Method, device, storage medium and electronic device for verifying data during power failure

By constructing write commands with preset parameters and independent power-off and re-power-on during the data writing process, the problem of data integrity verification of solid-state drives in the event of unexpected power loss is solved, and accurate data integrity and reliability are achieved. Detection, applicable to various SSD types.

CN111897685BActive Publication Date: 2024-09-03BIWIN STORAGE TECH CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202010742942.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-29
Publication Date
2024-09-03
Estimated Expiration
2040-07-29

AI Technical Summary

Technical Problem

It is difficult to effectively verify the data integrity and reliability of solid-state drives in the event of unexpected power outages with existing technology.

Method used

By constructing a write command containing preset parameters, data is written to the hard disk disk to be tested, and the power is individually powered off and on again during the writing process, and the stored write command parameters are used for data verification to ensure that the data is Integrity and reliability under power loss conditions.

Benefits of technology

It realizes the data integrity and reliability verification of solid-state drives in the event of unexpected power outage, improves the accuracy and compatibility of the test, and can accurately count the successful and failed data written, and is suitable for various types of solid-state drives.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111897685B
    Figure CN111897685B
Patent Text Reader

Abstract

The present invention discloses a method, device, storage medium and electronic device for verifying data during power failure. The method constructs a write command containing preset parameters, writes data to a hard disk platter to be tested according to the constructed write command, and stores the preset parameters corresponding to the successfully written write command. The preset parameters include a starting logical block address, a data writing address range and a data model. During the data writing process, the hard disk platter to be tested is powered off and then powered on again. After powering on again, data is read from the hard disk platter to be tested according to the preset parameters corresponding to the stored write command and data verification is performed. According to the verification result, it is possible to count which data is successfully written and which data is failed to be written at the moment of power failure, thereby accurately verifying the data integrity of the hard disk platter in the event of an unexpected power failure. At the same time, according to the verification result, the reliability of the hard disk platter in reconstructing data can also be verified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of hard disk testing, and in particular to a method, device, storage medium and electronic equipment for verifying data during power failure. Background Art

[0002] During the SSD (Solid State Disk) disk test, targeted reliability tests will be performed, among which abnormal power loss verification of disk reliability is one of them. Most hard disk consistency verifications only verify the integrity of data by writing first and then reading when the disk is in normal state and the power supply is stable. However, in the actual use of solid-state hard disks, it is inevitable that the disk power supply suddenly flashes or completely loses power during the reading and writing IO process. At this time, the SSD needs to protect the data on the disk in this extreme case. Due to the SSD firmware architecture and cache characteristics, part of the data has been written to the back-end Nand Flash at this time, and the other part of the data is in the cache or is being processed and has not been written to the Nand Flash. Then for SSDs that claim not to support power-off protection, it is necessary to ensure the consistency of the data written to the Nand Flash. For SSDs that claim to support power-off protection, it is necessary to ensure that the data of all hosts that receive successful commands should be consistent. However, there are few tests for solid-state hard disks under abnormal power supply in the prior art. Summary of the invention

[0003] The technical problem to be solved by the present invention is to provide a method, device, storage medium and electronic equipment for verifying data during power failure, which can verify the data integrity of a disk in the event of an unexpected power failure.

[0004] In order to solve the above technical problems, a technical solution adopted by the present invention is:

[0005] A method for verifying data during power failure, comprising the steps of:

[0006] The hard disk platter to be tested is powered on independently, and when an instruction indicating that the hard disk platter to be tested is successfully identified is received, a write command including preset parameters is constructed, wherein the preset parameters include a starting logical block address, a data write address range, and a data model;

[0007] Writing data to the hard disk platter to be tested according to the write command, and storing preset parameters corresponding to the successfully written write command;

[0008] During the data writing process, the hard disk platter to be tested is powered off separately;

[0009] The hard disk platter to be tested is powered on again independently, and when an instruction indicating that the hard disk platter to be tested is successfully identified is received, data is read from the hard disk platter to be tested and data verification is performed according to preset parameters corresponding to the stored write command.

