Hard disk test method and device, equipment and storage medium

By injecting logical errors into the hard disk sector and simulating the bad sector scenario, the hard disk's remapping ability is verified, and the problem that the hard disk cannot actively discover defects before use is solved, improving the stability and robustness of the hard disk.

CN120540917APending Publication Date: 2025-08-26INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202510667871.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-22
Publication Date
2025-08-26

AI Technical Summary

Technical Problem

The existing technology cannot proactively discover the defects of the hard disk before problems occur, resulting in low stability and robustness of the hard disk.

Method used

By injecting logical errors into the target sector of the target hard disk, the bad sector scenario is simulated, and the hard disk's remapping ability is verified, including writing preset data to the target sector and performing read operations on the backup sector, verifying the processing mechanism of the hard disk when processing the bad sector.

Benefits of technology

It improves the ability of hard disk to handle bad sector problems before use, and enhances the stability and robustness of hard disk.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120540917A_ABST
    Figure CN120540917A_ABST
Patent Text Reader

Abstract

The invention provides a hard disk testing method and device, equipment and a storage medium, and can be applied to the technical field of hard disk testing. The hard disk test method comprises the steps that in response to a received test request for a target hard disk, a target error injection instruction matched with a target sector in the target hard disk is executed, and the target error injection instruction is used for injecting a logic error into the target sector; writing first preset data into the target sector under the condition of determining that the execution of the target error injection instruction is completed; when it is determined that the bad sector information of the target hard disk indicates that the target sector is a bad sector, according to the mapping relation between the sector of the target hard disk and the standby sector, executing a read operation on the target standby sector having the mapping relation with the target sector to obtain first read data; and comparing the first read data with first preset data, and determining a first test result for the target hard disk.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of hard disk testing technology, and more specifically to a hard disk testing method, apparatus, device, and storage medium. Background Art

[0002] With the advancement of hard drive technology and the increasing demand for hard drives, hard drives have become widely used. As core storage media, hard drives store critical data such as business systems, databases, and user information. A hard drive failure can result in data loss or service interruption. Therefore, to improve data reliability and service stability, it's necessary to enhance the robustness and stability of hard drives.

[0003] However, maintenance of the hard disk is usually performed after a problem occurs in the hard disk, and the problem is analyzed and processed, but the defects of the hard disk cannot be discovered before the problem occurs, resulting in low stability and robustness of the hard disk. Summary of the Invention

[0004] In view of the above problems, the present application provides a hard disk testing method, apparatus, device, medium and program product.

[0005] According to the first aspect of the present application, a hard disk testing method is provided, comprising: in response to receiving a test request for a target hard disk, executing a target error injection instruction that matches a target sector in the target hard disk, the target error injection instruction being used to inject a logical error into the target sector; upon determining that the execution of the target error injection instruction is complete, writing first preset data into the target sector; upon determining that the bad sector information of the target hard disk indicates that the target sector is a bad sector, performing a read operation on the target spare sector that has the above-mentioned mapping relationship with the target sector according to the mapping relationship between the bad sector and the spare sector of the target hard disk, to obtain first read data; and comparing the first read data with the first preset data to determine a first test result for the target hard disk.

[0006] The second aspect of the present application provides a hard disk testing device, including: a target error injection module, which is used to execute a target error injection instruction matching a target sector in the above-mentioned target hard disk in response to receiving a test request for the target hard disk, and the above-mentioned target error injection instruction is used to inject a logical error into the above-mentioned target sector; a first writing module, which is used to write first preset data to the above-mentioned target sector when it is determined that the execution of the above-mentioned target error injection instruction is completed; a first reading module, which is used to perform a read operation on the target spare sector that has the above-mentioned mapping relationship with the above-mentioned target sector according to the mapping relationship between the bad sector and the spare sector of the above-mentioned target hard disk when it is determined that the bad sector information of the above-mentioned target hard disk indicates that the above-mentioned target sector is a bad sector, to obtain first read data; a comparison and determination module, which is used to compare the above-mentioned first read data with the above-mentioned first preset data to determine the first test result for the above-mentioned target hard disk.

[0007] The third aspect of the present application provides an electronic device, comprising: one or more processors; a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the above method.

[0008] The fourth aspect of the present application further provides a computer-readable storage medium having a computer program or instructions stored thereon, which implements the steps of the above method when the computer program or instructions are executed by a processor.

[0009] The fifth aspect of the present application further provides a computer program product, comprising a computer program or instructions, which implement the steps of the above method when executed by a processor.

[0010] According to an embodiment of the present application, by proactively injecting a logical error into the target sector of the target hard disk before using the target hard disk, a scenario in which a bad sector appears in the actual use of the target hard disk can be simulated. Furthermore, by writing a first preset data into the target sector after the logical error is injected to simulate the scenario in which a user performs a write operation on the bad sector, and performing a read operation on the target spare sector of the target sector, it is possible to verify whether the target hard disk can map the operation on the bad sector to the spare sector, thereby testing the remapping capability of the target hard disk. Furthermore, before using the target hard disk, the target hard disk's processing mechanism for handling bad sector problems can be verified, thereby improving the robustness and stability of the hard disk. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The above contents and other objects, features and advantages of the present application will become more apparent through the following description of the embodiments of the present application with reference to the accompanying drawings, in which:

[0012] Figure 1A diagram schematically illustrates an application scenario of a hard disk testing method, apparatus, device, medium, and program product according to an embodiment of the present application;

[0013] Figure 2 The flowchart of the hard disk testing method according to the embodiment of the present application is schematically shown;

[0014] Figure 3 A flowchart for determining the protocol type of a target hard disk according to an embodiment of the present application is schematically shown;