[0010] In order to solve the above technical problems, another technical solution adopted by the present invention is:

[0011] A device for verifying data when power is off, comprising:

[0012] Power-on module, used to independently power on the hard disk platter to be tested;

[0013] A command construction module, configured to construct a write command including preset parameters after the power-on module independently powers on the hard disk platter to be tested, upon receiving an instruction indicating that the hard disk platter to be tested is successfully identified, wherein the preset parameters include a starting logical block address, a data write address range, and a data model;

[0014] A data writing module, used for writing data to the hard disk platter to be tested according to the write command, and storing preset parameters corresponding to the successfully written write command;

[0015] A power-off module, used to power off the hard disk platter to be tested separately during the data writing process;

[0016] A data reading module is used to read data from the hard disk platter to be tested and perform data verification according to preset parameters corresponding to the stored write command when receiving an instruction indicating that the hard disk platter to be tested is successfully identified after the power-on module independently powers on the hard disk platter to be tested.

[0017] In order to solve the above technical problems, another technical solution adopted by the present invention is:

[0018] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the various steps of the method for verifying data during power failure.

[0019] In order to solve the above technical problems, another technical solution adopted by the present invention is:

[0020] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, each step of the method for verifying data during power failure is implemented.

[0021] The beneficial effects of the present invention are as follows: by constructing a write command including preset parameters, and writing data to the hard disk platter to be tested according to the constructed write command, and storing the preset parameters corresponding to the write command that is written successfully, the preset parameters include the starting logical block address, the data writing address range and the data model. During the data writing process, the hard disk platter to be tested is powered off and powered on again. After powering on again, data is read from the hard disk platter to be tested and data verification is performed according to the preset parameters corresponding to the stored write command. Since the constructed write command includes the preset starting logical block address, the data writing address range and the data model, and the above parameters are stored accordingly after the data is successfully written, after powering off and powering on again, the corresponding data can be read and verified according to the stored parameters. According to the verification results, it is possible to count which data is written successfully and which data is written unsuccessfully at the moment of power off, thereby accurately verifying the data integrity of the hard disk platter in the event of an unexpected power off, and at the same time, according to the verification results, the reliability of the hard disk platter in data reconstruction can also be verified. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 A flowchart of a method for verifying data during power failure according to an embodiment of the present invention;

[0023] Figure 2 A schematic diagram of the structure of a device for verifying data during power failure according to an embodiment of the present invention;

[0024] Figure 3 A schematic diagram of the structure of an electronic device according to an embodiment of the present invention;

[0025] Figure 4 A detailed flowchart of a method for verifying data during power failure according to an embodiment of the present invention;

[0026] Figure 5 A schematic diagram of the structure of a data format of a preset sector according to an embodiment of the present invention;

[0027] Figure 6 It is a schematic diagram of the structure of the flag field in the preset sector data format according to an embodiment of the present invention. DETAILED DESCRIPTION

[0028] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.

[0029] Please refer to Figure 1 , an embodiment of the present invention provides a method for verifying data when power is off, comprising the steps of:

[0030] The hard disk platter to be tested is powered on independently, and when an instruction indicating that the hard disk platter to be tested is successfully identified is received, a write command including preset parameters is constructed, wherein the preset parameters include a starting logical block address, a data write address range, and a data model;

[0031] Writing data to the hard disk platter to be tested according to the write command, and storing preset parameters corresponding to the successfully written write command;

[0032] During the data writing process, the hard disk platter to be tested is powered off separately;

[0033] The hard disk platter to be tested is powered on again independently, and when an instruction indicating that the hard disk platter to be tested is successfully identified is received, data is read from the hard disk platter to be tested and data verification is performed according to preset parameters corresponding to the stored write command.