[0015] Figure 4 Schematically shows a schematic diagram of the change of the error count value according to an embodiment of the present application;

[0016] Figure 5 A schematic diagram schematically shows a mapping relationship according to a specific embodiment of the present application;

[0017] Figure 6 The flowchart of the hard disk testing method according to the embodiment of the present application is schematically shown;

[0018] Figure 7 A block diagram schematically illustrates a structure of a hard disk testing device according to an embodiment of the present application; and

[0019] Figure 8 A block diagram of an electronic device suitable for implementing a hard disk testing method according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION

[0020] Hereinafter, embodiments of the present application will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present application. In the detailed description below, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present application. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessarily confusing the concepts of the present application.

[0021] The terms used herein are only for describing specific embodiments and are not intended to limit the present application. The terms "comprise," "include," etc. used herein indicate the presence of features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.

[0022] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0023] When expressions such as "at least one of A, B, and C, etc." are used, they should generally be interpreted in accordance with the meaning commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0024] With the rapid development of hard drive technology and the rapidly increasing demand for hard drives, hard drives have become widely used in various applications in daily life, and the requirements for hard drive stability and robustness are becoming increasingly higher. However, during the use of hard drives, problems are usually analyzed and solved after they occur, rather than proactively preventing potential problems before use, resulting in low hard drive stability and robustness.

[0025] In order to verify the stability and robustness of the hard disk in advance, an embodiment of the present application provides a hard disk testing method, including: in response to receiving a test request for a target hard disk, executing a target error injection instruction that matches a target sector in the target hard disk, the target error injection instruction is used to inject logical errors into the target sector; when it is determined that the execution of the target error injection instruction is completed, writing first preset data to the target sector; when it is determined that the bad sector information of the target hard disk indicates that the target sector is a bad sector, according to the mapping relationship between the sector of the target hard disk and the spare sector, performing a read operation on the target spare sector that has a mapping relationship with the target sector to obtain first read data; comparing the first read data with the first preset data to determine a first test result for the target hard disk.

[0026] The embodiments of the present application simulate the sector damage problem of the hard disk during actual use by performing logical error injection on the target sector, and write data to the target sector to verify whether the spare sector of the target sector can replace the work of the target sector when the target sector is a bad sector. Before the target hard disk is officially put into use, the processing mechanism when the target hard disk encounters damage problems is verified, thereby improving the robustness and stability of the hard disk.

[0027] Figure 1 The application scenario diagram of the hard disk testing method, apparatus, device, medium and program product according to the embodiments of the present application is schematically shown.

[0028] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a first server 110 and a second server 120 , wherein the first server 110 includes a target hard disk 111 to be tested.

[0029] The first server 110 may be a server for providing a test environment for the target hard disk 111. The second server 120 may be a server for providing a test service, such as testing the target hard disk 111 in the first server 110 and determining a test result for the target hard disk 111.

[0030] It should be noted that the hard disk testing method provided in the embodiment of the present application can generally be executed by the second server 120. Accordingly, the hard disk testing device provided in the embodiment of the present application can generally be set in the second server 120. The hard disk testing method provided in the embodiment of the present application can also be executed by a server or server cluster that is different from the second server 120 and can communicate with the first server 110 and / or the second server 120. Accordingly, the hard disk testing device provided in the embodiment of the present application can also be set in a server or server cluster that is different from the second server 120 and can communicate with the first server 110 and / or the second server 120.

[0031] It should be understood that Figure 1 The number of the first server, the second server and the hard disk is only for illustration. Any number of terminal devices, networks and servers may be provided as required.

[0032] The following will be based on Figure 1 The scene described by Figures 2 to 6 The hard disk testing method of the application embodiment is described in detail.

[0033] Figure 2 The flowchart of the hard disk testing method according to the embodiment of the present application is schematically shown.

[0034] like Figure 2 As shown, the hard disk testing method of this embodiment includes operations S210 to S240.

[0035] In operation S210 , in response to receiving a test request for a target hard disk, a target error injection instruction matching a target sector in the target hard disk is executed.

[0036] When testing the robustness and stability of a hard disk before putting it into use, the target hard disk to be tested can be placed in a first server that can provide a testing environment. The first server can be used to send a test request for the target hard disk to a second server that provides testing services. The second server tests the target hard disk in response to receiving the test request.

[0037] When testing the target hard disk, you can execute the target error injection instruction for injecting logical errors into the target sector to simulate the situation where the target hard disk generates logical bad sectors during actual application, so as to test the error handling mechanism of the target hard disk.

[0038] When selecting a target sector from multiple sectors of the target hard disk, the target sector can be randomly selected from the multiple sectors, or a sector specified by the user can be determined as the target sector. For example, an input box for entering a sector address can be displayed on the user's terminal, and the target sector can be determined based on the sector address entered by the user in the input box.

[0039] Before executing the error-recording instruction, since different instruction types correspond to different hard disk types, the hard disk type of the target hard disk may be determined first, and then the corresponding target error-recording instruction may be determined according to the hard disk type of the target hard disk.

[0040] In operation S220, when it is determined that the target error injection instruction is executed, first preset data is written to the target sector.

[0041] When the target error injection instruction is executed, the target sector has been injected with a logical error. At this time, the target sector cannot perform read and write operations normally. The first preset data can be written to the target sector to verify the target hard disk's handling method of writing operations on logical bad sectors.

[0042] In operation S230, when it is determined that the bad sector information of the target hard disk indicates that the target sector is a bad sector, a read operation is performed on the target spare sector that has a mapping relationship with the target sector according to the mapping relationship between the sectors of the target hard disk and the spare sectors to obtain first read data.