[0034] From the above description, it can be seen that the beneficial effect of the present invention is that: by constructing a write command containing preset parameters, and writing data to the hard disk platter to be tested according to the constructed write command, and storing the preset parameters corresponding to the write command that is written successfully, the preset parameters include the starting logical block address, the data write address range and the data model. During the data writing process, the hard disk platter to be tested is powered off and powered on again. After powering on again, data is read from the hard disk platter to be tested and data verification is performed according to the preset parameters corresponding to the stored write command. Since the constructed write command contains the preset starting logical block address, the data write address range and the data model, and after the data is successfully written, the above parameters will be stored accordingly. Therefore, after powering off and powering on again, the corresponding data can be read and verified according to the stored parameters. According to the verification results, it is possible to count which data is written successfully and which data is written unsuccessfully at the moment of power off, so that the data integrity of the hard disk platter in the event of an unexpected power off can be accurately verified, and the reliability of the hard disk platter for data reconstruction can also be verified according to the verification results.

[0035] Furthermore, the write command is an IO write command, and data writing is performed by concurrently executing the IO write command.

[0036] From the above description, it can be seen that by constructing IO commands to implement data writing and executing IO write commands in a concurrent manner, the hard disk to be tested can run at full speed and reach the highest load, thus achieving stress testing and improving the reliability, authenticity and accuracy of the test.

[0037] Furthermore, a preset time interval is set between the independent power-off and independent power-on of the hard disk platter to be tested, and the preset time interval can be dynamically set.

[0038] From the above description, it can be seen that by dynamically setting the preset interval time between the independent power failure and independent power-on of the hard disk platter to be tested, power failures in various situations can be simulated, which is highly flexible and the test is more accurate and reliable.

[0039] Furthermore, during the data writing process, powering off the hard disk platter to be tested separately includes:

[0040] During the data writing process, determining whether the hard disk platter to be tested supports power-off protection, and if so, powering off the hard disk platter to be tested separately;

[0041] If not, before powering off the hard disk to be tested, execute:

[0042] The cache of the hard disk platter to be tested is flushed, and after the flushing, the preset parameters corresponding to the write commands that are successfully written are not stored.

[0043] From the above description, it can be seen that by judging whether different hard disk platters support power-off protection and performing corresponding tests on different types of hard disk platters, for hard disk platters that do not support power-off protection, before executing a separate power-off, the cache of the hard disk platters to be tested is first flushed, and after flushing, the preset parameters corresponding to the successfully written write commands are not stored. That is, for hard disk platters that do not support power-off protection, the data verification is the data successfully written before flushing. This ensures the accuracy of testing of different types of hard disk platters and improves the compatibility of testing. Regardless of whether power-off protection is supported, correct testing can be performed.

[0044] Further, writing data to the hard disk platter to be tested according to the write command includes:

[0045] Writing data to the sector corresponding to the hard disk platter to be tested according to the write command and the preset sector data format;

[0046] The step of reading data from the hard disk platter to be tested and performing data verification according to the preset parameters corresponding to the stored write command comprises:

[0047] According to the preset parameters corresponding to the stored write command and the preset sector data format, data is read from the sector corresponding to the hard disk platter to be tested and data verification is performed.

[0048] From the above description, it can be seen that writing, reading and verifying data on the hard disk platter in sectors according to the preset sector data format can achieve fast writing and reading, and during verification, the abnormal area can be located more quickly, thereby improving test efficiency.

[0049] Furthermore, different sectors have different preset data formats.

[0050] From the above description, it can be seen that the preset data format set for each sector is different, which ensures the diversity of data written in different sectors, so that the data of each sector is different, which is closer to the actual situation and can further improve the accuracy of the test.

[0051] Further, the step of reading data from the hard disk platter to be tested and performing data verification according to the preset parameters corresponding to the stored write command includes:

[0052] Data is read from the area corresponding to the hard disk platter to be tested according to the starting logical block address and the data write address range corresponding to the stored write command, and the read data is compared with the data model to determine whether the written data is consistent with the read data.

[0053] From the above description, it can be seen that since the starting logical block address, data writing address range and data model are preset, and the above preset parameters corresponding to the successfully written write commands are stored, when reading data after power failure and power on again, the corresponding data can be read according to the above preset parameters, and the read data can be compared with the data model, so that the data integrity in the event of an unexpected power failure can be verified based on the comparison results.