[0043] Since hard disks usually have a bad block management mechanism, for example, updating bad sector information according to the real-time status of each sector in the hard disk, it is possible to determine whether the target hard disk has identified the target sector as a bad sector based on the bad sector information of the target hard disk.

[0044] The bad sector information may store the bad sector address of each bad sector. Based on the bad sector address and the sector address of the target sector, it can be determined whether the bad sector information indicates that the target sector is a bad sector, and further, whether the target hard disk has updated the bad sector information in real time. For example, if the bad sector address includes the sector address of the target sector, it can be determined that the bad sector information indicates that the target sector is a bad sector.

[0045] In some embodiments, bad sector information may be stored in a data table in a preset area of ​​the target hard disk, such as a bad sector table. Therefore, the bad sector table may be retrieved based on the preset area corresponding to the target hard disk, and the bad sector table may be used to determine whether the target hard disk has identified the target sector as a bad sector.

[0046] To ensure the stability and robustness of the hard disk, the hard disk usually has a remapping capability, which can map operations on logical bad sectors to other sectors and use other sectors to process the operations.

[0047] For example, when the target hard disk has the remapping capability, the target hard disk will determine a target spare sector from multiple spare sectors to replace the target sector, and map the write operation for the target sector to the target spare sector, and write the first preset data to the target spare sector to use the target spare sector to replace the target sector.

[0048] In some embodiments, the mapping relationship between bad sectors and spare sectors can be stored in bad sector information, such as in a bad sector table. When the bad sector information indicates that the target sector is a bad sector, the target spare sector corresponding to the target sector can be determined from the bad sector information.

[0049] In the case that the target hard disk has the remapping capability, the remapping capability of the target hard disk may be tested to ensure that the target hard disk has the remapping capability during use, thereby improving the stability and robustness of the target hard disk.

[0050] When testing the remapping capability of the target hard disk, a read operation can be performed on the target spare sector to read the data stored in the target spare sector as the first read data, and then it can be determined whether the first preset data has been written in the target spare sector based on the read data.

[0051] In operation S240 , the first read data is compared with first preset data to determine a first test result for the target hard disk.

[0052] When comparing the first read data with the first preset data, it can be determined whether the first read data includes the first preset data. If the first read data includes the first preset data, the first test result is determined to be that the remapping capability of the target hard disk is normal; otherwise, it can be determined that the remapping capability of the target hard disk is abnormal.

[0053] According to an embodiment of the present application, by proactively injecting a logical error into the target sector of the target hard disk before using the target hard disk, a scenario in which a bad sector appears in the actual use of the target hard disk can be simulated. Furthermore, by writing a first preset data into the target sector after the logical error is injected to simulate the scenario in which a user performs a write operation on the bad sector, and performing a read operation on the target spare sector of the target sector, it is possible to verify whether the target hard disk can map the operation on the bad sector to the spare sector, thereby testing the remapping capability of the target hard disk. Furthermore, before using the target hard disk, the target hard disk's processing mechanism for handling bad sector problems can be verified, thereby improving the robustness and stability of the hard disk.

[0054] According to an embodiment of the present application, the target error note instruction is generated in the following manner: based on the drive letter of the target hard disk, the protocol type of the target hard disk is determined; according to the protocol type, the initial error note instruction that matches the target hard disk is determined; according to the initial error note instruction and the first address of the target sector, the target error note instruction is generated.

[0055] Because different protocol types correspond to different command tools, a target error annotation command can be generated based on the protocol type of the target hard drive and the first address of the target sector to implement error annotation on the target sector. The first address can be the logical address of the target sector in the Logical Block Addressing (LBA) mode.

[0056] When determining the protocol type of the target hard disk, the protocol type can be determined based on the drive letter of the target hard disk. For example, the protocol type of the target hard disk can be determined based on the drive letter path of the drive letter.

[0057] When determining the initial error injection instruction that matches the target hard disk, you can first determine the instruction tool that matches the protocol type, and then determine the initial error injection instruction for injecting logical errors under the instruction tool, write unrecoverable errors to the sector, and artificially create logical bad sectors.

[0058] For example, the command tool that matches the Serial Advanced Technology Attachment (SATA) protocol is hdparm, and the initial error annotation command may be --make-bad-sector; the command tool that matches the Non-Volatile Memory Express (NVME) protocol is nvme, and the initial error annotation command may be write-uncor; the command tool that matches the Serial Attached SCSI (SAS) protocol is sg_write_long, and the initial error annotation command may be --wr_uncor.

[0059] After the initial error injection instruction is determined, in order to inject a logic error into the target sector, the first address may be added to the initial error injection instruction to generate a target error injection instruction.

[0060] According to an embodiment of the present application, by determining the protocol type of the target hard disk and the first address of the target sector, a target error annotation instruction matching the target sector is generated, thereby improving the accuracy of the target error annotation instruction and thereby improving the accuracy of the hard disk test.

[0061] According to an embodiment of the present application, the protocol type of the target hard disk is determined based on the drive letter of the target hard disk, including: obtaining the drive letter of the target hard disk; when the drive letter path of the drive letter is a first preset path, determining that the protocol type of the target hard disk is a first protocol type; when the drive letter path of the drive letter is a second preset path, obtaining the protocol parameter of the target hard disk; when the parameter value of the protocol parameter is a first preset parameter value, determining that the protocol type of the target hard disk is a second protocol type; when the parameter value of the protocol parameter is a second preset parameter value, determining that the protocol type of the target hard disk is a third protocol type.

[0062] To obtain the drive letter of the target hard disk, you can execute a drive letter query command to obtain the drive letter including the drive letter path. For example, the drive letter query command can be lsblk, and the drive letter obtained can be / dev / sd* or / dev / nvme*n1, and the drive letter path can be / dev / sd or / dev / nvme.

[0063] The first preset path may be / dev / nvme, and in this case the first protocol type corresponding to the first preset path is the NVME protocol.

[0064] The second preset path may be / dev / sd, and the protocol type corresponding to the second preset path includes a second protocol type and a third protocol type, wherein the second protocol type may be a SATA protocol, and the third protocol type may be a SAS protocol.

[0065] Since the protocol type corresponding to the second preset path includes both the second protocol type and the third protocol type, the protocol type of the target hard disk cannot be distinguished by the drive letter path alone. Therefore, the protocol parameters of the target hard disk can be further obtained to determine the protocol type of the target hard disk.

[0066] The protocol parameter corresponding to the second protocol type may be SATA Version, and the protocol parameter corresponding to the third protocol type may be Transport Protocol. In some embodiments, the protocol parameter may be obtained from Self-Monitoring Analysis and Reporting Technology (SMART) information of the target hard disk.

[0067] The protocol parameters included in the SMART information may also differ depending on the hard drive protocol type. For example, the SMART report for a SATA hard drive includes the protocol parameter "SATA Version," while the SMART report for a SAS hard drive does not. Therefore, when querying the SATA Version of a SATA hard drive, the result is "SATA," but when querying the SATA Version of a SAS hard drive, no parameter value is found.

[0068] In some embodiments, the first preset parameter value can be set to SATA and the second preset parameter value can be set to SAS. Specifically, the parameter value of SATA Version of the target hard disk can be queried first. When the parameter value is the first preset parameter value SATA, it is determined that the protocol of the target hard disk is SATA. If the parameter value cannot be queried, the parameter value of Transport Protocol of the target hard disk can be queried. When the parameter value is the second preset parameter value SAS, it is determined that the protocol of the target hard disk is SAS.

[0069] According to an embodiment of the present application, by determining the protocol type of the target hard disk based on the drive letter path of the target hard disk and the parameter value of the protocol parameter, the accuracy of the determined protocol type is improved, thereby making the hard disk testing method applicable to hard disks of different protocol types, and expanding the scope of use of the hard disk testing method.

[0070] Figure 3 The flowchart of determining the protocol type of the target hard disk according to an embodiment of the present application is schematically shown.

[0071] like Figure 3 As shown, determining the protocol type of the target hard disk includes operations S310 to S370.

[0072] In operation S310 , a drive letter of a target hard disk is obtained.

[0073] In operation S320, it is determined whether the drive letter path is the first preset path. If the drive letter path is the first preset path, operation S350 is performed, otherwise operation S330 is performed.

[0074] In operation S330 , protocol parameters of the target hard disk are acquired.

[0075] In operation S340, it is determined whether the parameter value of the protocol parameter is the first preset parameter value. If the parameter value of the protocol type is the first preset parameter value, operation S360 is performed; otherwise, operation S370 is performed.

[0076] In operation S350 , it is determined that the protocol type of the target hard disk is a first protocol type.

[0077] In operation S360 , it is determined that the protocol type of the target hard disk is the second protocol type.

[0078] In operation S370 , it is determined that the protocol type of the target hard disk is a third protocol type.

[0079] According to an embodiment of the present application, after executing a target error annotation instruction that matches a target sector in a target hard disk, the hard disk testing method further includes: obtaining a current error count value during a read operation on the target sector; comparing the current error count value with a historical error count value to obtain a comparison result; and determining that execution of the target error annotation instruction is complete when the comparison result indicates the presence of a new error.

[0080] In order to ensure the accuracy of the test results, verification is required after executing the target error injection instruction to ensure that the error handling mechanism of the target hard disk is tested after the target error injection instruction is executed.

[0081] To determine whether the target error injection command has been executed, you can perform a read operation on the target sector. If the target sector is already a bad sector, read and write operations cannot be performed normally, and an error will be generated. Therefore, by comparing the error count values ​​before and after the read operation, you can determine whether the target hard drive has reported an error, and further determine whether the target sector is already a bad sector.

[0082] The current error count value may be the error count value after the read operation is performed, and the historical error count value may be the error count value before the read operation is performed. For example, the error count value may be obtained before the read operation is performed and determined as the historical error count value, and the error count value may be obtained after the read operation is performed and determined as the current error count value.

[0083] In some embodiments, different protocol types may correspond to different error count types. Therefore, it is necessary to determine the error count type corresponding to the target hard drive based on the protocol type of the target hard drive. For example, the error count corresponding to the SATA and SAS protocols may be Reported_Uncorrect, and the error count corresponding to NVME may be media_errors.

[0084] When comparing the current error count value with the historical error count value, if the historical error count value is A, it can be determined whether the current error count value is A+1. If the current error count value is A+1, it can be determined that the comparison result indicates that a new error has been reported, and the target error-noting instruction has been executed successfully. If the current error count value is A, it can be determined that the comparison result indicates that no new error has been reported, and the target error-noting instruction has failed to execute.

[0085] In other embodiments of the present application, an error count value may be obtained before executing the target error-injection instruction and determined as the initial error count value. If the initial error count value is A, the historical error count value is A, and the current error count value is A+1, it is determined that the comparison result indicates the presence of a new error, and execution of the target error-injection instruction is complete.

[0086] According to the embodiments of the present application, by verifying the execution status of the target incorrectly injected instruction, it is possible to ensure that subsequent test steps are executed only after the execution of the target incorrectly injected instruction is completed, thereby improving the accuracy of the test.