[0054] Please refer to Figure 2 Another embodiment of the present invention provides a device for verifying data when power is off, comprising:

[0055] Power-on module, used to independently power on the hard disk platter to be tested;

[0056] A command construction module, configured to construct a write command including preset parameters after the power-on module independently powers on the hard disk platter to be tested, upon receiving an instruction indicating that the hard disk platter to be tested is successfully identified, wherein the preset parameters include a starting logical block address, a data write address range, and a data model;

[0057] A data writing module, used for writing data to the hard disk platter to be tested according to the write command, and storing preset parameters corresponding to the successfully written write command;

[0058] A power-off module, used to power off the hard disk platter to be tested separately during the data writing process;

[0059] A data reading module is used to read data from the hard disk platter to be tested and perform data verification according to preset parameters corresponding to the stored write command when receiving an instruction indicating that the hard disk platter to be tested is successfully identified after the power-on module independently powers on the hard disk platter to be tested.

[0060] Another embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps in the above method for verifying data during power failure are implemented.

[0061] Please refer to Figure 3 Another embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements each step of the method for verifying data during power failure when executing the computer program.

[0062] The method, device, computer-readable storage medium and electronic device for verifying data during power failure of the present invention can be applied to any type of solid-state hard disk test, such as SATA (Serial Advanced Technology Attachment, serial port hard disk) disk, PCIE (peripheral component interconnect express) disk, etc., which are described below through specific implementation methods:

[0063] Embodiment 1

[0064] Please refer to Figure 1 , a method for verifying data when power is off, comprising the steps of:

[0065] S1. The hard disk to be tested is powered on independently. When receiving an instruction indicating that the hard disk to be tested is successfully identified, a write command including preset parameters is constructed. The preset parameters include a starting logical block address, a data write address range, and a data model.

[0066] Before testing, test networking is performed first. Specifically, the hard disk to be tested is connected to the test host as a data disk, and the power supply of the hard disk to be tested is independently controlled: if it is a SATA hard disk, because it supports hot plugging, a PC power supply can be added to independently control the power supply of the disk; if it is a PCIE disk, an adapter card can be used to control the power supply of the disk;

[0067] After the test network is established, the test host can run on different systems. In this embodiment, the test host is a Linux system. When the system is running normally, the hard disk to be tested is powered on by the power-on module. After the host to be tested can successfully scan the disk, that is, the test host can correctly identify the hard disk to be tested, the write command is created;

[0068] Among them, you can use the IO tool to create a write command, and specify the starting logical block address LBA of the write command, the data write address range range, and the specific value of the data model PATTERN in the parameters. The creation of the write command can be implemented by an open source IO tool or by calling the operating system API;

[0069] S2, writing data to the hard disk platter to be tested according to the write command, and storing the preset parameters corresponding to the successfully written write command;

[0070] By constructing IO write commands to form IO load to realize data writing, in order to make the hard disk run at full speed and reach the highest load, which is closer to the scene of real hard disk data reading and writing, data writing can be performed by concurrently executing the IO write commands;

[0071] During the data writing process, each piece of successful writing information is recorded in a preset file in a log format. Specifically, the preset parameters of the write command corresponding to the successful data writing can be stored;

[0072] S3, during the data writing process, powering off the hard disk platter to be tested separately;

[0073] During the IO load process, that is, during the process of writing data to the hard disk to be tested through the created IO write command, that is, during the process of the IO thread operating the hard disk to be tested, the power module is triggered to power off the hard disk to be tested independently;

[0074] S4, independently powering on the hard disk platter to be tested again, and when receiving an instruction indicating that the hard disk platter to be tested is successfully identified, reading data from the hard disk platter to be tested and performing data verification according to preset parameters corresponding to the stored write command;

[0075] Wherein, the hard disk to be tested is powered off separately and then powered on again separately after a preset time interval, and the preset time interval can be dynamically set;