[0087] Figure 4 The diagram schematically shows the change of the error count value according to an embodiment of the present application.

[0088] like Figure 4 As shown, when the error count value is the initial error count value 410, the value is A. After executing the target error injection instruction, the error count value is the historical error count value 420, and the value is A. After performing the read operation, the error count value is the current error count value 430. Since the read operation cannot be performed when the target sector is a bad sector, an error is generated, and the value is A+1.

[0089] According to an embodiment of the present application, the mapping relationship includes a sub-mapping relationship between a bad sector address and a spare sector address. Based on the mapping relationship between the bad sector and the spare sector of the target hard disk, performing a read operation on a target spare sector that has a mapping relationship with the target sector to obtain first read data includes: determining a second address of the target spare sector using the sub-mapping relationship based on the first address of the target sector; and performing a read operation on the target spare sector using the second address to obtain the first read data.

[0090] In the bad sector information, the bad sector can be identified by the sector address of the bad sector, and the spare sector can be identified by the sector address of the spare sector. Therefore, the mapping relationship between the bad sector and the spare sector can include the mapping relationship between the bad sector address and the spare sector address.

[0091] In an embodiment of the present application, the target error injection instruction may include the first address of the target sector, and when the bad sector information includes the sector information of the target sector, the second address of the target spare sector of the target sector may be determined based on the first address of the target sector.

[0092] When reading data stored in the target spare sector, a read operation may be performed on the second address using a read data instruction corresponding to the target hard disk to obtain first read data.

[0093] According to an embodiment of the present application, the second address of the target spare sector is obtained according to the sub-mapping relationship, and the second address is used to directly perform a read operation on the target spare sector, thereby further verifying the remapping capability of the target hard disk and improving the accuracy of the first read data.

[0094] Figure 5 The following is a schematic diagram schematically showing a mapping relationship according to a specific embodiment of the present application.

[0095] like Figure 5 As shown, the target hard disk includes 8 sectors, such as sector 0, sector 1, sector 2, ..., sector 6 and sector 7. In the case that sector 1 is a bad sector, the spare sector that has a mapping relationship with sector 1 is sector 7, and sector 7 is used to replace sector 1 for read and write operations.

[0096] According to an embodiment of the present application, the hard disk testing method also includes: executing target error annotation instructions on multiple target sectors of the target hard disk respectively; when multiple target error annotation instructions are executed, using a preset script to perform a high-load write operation on the target hard disk; in the process of executing the high-load write operation, obtaining an error count value; and determining a fourth test result for the target hard disk based on the error count value.

[0097] In an embodiment of the present disclosure, target error injection instructions are executed on multiple target sectors respectively to create multiple logical bad sectors, so as to simulate a scenario in which a large number of logical bad sectors exist in the target hard disk, and verify the ability of the target hard disk to withstand high loads when a large number of logical bad sectors exist in the target hard disk.

[0098] Because the target drive has remapping capabilities, the error count value remains unchanged even when write operations are performed on the target sector. However, if the target drive has a large number of logically bad sectors and is under heavy load, the target drive's stability may deteriorate, and write operations to the bad sectors may not be mapped to spare sectors, resulting in errors.

[0099] When determining the fourth test result based on the error count value, the fourth test result can be determined based on the time when the error count value first changes and the trend of changes in the error count value during the write operation. For example, the later the time when the error count value first changes, the greater the target hard drive's ability to withstand high loads and greater stability when a large number of logical bad sectors exist.

[0100] According to an embodiment of the present application, by injecting errors into multiple sectors, a scenario in which a large number of logical bad sectors exist in the target hard disk is simulated, and the scenario in which a large number of logical bad sectors exist in the target hard disk is combined with a scenario of undergoing high-load read and write operations to verify the stability of the target hard disk, thereby making the verification of the target hard disk more comprehensive and improving the stability of the target hard disk.

[0101] According to an embodiment of the present application, the hard disk testing method also includes: executing a target recovery instruction that matches the target sector in the target hard disk; when it is determined that the target recovery instruction has been executed, performing a power-off operation on the target hard disk to simulate an abnormal power failure of the target hard disk; performing a power-on operation on the target hard disk, comparing the target sector information with the bad sector information, and determining a second test result for the target hard disk.

[0102] Since users will repair logical bad sectors during the actual use of the hard disk, when testing the target hard disk, you can also simulate the situation where users repair logical bad sectors by executing the target recovery instruction for repairing the target sector after the logical error is injected, so as to test the processing mechanism of the target hard disk after the logical bad sector is repaired.

[0103] Before executing the target recovery instruction, a target recovery instruction needs to be generated. In some embodiments, the target recovery instruction is generated in a manner similar to the target error instruction, and is generated by: determining an initial recovery instruction that matches the target hard drive based on the protocol type of the target hard drive; and generating the target recovery instruction based on the initial recovery instruction and the first address of the target sector.

[0104] The initial recovery instruction can rewrite the target sector to restore the target sector to normal. For example, before executing the target error instruction, the data stored in the target sector can be backed up, and when restoring the target sector, the backup data is used to rewrite the target sector.

[0105] When determining the initial recovery command that matches the target hard disk, the command tool that matches SATA is hdparm, the command tool that matches SAS is sg_dd, and the command tool that matches NVME is nvme.

[0106] After the initial recovery instruction is determined, the first address may be added to the initial recovery instruction to obtain a target recovery instruction to recover the target sector.

[0107] After executing the target recovery instruction, you can also verify whether the target recovery instruction is executed. After the target recovery instruction is executed, you can perform subsequent test operations to improve the accuracy of the test process.

[0108] When verifying whether the target recovery instruction has been executed, a read operation can be performed on the target sector. Since the target sector has recovered to normal, the read operation can be performed normally, so no error will be reported. At this time, the error count values ​​before and after the read operation are the same, and are the same as the current error count value, both A+1.

[0109] Since hard drives may experience problems such as abnormal power failure during actual use, the bad sector repair scenario of the hard drive can be further combined with the abnormal power failure scenario to further verify the robustness and stability of the target hard drive.

[0110] When a hard drive experiences an abnormal power outage, it may lose flash memory metadata and bad sector information. Therefore, you can verify the target hard drive's information persistence after a power outage and power cycle, such as whether the bad sector information is correct.

[0111] Because the target sector had already been restored to a normal state before the power outage, the bad sector information of the target hard drive after power is restored should not include the target sector information. When comparing the target sector information with the bad sector information, if the bad sector information does not include the target sector information, the second test result is determined to indicate that the target hard drive has a high information persistence capability and the firmware is able to read the historical bad sector information from the non-volatile storage medium.

[0112] According to the embodiments of the present application, by combining the bad sector recovery scenario with the abnormal power failure scenario, it is closer to the actual usage of the target hard disk, thereby realizing the verification of the information persistence capability of the hard disk in the abnormal power failure scenario and improving the robustness of the target hard disk.

[0113] According to an embodiment of the present application, after performing a power-on operation on the target hard disk, the hard disk testing method also includes: writing second preset data to the first address of the target sector; performing a read operation on the second address of the target spare sector to obtain second read data; performing a read operation on the first address of the target sector to obtain third read data; and determining a third test result for the target hard disk based on the second preset data, the second read data and the third read data.

[0114] In the event of an abnormal power outage, the target hard drive's mapping relationship reconstruction capability can also be verified. For example, if the target sector has been restored to a normal sector, it can be verified whether the target hard drive still maps write operations to the target backup sector according to the mapping relationship between the target sector and the target backup sector.

[0115] When verifying the mapping relationship reconstruction capability of the target hard disk, it is possible to write the second preset data to the target sector and then determine whether the second preset data is written to the target sector or the target spare sector.

[0116] When the target hard disk has not rebuilt the mapping relationship between the target sector and the target spare sector, the read operation performed on the first address of the target sector will still be mapped to the target spare sector for execution. Therefore, it is necessary to perform read operations on the target sector and the target spare sector respectively to determine whether the second preset data is written to the target sector or the target spare sector.

[0117] The second read data may be data stored in the target spare sector, and the third read data may be data stored in the target sector. If the second read data does not include the second preset data and the third read data includes the second preset data, it can be determined that the second preset data was written normally to the target sector, and the third test result indicates that the target hard disk can reconstruct the mapping relationship between the sector and the spare sector in the event of an abnormal power outage.

[0118] According to the embodiments of the present application, by combining the bad sector recovery scenario with the abnormal power failure scenario, it is tested whether the target sector can write data normally after power is restored, and then it is tested whether the target hard disk can rebuild the mapping relationship between the sector and the spare sector in the abnormal power failure scenario, thereby improving the robustness of the target hard disk.

[0119] Figure 6 The flowchart of the hard disk testing method according to the embodiment of the present application is schematically shown.

[0120] like Figure 6 As shown, the hard disk testing method includes operations S601 to S609.

[0121] In operation S601 , a drive letter of a target hard disk is obtained.

[0122] In operation S602 , a protocol type of a target hard disk is determined.

[0123] In operation S603 , a target error-injection instruction is generated and executed.

[0124] In operation S604, the execution status of the target error-injected instruction is checked.

[0125] In operation S605 , a first test result is determined.

[0126] In operation S606 , a target recovery instruction is generated and executed.

[0127] In operation S607 , the execution status of the target recovery instruction is checked.

[0128] In operation S608 , a second test result is determined.

[0129] In operation S609 , a third test result is determined.

[0130] Based on the above hard disk testing method, this application also provides a hard disk testing device. Figure 7 The device is described in detail.

[0131] Figure 7 The following schematically shows a structural block diagram of a hard disk testing device according to an embodiment of the present application.

[0132] like Figure 7As shown, the hard disk testing device 700 of this embodiment includes a target error injection module 710 , a first writing module 720 , a first reading module 730 and a comparison and determination module 740 .

[0133] Target error injection module 710 is configured to, in response to receiving a test request for a target hard drive, execute a target error injection instruction that matches a target sector on the target hard drive. The target error injection instruction is configured to inject a logical error into the target sector. In one embodiment, target error injection module 710 may be configured to perform operation S210 described above, and further description thereof will not be given here.

[0134] The first writing module 720 is used to write the first preset data to the target sector when it is determined that the target error injection instruction is executed. In one embodiment, the first writing module 720 can be used to perform the operation S220 described above, which will not be repeated here.

[0135] The first reading module 730 is configured to, when determining that the bad sector information of the target hard disk indicates that the target sector is a bad sector, perform a read operation on the target spare sector that is mapped to the target sector based on the mapping relationship between the bad sectors and spare sectors of the target hard disk, to obtain first read data. In one embodiment, the first reading module 730 can be configured to perform operation S230 described above, which will not be further described here.

[0136] The comparison and determination module 740 is used to compare the first read data with the first preset data to determine a first test result for the target hard disk. In one embodiment, the comparison and determination module 740 can be used to perform the operation S240 described above, which will not be repeated here.

[0137] According to an embodiment of the present application, the mapping relationship includes a sub-mapping relationship between bad sector addresses and spare sector addresses. The data reading module 730 includes an address determination module and a data reading sub-module.