[0076] When the hard disk platter to be tested is reconnected to the test host and the test host scans the disk successfully, a read command is used to read data from the area corresponding to the hard disk platter to be tested according to the starting logical block address and data write address range corresponding to the write command stored in the preset file of step S2, and the read data is compared with the data model to determine whether the written data is consistent with the read data. If they are inconsistent, it indicates that there is an abnormality when the area corresponding to the inconsistent data loses power.

[0077] Embodiment 2

[0078] Since some solid state drives support power-off protection while others do not, when testing them, it is necessary to be able to perform correct data verification on solid state drives in both cases. This embodiment further defines this:

[0079] like Figure 4 As shown:

[0080] Step 1, turn on the power of the hard disk to be tested, scan the disk through fdisk, send the identify command to confirm that the hard disk to be tested is successfully identified, and then send the format command to initialize the hard disk data to be tested;

[0081] Step 2, using the IO tool to construct an IO write command, wherein the data format of the written data is defined by preset parameters, including the start LBA, the data write range, and the data model PATTERN;

[0082] Step 3, using the program voice feature to develop an IO driver module, so that the IO write command of step 2 can realize the concurrency function, and at the same time realize the format of the IO command sent to file A, that is, for the IO write command that successfully writes the data, its preset parameters are stored in file A;

[0083] Step 4, determine whether the hard disk to be tested supports power-off protection, if it does, execute step 41, otherwise, execute step 42;

[0084] Step 41, for the hard disk to be tested that supports power-off protection, power off the disk separately during its IO load process, and then execute step 5;

[0085] Step 42, for the hard disk to be tested that does not support power-off protection, during its IO load, use the flush command to flush its cache, and the IO write command after the flush is not recorded in the file A that has sent the IO write command. At this time, fdisk is used to scan the disk to determine that the disk has been removed by the host. If it is a SATA disk, the hot-swap switch of the test host is turned on. If it is a PCIE disk, the PCIE remove operation is performed under Linux using the PCIE feature, and then step 5 is executed;

[0086] Step 5: Power on the hard disk to be tested independently at intervals of 1-10 seconds. If it is a PCIE disk, use the PCIE feature to perform a PCIE rescan operation under Linux, scan the disk through fdisk, and send the identify command to confirm that the disk to be tested is successfully identified;

[0087] Step 6, use the IO tool to load the file A saved last time, parse the data format corresponding to the IO write command corresponding to the data successfully written in step 3 saved in file A, and read the corresponding data on the hard disk platter to be tested with the read command according to the data format to verify whether the data is complete when the power is off. If there is no abnormality, mark it as passed, otherwise, mark it as failed;

[0088] The above steps 1 to 6 can be automated using a scripting language.

[0089] Embodiment 3

[0090] This embodiment further defines the data format of the preset sectors, and then writing data to the hard disk platter to be tested according to the write command includes:

[0091] Writing data to the sector corresponding to the hard disk platter to be tested according to the write command and the preset sector data format;

[0092] The step of reading data from the hard disk platter to be tested and performing data verification according to the preset parameters corresponding to the stored write command comprises:

[0093] Reading data from the sector corresponding to the hard disk platter to be tested and performing data verification according to the preset parameters corresponding to the stored write command and the preset sector data format;

[0094] Among them, different preset data formats of different sectors can be set to be different, so that the data of each sector can be different, which is convenient for data verification testing;

[0095] Specifically, Figure 5 As shown, it is a preset data format of a sector, a sector has a total of 512 bytes, including a starting lba field, a pattern field, a checksum field, a flag field and a data field, wherein the flag field is used to mark the data for data verification when power is off, and includes a 4-byte IO count field and a 4-byte reserved field;

[0096] When writing data, fill the preset parameter data model in the pattern field, then use random numbers to construct an 8-byte data model PATTERN based on the preset parameter data model, get the checksum through CRC check, fill it into the checksum field, then fill the data field with the constructed data model pattern, and fill the flag in the flag field to indicate that the data is used for power-off verification, and finally define the first 8 bytes of each data buffer as the LBA address of the write target address through calculation, that is, the first 8 bytes constitute the starting LBA field, which is used to write the preset parameter starting LBA;

[0097] When reading data, the corresponding sector is determined according to the preset parameter start LBA and data writing range range, and then the data is read, and then the data is compared in sequence according to the preset sector data format and preset parameters to determine whether the written data is consistent with the read data;

[0098] Since the preset parameter data model PATTERN is 8 bytes, when performing comparison, the comparison result can accurately determine which sector or data block has an abnormality. The specific length and form of the data model can be flexibly set to suit various test scenarios.

[0099] Embodiment 4

[0100] Please refer to Figure 2 , a device for verifying data when power is off, comprising:

[0101] Power-on module, used to independently power on the hard disk platter to be tested;

[0102] A command construction module, configured to construct a write command including preset parameters after the power-on module independently powers on the hard disk platter to be tested, upon receiving an instruction indicating that the hard disk platter to be tested is successfully identified, wherein the preset parameters include a starting logical block address, a data write address range, and a data model;

[0103] A data writing module, used for writing data to the hard disk platter to be tested according to the write command, and storing preset parameters corresponding to the successfully written write command;

[0104] A power-off module, used to power off the hard disk platter to be tested separately during the data writing process;

[0105] A data reading module is used to read data from the hard disk platter to be tested and perform data verification according to preset parameters corresponding to the stored write command when receiving an instruction indicating that the hard disk platter to be tested is successfully identified after the power-on module independently powers on the hard disk platter to be tested.

[0106] Embodiment 5

[0107] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for verifying data during power failure described in any one of Embodiments 1 to 3.

[0108] Embodiment 6

[0109] like Figure 3 As shown, an electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, each step of the method for verifying data during power failure described in any one of Embodiments 1 to 3 is implemented.

[0110] In summary, the method, device, computer-readable storage medium and electronic device for verifying data during power failure provided by the present invention construct a write command containing preset parameters, and concurrently write data to the sectors corresponding to the hard disk platter to be tested according to the constructed write command and the data format of the preset sector, the data format of different sectors is different, and the preset parameters corresponding to the successfully written write command are stored, the preset parameters include the starting logical block address, the data write address range and the data model, during the data writing process, the hard disk platter to be tested is powered off and powered on again, after powering on again, data is read from the hard disk platter to be tested according to the preset parameters corresponding to the stored write command and the data is verified. Verification, since the constructed write command contains the preset starting logical block address, data write address range and data model, and the above parameters will be stored accordingly after the data is written successfully, so after power failure and power on again, the corresponding data can be read and verified according to the stored parameters and the preset sector data format. According to the verification results, it can be counted which data is written successfully and which data is written unsuccessfully at the moment of power failure, so as to accurately verify the data integrity of the hard disk platter in the event of an unexpected power failure. At the same time, according to the verification results, the reliability of the hard disk platter for data reconstruction can also be verified, and the entire test process can be fully automated with high test efficiency.

[0111] In the above embodiments provided in the present application, it should be understood that the disclosed methods, devices, computer-readable storage media, and electronic devices can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple components or modules can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or components or modules, which can be electrical, mechanical or other forms.

[0112] The components described as separate components may or may not be physically separated, and the components shown as components may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the components may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0113] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each component may exist physically separately, or two or more modules may be integrated into one module. The above integrated modules may be implemented in the form of hardware or in the form of software functional modules.