[0138] The address determination submodule is used to determine the second address of the target spare sector according to the first address of the target sector by using the sub-mapping relationship.

[0139] The data reading submodule is used to perform a read operation on the target spare sector using the second address to obtain first read data.

[0140] According to an embodiment of the present application, the hard disk testing device 700 further includes a target recovery module, a target power-off module, and a target power-on module.

[0141] The target recovery module is used to execute a target recovery instruction that matches a target sector in a target hard disk. The target recovery instruction is used to recover the target sector after a logic error is injected.

[0142] The target power-off module is used to perform a power-off operation on the target hard disk when it is determined that the target recovery instruction has been executed, so as to simulate an abnormal power-off of the target hard disk.

[0143] The target power-on module is used to perform a power-on operation on the target hard disk, compare the target sector information with the bad sector information, and determine a second test result for the target hard disk.

[0144] According to an embodiment of the present application, the hard disk testing device 700 further includes a second writing module, a second reading module, a third reading module, and a result determination module.

[0145] The second writing module is used for writing second preset data into the first address of the target sector.

[0146] The second reading module is used to perform a read operation on a second address of the target spare sector to obtain second read data.

[0147] The third reading module is used to perform a read operation on the first address of the target sector to obtain third read data.

[0148] The result determination module is used to determine a third test result for the target hard disk based on the second preset data, the second read data, and the third read data.

[0149] According to an embodiment of the present application, the hard disk testing device 700 further includes a count acquisition module, a count comparison module, and an execution determination module.

[0150] The count acquisition module is used to obtain the current error count value during the process of performing a read operation on the target sector.

[0151] The counting comparison module is used to compare the current error counting value with the historical error counting value to obtain a comparison result.

[0152] The execution determination module is used to determine whether the target error-annotated instruction has been executed when the comparison result indicates that a new error has been reported.

[0153] According to an embodiment of the present application, the hard disk testing device 700 further includes a drive letter obtaining module, a first determining module, a second determining module, and a third determining module.

[0154] The drive letter acquisition module is used to obtain the drive letter of the target hard disk.

[0155] The first determining module is configured to determine that the protocol type of the target hard disk is a first protocol type when the drive letter path of the drive letter is a first preset path.

[0156] The second determining module is configured to determine that the protocol type of the target hard disk is a second protocol type when the parameter value of the protocol parameter is a first preset parameter value.

[0157] The third determining module is configured to determine that the protocol type of the target hard disk is a third protocol type when the parameter value of the protocol parameter is a second preset parameter value.

[0158] According to an embodiment of the present application, any multiple modules among the target error injection module 710, the first write module 720, the first read module 730, and the comparison and determination module 740 can be combined into a single module, or any one of them can be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules can be combined with at least part of the functionality of other modules and implemented in a single module. According to an embodiment of the present application, at least one of the target error injection module 710, the first write module 720, the first read module 730, and the comparison and determination module 740 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented in hardware or firmware by any other reasonable means of integrating or packaging circuits, or can be implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, at least one of the target error injection module 710 , the first writing module 720 , the first reading module 730 , and the comparison and determination module 740 may be at least partially implemented as a computer program module, which may perform corresponding functions when executed.

[0159] Figure 8 A block diagram of an electronic device suitable for implementing a hard disk testing method according to an embodiment of the present application is schematically shown.

[0160] like Figure 8 As shown, an electronic device 800 according to an embodiment of the present application includes a processor 801, which can perform various appropriate actions and processes based on a program stored in a read-only memory (ROM) 802 or a program loaded from a storage unit 808 into a random access memory (RAM) 803. The processor 801 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a dedicated microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 801 may also include onboard memory for caching purposes. The processor 801 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present application.

[0161] Various programs and data required for the operation of the electronic device 800 are stored in the RAM 803. The processor 801, ROM 802, and RAM 803 are connected to each other via a bus 804. The processor 801 performs various operations of the method flow according to the embodiment of the present application by executing the programs in the ROM 802 and / or RAM 803. It should be noted that the programs can also be stored in one or more memories other than the ROM 802 and RAM 803. The processor 801 can also perform various operations of the method flow according to the embodiment of the present application by executing the programs stored in one or more memories.

[0162] According to an embodiment of the present application, electronic device 800 may further include an input / output (I / O) interface 805, which is also connected to bus 804. Electronic device 800 may also include one or more of the following components connected to I / O interface 805: an input section 806 including a keyboard, mouse, etc.; an output section 807 including devices such as a cathode ray tube (CRT), liquid crystal display (LCD), and speakers; a storage section 808 including a hard disk; and a communication section 809 including a network interface card such as a LAN card or modem. Communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to I / O interface 805 as needed. Removable media 811, such as a magnetic disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed in drive 810 as needed, so that computer programs read from the removable media can be installed into storage section 808 as needed.

[0163] This application also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments, or may exist independently and not be incorporated into the device / apparatus / system. The computer-readable storage medium carries one or more programs, and when the one or more programs are executed, the method according to the embodiments of this application is implemented.

[0164] According to an embodiment of the present application, a computer-readable storage medium may be a non-volatile computer-readable storage medium, and may include, for example, but not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present application, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to an embodiment of the present application, a computer-readable storage medium may include the ROM 802 and / or RAM 803 described above and / or one or more memories other than ROM 802 and RAM 803.

[0165] The embodiments of the present application also include a computer program product, which includes a computer program containing program code for executing the method shown in the flowchart. When the computer program product is executed in a computer system, the program code is used to enable the computer system to implement the hard disk testing method provided in the embodiments of the present application.