[0114] If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0115] It should be noted that, for the convenience of description, the aforementioned method embodiments are all described as a series of action combinations, but those skilled in the art should be aware that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0116] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0117] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for verifying data when power is off, It is characterized in that Includes steps: The hard disk platter to be tested is powered on independently, and when an instruction indicating that the hard disk platter to be tested is successfully identified is received, a write command including preset parameters is constructed, wherein the preset parameters include a starting logical block address, a data write address range, and a data model; Writing data to the hard disk platter to be tested according to the write command, and storing preset parameters corresponding to the successfully written write command; During the data writing process, the hard disk platter to be tested is powered off separately; Re-powering on the hard disk platter to be tested independently, and when receiving an instruction indicating that the hard disk platter to be tested is successfully identified, reading data from the hard disk platter to be tested and performing data verification according to preset parameters corresponding to the stored write command; During the data writing process, powering off the hard disk platter to be tested separately includes: During the data writing process, determining whether the hard disk platter to be tested supports power-off protection, and if so, powering off the hard disk platter to be tested separately; If not, before powering off the hard disk to be tested, execute: The cache of the hard disk to be tested is flushed, and after the flush, the preset parameters corresponding to the successfully written write command are not stored; The step of reading data from the hard disk platter to be tested and performing data verification according to the preset parameters corresponding to the stored write command comprises: Data is read from the area corresponding to the hard disk platter to be tested according to the starting logical block address and the data write address range corresponding to the stored write command, and the read data is compared with the data model to determine whether the written data is consistent with the read data.

2. A method for verifying data when power is off according to claim 1, It is characterized in that The write command is an IO write command, and data is written by concurrently executing the IO write command.

3. The method for verifying data when power is off according to claim 1, It is characterized in that A preset time interval is set between the independent power-off and independent power-on of the hard disk platter to be tested, and the preset time interval can be dynamically set.

4. A method for verifying data during power failure according to any one of claims 1 to 3, It is characterized in that Writing data to the hard disk platter to be tested according to the write command includes: Writing data to the sector corresponding to the hard disk platter to be tested according to the write command and the preset sector data format; The step of reading data from the hard disk platter to be tested and performing data verification according to the preset parameters corresponding to the stored write command comprises: According to the preset parameters corresponding to the stored write command and the preset sector data format, data is read from the sector corresponding to the hard disk platter to be tested and data verification is performed.

5. A method for verifying data when power is off according to claim 4, It is characterized in that Different sectors have different preset data formats.

6. A device for verifying data when power is off, It is characterized in that include: Power-on module, used to independently power on the hard disk platter to be tested; A command construction module, configured to construct a write command including preset parameters after the power-on module independently powers on the hard disk platter to be tested, upon receiving an instruction indicating that the hard disk platter to be tested is successfully identified, wherein the preset parameters include a starting logical block address, a data write address range, and a data model; A data writing module, used for writing data to the hard disk platter to be tested according to the write command, and storing preset parameters corresponding to the successfully written write command; A power-off module, used to power off the hard disk platter to be tested separately during the data writing process; A data reading module, configured to read data from the hard disk platter to be tested and perform data verification according to preset parameters corresponding to the stored write command when receiving an instruction indicating that the hard disk platter to be tested is successfully identified after the power-on module independently powers on the hard disk platter to be tested; During the data writing process, powering off the hard disk platter to be tested separately includes: During the data writing process, determining whether the hard disk platter to be tested supports power-off protection, and if so, powering off the hard disk platter to be tested separately; If not, before powering off the hard disk to be tested, execute: The cache of the hard disk to be tested is flushed, and after the flush, the preset parameters corresponding to the successfully written write command are not stored; The step of reading data from the hard disk platter to be tested and performing data verification according to the preset parameters corresponding to the stored write command comprises: Data is read from the area corresponding to the hard disk platter to be tested according to the starting logical block address and the data write address range corresponding to the stored write command, and the read data is compared with the data model to determine whether the written data is consistent with the read data.

7. A computer-readable storage medium having a computer program stored thereon, Features: When the computer program is executed by a processor, the steps of the method for verifying data during power failure as described in any one of claims 1 to 5 are implemented.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the processor implements the steps of the method for verifying data during power failure as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Test system and method for data storage

    CN102842342A

  • Method and system for testing abnormal power failure of solid-state hard disk

    CN104658611A

  • Safe solid-state hard disk data writing method

    CN107797899A

  • Test method and system for power-down protection function of storage server mainboard

    CN107807870A

  • Server powering-off test method and device based on Phytium platform

    CN108614754A