[0166] The computer program executes the above functions defined in the system / device of the embodiment of the present application when the processor 801 executes the computer program. According to the embodiment of the present application, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0167] In one embodiment, the computer program may be stored on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may be transmitted and distributed in the form of a signal on a network medium, downloaded and installed via the communication portion 809, and / or installed from a removable medium 811. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to wireless, wired, or any suitable combination thereof.

[0168] In such an embodiment, the computer program can be downloaded and installed from the network via the communication section 809, and / or installed from the removable medium 811. When the computer program is executed by the processor 801, the above-mentioned functions defined in the system of the embodiment of the present application are performed. According to the embodiment of the present application, the systems, devices, means, modules, units, etc. described above can be implemented by computer program modules.

[0169] According to an embodiment of the present application, the program code for executing the computer program provided by the embodiment of the present application can be written in any combination of one or more programming languages. Specifically, these computer programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, languages ​​such as Java, C++, Python, "C" or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect via the Internet).

[0170] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of the boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0171] Those skilled in the art will appreciate that the features described in the various embodiments of this application may be combined and / or coupled in various ways, even if such combinations or couplings are not explicitly described in this application. In particular, the features described in the various embodiments of this application may be combined and / or coupled in various ways without departing from the spirit and teachings of this application. All such combinations and / or couplings fall within the scope of this application.

[0172] The embodiments of the present application have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of the present application. Although each embodiment has been described separately above, this does not mean that the measures in each embodiment cannot be advantageously used in combination. Without departing from the scope of the present application, those skilled in the art may make various substitutions and modifications, and these substitutions and modifications should all fall within the scope of the present application.

Claims

1. A hard disk testing method, characterized in that: The method comprises: In response to receiving a test request for a target hard disk, executing a target error injection instruction that matches a target sector in the target hard disk, the target error injection instruction being used to inject a logical error into the target sector; When it is determined that the target error injection instruction is executed, writing first preset data into the target sector; When it is determined that the bad sector information of the target hard disk indicates that the target sector is a bad sector, performing a read operation on a target spare sector having the mapping relationship with the target sector according to the mapping relationship between the bad sectors and spare sectors of the target hard disk to obtain first read data; The first read data is compared with the first preset data to determine a first test result for the target hard disk.

2. The method according to claim 1, characterized in that The mapping relationship includes a sub-mapping relationship between a bad sector address and a spare sector address; and performing a read operation on a target spare sector having the mapping relationship with the target sector according to the mapping relationship between the bad sector and the spare sector of the target hard disk to obtain first read data, including: Determining a second address of the target spare sector using the sub-mapping relationship according to the first address of the target sector; A read operation is performed on the target spare sector using the second address to obtain the first read data.

3. The method according to claim 1, characterized in that The method further comprises: executing a target recovery instruction that matches a target sector in the target hard disk, wherein the target recovery instruction is used to recover the target sector after a logic error is injected; When it is determined that the target recovery instruction is executed successfully, performing a power-off operation on the target hard disk to simulate an abnormal power-off of the target hard disk; A power-on operation is performed on the target hard disk, and the information of the target sector is compared with the bad sector information to determine a second test result for the target hard disk.

4. The method according to claim 3, characterized in that After powering on the target hard disk, the method further includes: Writing second preset data to the first address of the target sector; Performing a read operation on a second address of the target spare sector to obtain second read data; performing a read operation on the first address of the target sector to obtain third read data; A third test result for the target hard disk is determined based on the second preset data, the second read data, and the third read data.

5. The method according to claim 1, wherein After executing the target error-notification instruction that matches the target sector in the target hard disk, the method further includes: During a read operation on the target sector, obtaining a current error count value; Comparing the current error count value with the historical error count value to obtain a comparison result; When the comparison result indicates that a new error exists, it is determined that the target error-annotation instruction is executed successfully.

6. The method according to claim 1, characterized in that The method further comprises: Determining a protocol type of the target hard disk based on the drive letter of the target hard disk; determining, according to the protocol type, an initial error-injection instruction that matches the target hard disk; The target error injection instruction is generated according to the initial error injection instruction and the first address of the target sector.

7. The method according to claim 6, characterized in that The determining the protocol type of the target hard disk based on the drive letter of the target hard disk includes: Obtain the drive letter of the target hard disk; When the drive path of the drive letter is the first preset path, determining that the protocol type of the target hard disk is the first protocol type; When the drive path of the drive letter is the second preset path, obtaining the protocol parameters of the target hard disk; When the parameter value of the protocol parameter is the first preset parameter value, determining that the protocol type of the target hard disk is the second protocol type; When the parameter value of the protocol parameter is the second preset parameter value, it is determined that the protocol type of the target hard disk is a third protocol type.

8. A hard disk testing device, characterized in that: The device comprises: a target error injection module, configured to, in response to receiving a test request for a target hard disk, execute a target error injection instruction that matches a target sector in the target hard disk, wherein the target error injection instruction is configured to inject a logical error into the target sector; A first writing module is configured to write first preset data into the target sector when it is determined that the target error injection instruction has been executed; a first reading module configured to, when determining that the bad sector information of the target hard disk indicates that the target sector is a bad sector, perform a read operation on a target spare sector having a mapping relationship with the target sector based on a mapping relationship between bad sectors and spare sectors of the target hard disk, to obtain first read data; The comparison and determination module is configured to compare the first read data with the first preset data to determine a first test result for the target hard disk.

9. An electronic device comprising: one or more processors; a memory for storing one or more computer programs, It is characterized in that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Test method of storage control equipment and electronic equipment

    CN120743606A

  • Hard disk test method, electronic equipment, medium and computer program product

    CN120743658A

  • Hard disk testing method, electronic device, medium, and computer program product

    CN120743658B