Data processing method and apparatus for a hard disk
By dynamically restoring data in the solid-state drive according to the business status and using intermediate verification data or error correction interval verification data to recover erroneous data, the write amplification and latency problems in the existing technology are solved, and efficient and reliable data recovery is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INSPUR SUZHOU INTELLIGENT TECH CO LTD
- Filing Date
- 2026-05-26
- Publication Date
- 2026-06-26
AI Technical Summary
Existing technologies, when handling read errors in open stripes of solid-state drives (SSDs), require filling with dummy data to simulate a fully written state, resulting in increased write amplification, shortened SSD lifespan, and longer data reconstruction latency, which cannot meet the real-time requirements of high-performance SSDs.
By receiving read error information, incomplete stripes and erroneous data units are identified, and data is recovered in different ways depending on the hard drive's business status: under low load conditions, intermediate check data and valid data units are used for recovery, while under high load conditions, error correction interval check data and valid data units are used for recovery, avoiding dummy data filling and redundant calculations.
It effectively reduces write amplification, extends hard drive lifespan, shortens data reconstruction latency, and improves data recovery efficiency and reliability.
Smart Images

Figure CN122285372A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a data processing method and apparatus for a hard disk. Background Technology
[0002] In the field of solid state drives (SSDs) data storage, in order to cope with the bit error rate of NAND flash memory and ensure data reliability, modern high-performance SSDs generally adopt a striped storage architecture similar to RAID5, which distributes user data and parity information across different physical units. Among them, open stripes that have not yet been filled with data are widely used in practical applications.
[0003] However, when dealing with read errors in open stripes, the relevant technologies need to first fill the free areas of the stripe with dummy data to simulate a full state, then recalculate a new check value, and finally recover the erroneous data based on the new check value and other valid data. This process not only generates a large number of unnecessary write operations, leading to increased write amplification and shortened SSD lifespan, but also causes a long delay in data reconstruction due to redundant filling and check calculation steps. Summary of the Invention
[0004] This application provides a data processing method and apparatus for a hard disk to at least solve the problems in the aforementioned related technologies.
[0005] In a first aspect, this application provides a data processing method for a hard disk, including:
[0006] Receive read error information from the hard drive, including the incomplete stripe identifier and the location of the erroneous data unit where the read error occurred;
[0007] The target incomplete strip is identified based on the incomplete strip identifier, and the erroneous data unit in the target incomplete strip is identified based on the location of the erroneous data unit;
[0008] Obtain the current service status of the hard drive; where the service status is determined based on the service time difference between adjacent services;
[0009] If the business status is the first business status, then based on the intermediate verification data generated during the data writing process of the target incomplete stripe and the valid data units in the target incomplete stripe, the erroneous data units are recovered using preset calculations;
[0010] If the business status is the second business status, then the error data unit is restored by using a preset operation based on the verification data of the error correction interval where the error data unit is located and the valid data units within the error correction interval; wherein, the error correction interval is pre-divided based on the number of programming erases of the physical block corresponding to the target incomplete stripe; the load value corresponding to the first business status is less than the load value corresponding to the second business status.
[0011] Secondly, this application also provides a data processing apparatus for a hard disk, comprising:
[0012] The receiving module is used to receive read error information from the hard disk, including the incomplete stripe identifier and the location of the erroneous data unit where the read error occurred.
[0013] The determination module is used to determine the target incomplete strip based on the incomplete strip identifier, and to determine the erroneous data unit in the target incomplete strip based on the erroneous data unit location;
[0014] The acquisition module is used to acquire the current service status of the hard drive; the service status is determined based on the service time difference between adjacent services.
[0015] The data recovery module is used to recover erroneous data units by using preset calculations based on the intermediate verification data generated during the data writing process of the target incomplete stripe and the valid data units in the target incomplete stripe if the business status is the first business status.
[0016] The data recovery module is also used to recover data from the erroneous data unit by using a preset operation based on the verification data of the error correction interval where the erroneous data unit is located and the valid data units within the error correction interval if the business state is the second business state. The error correction interval is pre-divided based on the number of programming erases of the physical block corresponding to the target incomplete stripe. The load value corresponding to the first business state is less than the load value corresponding to the second business state.
[0017] Thirdly, this application also provides an electronic device, including:
[0018] Memory, used to store computer programs;
[0019] A processor is used to implement the steps of the method as described in the first aspect when executing a computer program.
[0020] Fourthly, this application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the method as described in the first aspect.
[0021] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method described in the first aspect.
[0022] This application provides a hard disk data processing method and apparatus. In the event of a read error, the method receives read error information from the hard disk, determines the target incomplete stripe based on the incomplete stripe identifier, and identifies the erroneous data unit within the target incomplete stripe based on the location of the erroneous data unit. Then, by acquiring the hard disk's operational status, different methods are used to recover the erroneous data depending on the operational status. In the first operational status, recovery is performed using intermediate check data and valid data units from the writing process of the target incomplete stripe. In the second operational status, recovery is performed using check data and valid data units from the error correction interval. Therefore, there is no need to fill in dummy data to simulate a full write state, avoiding a large number of unnecessary write operations, effectively reducing write amplification, and extending the hard disk's lifespan. Furthermore, it reduces redundant filling and check calculation steps, shortens data reconstruction latency, and improves the efficiency and reliability of hard disk data recovery. Attached Figure Description
[0023] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 An application scenario diagram corresponding to a hard disk data processing method provided in one embodiment of this application;
[0025] Figure 2 A schematic flowchart illustrating a data processing method for a hard disk provided in an embodiment of this application;
[0026] Figure 3 A schematic flowchart illustrating a data processing method for a hard disk provided in another embodiment of this application;
[0027] Figure 4 This is a schematic diagram of the structure of a hard disk data processing device provided in an embodiment of this application;
[0028] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0029] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0030] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0031] In the field of solid-state drives (SSDs) data storage, to address the bit error rate of NAND flash memory and ensure data reliability, modern high-performance SSDs generally adopt a striped storage architecture similar to RAID 5. This striped architecture divides user data into multiple data blocks, or data units, and synchronously generates corresponding checksum information. The data units and checksum information are then distributed and stored across different physical storage units. Through this striped architecture, when a data error occurs in a single physical storage unit, the SSD can utilize the data and checksum information from other normal storage units to recover the erroneous data through an XOR operation, thereby ensuring data reliability.
[0032] In real-world applications, due to the randomness and intermittency of user data writes, SSDs often contain numerous open stripes that are not yet fully written to. This means that some data units within a stripe store valid user data, while the remaining units are idle. To handle read errors in open stripes and adapt to RAID 5-like parity recovery logic (which requires calculations based on complete stripe data), related technologies first fill the idle areas of the stripe with "dummy data" (meaningless placeholder data) to simulate a full stripe. Then, based on the filled, complete stripe data, a new parity value is recalculated. Finally, the erroneous data is recovered using the new parity value and data from other valid data units.
[0033] However, in related technologies, the dummy data filling and checksum recalculation processes generate a large number of unnecessary write operations, significantly increasing the "write amplification" phenomenon in SSDs. Since NAND flash memory has a physical limit to the number of programmable and erased cycles, excessive invalid writes directly shorten the lifespan of the SSD. Furthermore, redundant dummy data filling and checksum recalculation steps consume significant hardware resources and time, resulting in long data reconstruction delays and failing to meet the real-time requirements of high-performance SSDs for read error recovery. Moreover, when multiple data units in an open stripe fail simultaneously, the interference from dummy data filling and the distortion of the checksum cause the error correction logic to fail, resulting in severely insufficient fault tolerance and an inability to guarantee data reliability under complex error scenarios.
[0034] Figure 1 This application provides an example of an application scenario diagram corresponding to a hard disk data processing method provided in one embodiment of this application; for example... Figure 1As shown, the application scenario includes a solid-state storage device 10 and a data processing controller 11. The solid-state storage device 10 and the data processing controller 11 establish a communication connection through a storage bus (such as SATA (Serial Advanced Technology Attachment), SAS (Serial Attached SCSI), NVMe (Non-Volatile Memory Express) bus). The data processing controller 11 has pre-stored hard disk striping rules, error correction interval configuration and preset operation logic to support fast response to read errors and data recovery.
[0035] Optionally, when the solid-state storage device 10 performs a data read operation, if a data read abnormality is detected, the solid-state storage device 10 will immediately generate read error information and send it to the data processing controller 11 via the storage bus. The read error information includes an incomplete stripe identifier indicating where the read error occurred and the location of the erroneous data unit.
[0036] Optionally, after receiving a read error message, the error location module of the data processing controller 11 searches the stripe management list of the hard disk based on the incomplete stripe identifier to quickly determine the corresponding target incomplete stripe, and determines the erroneous data unit in the storage structure of the target incomplete stripe according to the location of the erroneous data unit. Subsequently, the data processing controller 11 calls the service status monitoring module to obtain the current service status of the solid-state storage device 10. This service status is determined by real-time statistics of the service time difference between two adjacent data read and write operations.
[0037] Optionally, if the current business state is determined to be the first business state, the data processing controller 11 retrieves the intermediate verification data generated and cached in real time during the data writing process of the target incomplete stripe, extracts each valid data unit in the target incomplete stripe except for the erroneous data unit, and reverse-derives the original data of the erroneous data unit through preset operations (such as XOR operation, RS (Reed-Solomon) decoding operation) to achieve fast and accurate recovery, and at this time the recovery operation has minimal impact on the current business.
[0038] Optionally, if the current business state is determined to be the second business state, and the load value corresponding to the first business state is less than the load value corresponding to the second business state, the data processing controller 11 first determines the error correction interval where the erroneous data unit is located. This error correction interval is pre-divided based on the number of programmed erases of the physical block corresponding to the target incomplete stripe. Then, it retrieves the overall verification data of the error correction interval and combines it with other valid data units within the error correction interval. Through preset calculations, it completes the data recovery of the erroneous data unit. This strategy can reduce resource consumption during the recovery process and avoid business lag or delay under high load.
[0039] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0040] Figure 2 This is a schematic flowchart illustrating a hard disk data processing method according to an embodiment of this application, as shown below. Figure 2 As shown, the execution subject of this embodiment is a hard disk data processing device. This device can be implemented by a computer program, or by a medium storing the relevant computer program, such as a USB flash drive and / or optical disc; alternatively, it can be implemented by a physical device integrating or installing the relevant computer program, such as a chip or electronic device. The electronic device may be a computer or a server, etc. The hard disk data processing method provided in this embodiment includes the following steps:
[0041] Optionally, in this embodiment, the data processing device for the hard disk may be located in the SSD controller.
[0042] S201. Receive read error information from the hard disk, wherein the read error information includes the incomplete stripe identifier and the location of the erroneous data unit where the read error occurred.
[0043] Optionally, when the SSD performs a data read operation, if a read error is detected in a data cell in a certain band, such as a data mismatch caused by bit flipping, the read error reporting mechanism is triggered to generate read error information and send it to the data processing device.
[0044] The read error information includes the identifier of the incomplete stripe where the read error occurred and the location of the erroneous data unit. The incomplete stripe identifier can be a unique identifier such as the stripe number or physical address range, used to quickly locate the target stripe where the error occurred. The location of the erroneous data unit can be the index or offset address of the data unit within the stripe, used to precisely locate the specific data unit in the target stripe where the read error occurred.
[0045] It should be noted that by obtaining basic information on error handling, a basis can be provided for subsequent target identification and data recovery. Only by clearly identifying the stripe where the error occurred and the specific data unit can targeted recovery operations be performed, avoiding ineffective global scanning and improving the efficiency of error handling.
[0046] S202, determine the target incomplete strip based on the incomplete strip identifier, and determine the erroneous data unit in the target incomplete strip based on the erroneous data unit location.
[0047] Optionally, upon receiving a read error message, the system first queries a preset stripe management table based on the incomplete stripe identifier to determine the stripe corresponding to that identifier as the target incomplete stripe. The preset stripe management table stores information such as the status (full / incomplete), physical storage location, and number of data units for all stripes in the SSD. This table allows for quick filtering of the target stripe and retrieval of its parameters.
[0048] Subsequently, based on the location of the erroneous data unit and combined with the structural parameters of the incomplete target stripe (such as the size and arrangement order of the data units), the erroneous data unit in the incomplete target stripe where the read error occurred is located. For example, if the target stripe contains 8 data units (indices 0-7), and the erroneous data unit location is identified as "index 3", then the data unit corresponding to index 3 is directly determined to be the erroneous data unit.
[0049] S203. Obtain the current service status of the hard disk; wherein, the service status is determined based on the service time difference between adjacent services.
[0050] Optionally, the execution time of each business operation (including read and write operations) can be recorded in real time through the SSD controller, and the time interval between two adjacent business operations, i.e., the business time difference, can be calculated.
[0051] Optionally, when the time difference between services exceeds a preset threshold, the current service state is determined to be the first service state, i.e., the low-load state. At this time, the hardware resources of the hard disk (such as controller computing power and IO (Input / Output) bandwidth) are relatively abundant, the sensitivity to recovery delay is low, but the control requirements for write operations are high.
[0052] Optionally, when the business time difference is less than or equal to a preset threshold, the current business state is determined to be the second business state, i.e., the high load state. At this time, the hard disk hardware resources are under pressure and are highly sensitive to recovery delay, so recovery efficiency must be prioritized.
[0053] For example, the preset threshold can be set to 10ms. If the time interval between two adjacent services is 15ms, it is the first service state; if the time interval is 5ms, it is the second service state.
[0054] S204. If the business status is the first business status, then based on the intermediate verification data generated during the data writing process of the target incomplete stripe and the valid data units in the target incomplete stripe, the erroneous data units are recovered using preset calculations.
[0055] Optionally, if the current business state is the first business state, i.e., low load, then the recovery method using intermediate verification data and valid data units is adopted. Optionally, based on the intermediate verification data generated during the data writing process of the target incomplete stripe, and other normal valid data units in the target incomplete stripe, data recovery of erroneous data units is performed through preset calculations.
[0056] It should be noted that during the data writing phase when the target strip is not full, intermediate verification data will be generated and stored in real time. That is, after each valid data unit is written, the verification value will be recalculated based on all the valid data units that have been written, and the verification value will be stored as intermediate verification data in a preset verification cache or a specified physical unit.
[0057] For example, a target stripe contains 4 data units (D0-D3) and 1 parity unit (P). When D0 is written, an intermediate parity P0 is generated (P0=D0); when D1 is written, an intermediate parity P1 is generated (P1=D0⊕D1); and when D2 is written, an intermediate parity P2 is generated (P2=D0⊕D1⊕D2). Here, ⊕ represents the XOR operation.
[0058] Optionally, when the erroneous data unit is D1, the stored intermediate check data P2 can be directly retrieved and combined with other normal valid data units (D0, D2) to recover D1 through an XOR operation: D1 = D0 ⊕ D2 ⊕ P2. The entire process does not require filling the idle data unit (D3) with dummy data, nor does it require recalculating the check value, thus avoiding invalid write operations.
[0059] Optionally, the intermediate verification data is the XOR check value of the valid data units written in the target incomplete stripe; the preset operation is XOR operation, and the data recovery result of the erroneous data unit is the XOR operation result of the XOR check value and each valid data unit in the target incomplete stripe.
[0060] S205. If the business status is the second business status, then based on the verification data of the error correction interval where the error data unit is located and the valid data units within the error correction interval, the error data unit is restored using a preset operation; wherein, the error correction interval is pre-divided based on the number of programming erases of the physical block corresponding to the target unfilled stripe; the load value corresponding to the first business status is less than the load value corresponding to the second business status.
[0061] Optionally, if the current business state is the second business state, i.e., high load, then the recovery method of error correction interval verification data and valid data units within the interval is adopted. Optionally, based on the verification data of the error correction interval where the error data unit is located, and other normal valid data units within the error correction interval, data recovery of the error data unit is performed through preset calculations.
[0062] Optionally, the error correction interval is pre-divided based on the number of program erase (PE) cycles of the physical block corresponding to the incomplete stripe of the target. Optionally, since the higher the PE cycle of NAND flash memory, the higher the bit error rate, the principle of dividing the error correction interval into smaller intervals is adopted. The smaller error correction interval can reduce the amount of data processing during a single recovery and improve recovery efficiency.
[0063] Optionally, for each physical block in the SSD, multiple independent error correction intervals are divided according to its PE count. Each error correction interval contains several data units and corresponding independent verification data (the verification data is generated and stored when data is written within the interval).
[0064] For example, if a physical block has a low number of PE cycles (e.g., <1000 times), it is divided into 2 error correction intervals, and each error correction interval contains 8 data units and 1 check unit; if the number of PE cycles is high (e.g., ≥5000 times), it is divided into 8 error correction intervals, and each interval contains 2 data units and 1 check unit.
[0065] Optionally, firstly, the PE count of the physical block to which the erroneous data unit belongs is determined, and then the error correction interval in which it is located is located; subsequently, the verification data corresponding to the error correction interval is called, and combined with other normal valid data units in the interval, the erroneous data is recovered through preset operations.
[0066] For example, an erroneous data unit belongs to the error correction interval of a physical block with a high PE count (containing two data units, D0 and D1, and a checksum P). If D0 is faulty, D0 is recovered using D1 and P (D0 = D1 ⊕ P). This process does not require processing data across intervals or filling in dummy data, and can quickly complete error recovery under high load scenarios, ensuring business continuity.
[0067] Optionally, the method provided in this embodiment can be applied to high-frequency read / write scenarios such as enterprise-level storage servers, cloud storage nodes, and industrial control storage systems. In such scenarios, the hard drive needs to continuously bear a large amount of data writing and reading operations. Affected by factors such as disk media wear, signal interference, and physical block aging, data read errors are prone to occur. In particular, incomplete stripes (stripes that have not completed the writing of complete data blocks) are more difficult to repair due to incomplete data distribution. It is necessary to dynamically select recovery strategies based on business load to avoid affecting normal business operations.
[0068] This application provides a hard disk data processing method. When a read error occurs on the hard disk, the method receives read error information sent by the hard disk, determines the target incomplete stripe based on the incomplete stripe identifier, and identifies the erroneous data unit within the target incomplete stripe based on the location of the erroneous data unit. Then, by acquiring the hard disk's service status, different methods are used to recover the erroneous data depending on the service status. In the first service status, recovery is performed using intermediate check data and valid data units from the writing process of the target incomplete stripe. In the second service status, recovery is performed using check data and valid data units from the error correction interval. Therefore, there is no need to fill in dummy data to simulate a full write state, avoiding a large number of unnecessary write operations, effectively reducing write amplification, and extending the hard disk's lifespan. Furthermore, it reduces redundant filling and check calculation steps, shortens data reconstruction latency, and improves the efficiency and reliability of hard disk data recovery.
[0069] As an optional implementation, based on any of the above embodiments, data recovery of the erroneous data unit is performed using a preset operation based on the verification data of the error correction interval where the erroneous data unit is located and the valid data units within the error correction interval, including the following steps:
[0070] First, determine the logical offset of the location of the erroneous data cell in the incomplete stripe of the target.
[0071] The logical offset refers to the address offset of the erroneous data unit relative to the starting position of the incomplete stripe. If the data unit is the smallest counting unit, the starting position of the stripe is offset 0, and the offset of each subsequent data unit increases by 1.
[0072] Secondly, the error correction interval is determined based on the logical offset and the rules for dividing the error correction interval.
[0073] Optionally, the specific error correction interval to which the erroneous data unit belongs can be calculated by combining the interval division criteria matched by the number of PEs of the physical block corresponding to the target unfilled strip (e.g., when the number of PEs is ≥5000, every 2 data units constitute an error correction interval). For example, when the logical offset is 0, it corresponds to the first error correction interval under the division rule of PEs ≥5000.
[0074] Finally, based on the valid data units within the error correction interval and the verification data of the error correction interval, the erroneous data units are recovered using an XOR operation.
[0075] This application provides a hard disk data processing method that, by determining the logical offset of the erroneous data unit and based on the error correction interval division rules, can accurately locate the error correction interval, providing an accurate basis for subsequent recovery. Furthermore, by utilizing XOR operations, recovery is performed based on the valid data units and check data within the error correction interval; the operation is simple and efficient, and can quickly yield correct data.
[0076] As an optional implementation, based on any of the above embodiments, the following steps are also included:
[0077] First, the effective data unit count of the hard drive is used to determine whether the data units in the target incomplete stripe, excluding erroneous data units, are valid data units.
[0078] The valid data unit count is a preset counting parameter of the hard disk controller, used to record in real time whether each data unit stores valid user data. For example, the count increases when data is written and decreases when data is deleted. A non-zero count indicates that valid data exists.
[0079] Secondly, if the valid data unit count of any data unit is a first preset value, the corresponding data unit is determined to be an invalid data unit.
[0080] The first preset value can be preset to 0 according to the hard disk storage architecture. That is, when the count is 0, it means that the data unit does not store valid data and may be in an idle state or a deleted state.
[0081] By following the steps in this embodiment, interference from invalid data units on the recovery operation can be eliminated in advance, and invalid data can be avoided from being included in the XOR operation process. This ensures that subsequent recovery operations are performed only based on real and valid data, thereby further improving the accuracy and reliability of data recovery.
[0082] This application provides a hard disk data processing method that uses the effective data unit count of the hard disk to determine the validity of data units other than erroneous data units in a target incomplete stripe. By setting a first preset value as the judgment standard, when the effective data unit count of a data unit reaches the value, it can be quickly determined to be an invalid data unit. The judgment process is clear and explicit, which can effectively improve the accuracy and efficiency of data validity judgment and provide a more accurate basis for subsequent processing of erroneous data units.
[0083] As an optional implementation, based on any of the above embodiments, the following steps are also included:
[0084] First, the number of target partitions is determined based on the number of programmed erases of the physical blocks corresponding to the unfilled stripes of the target.
[0085] The number of target partitions is the total number of error correction intervals. Optionally, the higher the physical block PE count, the more target partitions there are, and the smaller the size of a single error correction interval.
[0086] Specifically, if the number of programmable erase operations exceeds a first threshold, the number of target partitions is set to a second preset value. If the number of programmable erase operations exceeds the second threshold, the number of target partitions is set to a third preset value; wherein the second threshold is greater than the first threshold, and the third preset value is greater than the second preset value.
[0087] Finally, based on the number of target partitions, error correction intervals are divided for incomplete target stripes according to the order of data units.
[0088] Optionally, starting from the data unit at the beginning of the strip, consecutive data units are sequentially divided into an error correction interval until all data units are assigned to the corresponding error correction interval.
[0089] For example, taking a target strip containing 16 data units as an example, with a preset first threshold of 2000 times, a second threshold of 5000 times, a second preset value of 4, and a third preset value of 8. When the corresponding physical block PE count is 3000 times, the target partition number is set to 4, and the 16 data units are divided into 4 error correction intervals in sequence, with each interval containing 4 data units; when the PE count is 6000 times, the target partition number is set to 8, and the strip is divided into 8 error correction intervals, with each interval containing 2 data units.
[0090] It should be noted that the higher the PE (Problem-E) count of NAND flash memory, the higher the bit error rate. By setting more target partitions, i.e., smaller error correction interval sizes, the amount of data processing during a single error recovery can be reduced, improving error correction efficiency in high error rate scenarios. Specifically, for each physical block in the SSD, the number of target partitions is matched according to its PE count, thereby dividing it into multiple independent error correction intervals. Each interval contains several data units and corresponding independent check data, which is generated and stored when data is written within the interval.
[0091] This application provides a hard disk data processing method that dynamically determines the number of target partitions based on the number of programmable erase operations on the physical blocks corresponding to the target incomplete stripe, thus fully considering the wear and tear of the physical blocks. By setting a first threshold and a second threshold, when the number of programmable erase operations exceeds the corresponding threshold, the number of target partitions is set to different preset values, with a larger threshold resulting in more partitions. Finally, error correction intervals are divided according to the data unit order based on the number of target partitions, making the division of error correction intervals more closely match the actual state of the physical blocks. This allows for more accurate utilization of error correction interval information during data recovery, effectively improving the accuracy and reliability of data recovery.
[0092] As an optional implementation, based on any of the above embodiments, the following steps are also included:
[0093] First, when the business status is the first business status, verify whether each data unit in the target unfilled strip, excluding the erroneous data unit, has completed the physical write operation.
[0094] Optionally, the criterion for determining the completion of physical writing is that the NAND flash memory corresponding to the data unit has completed the programming operation and returned a write success confirmation signal, that is, the data has been stably stored in the flash physical medium, rather than being temporarily stored in the cache.
[0095] Alternatively, verification can be performed by querying the write status identifiers of each data unit recorded in the SSD controller, such as "write complete", "writing in progress", and "not written".
[0096] Secondly, if any data unit is detected to have not completed a physical write operation, the data recovery operation is paused.
[0097] Optionally, if any data unit is detected to have not completed the physical write operation, the data recovery operation is paused. This avoids including unstable and invalid data in the XOR operation, which could lead to errors in the recovery result. The data recovery process is then restarted after all relevant data units have completed the physical write operation.
[0098] Optionally, if it is detected that all data units have completed the physical write operation, the data recovery operation can be performed directly.
[0099] This application provides a hard disk data processing method. When the business state is the first business state, physical write operations are performed on each data unit in the target incomplete stripe except for the erroneous data unit. If a data unit is detected that the physical write operation has not been completed, the data recovery is paused. This can avoid performing recovery operations in the state of incomplete or unstable data, prevent errors in the recovery results due to data inconsistency, and ensure the accuracy and reliability of data recovery.
[0100] Figure 3 A schematic flowchart of a hard disk data processing method provided in another embodiment of this application is shown below. Figure 3 As shown, as an optional implementation, based on any of the above embodiments, the following steps are also included:
[0101] S301. When the business status is the second business status and there are multiple erroneous data units in the target not full strip, determine whether the multiple erroneous data units are located in different error correction intervals.
[0102] Optionally, the error correction interval to which each error data unit belongs can be determined based on the logical offset of each error data unit and the corresponding error correction interval division rules, and the interval identifiers can be compared to determine whether they belong to different intervals.
[0103] S302. If multiple erroneous data units are located in different error correction intervals, data recovery shall be performed on each erroneous data unit separately.
[0104] S303. If multiple erroneous data units are located in the same error correction interval, then stop the data recovery of erroneous data units within the error correction interval.
[0105] Optionally, differentiated processing is performed based on the judgment result. If multiple erroneous data units are located in different error correction intervals, data recovery is performed on each erroneous data unit according to the recovery process of a single erroneous data unit described above. That is, each erroneous data unit is recovered based on the verification data of its error correction interval and the valid data units within the interval.
[0106] Optionally, if multiple erroneous data units are located in the same error correction interval, data recovery for all erroneous data units within that error correction interval should be stopped. It should be noted that the verification data of a single error correction interval can only support the recovery of a small number (e.g., one) of erroneous data units within the interval. When multiple errors occur within the same interval, the fault tolerance capability of the XOR operation will exceed its limit, and forced recovery may easily lead to distorted results. Stopping recovery in this case can prevent erroneous data from overwriting valid data, ensuring the security of data storage.
[0107] For example, if there are two erroneous data units, D0 and D2, in the target unfilled strip, and the error correction interval of D0 is interval 1 and the error correction interval of D2 is interval 2, then D0 and D2 are recovered based on the verification data and valid data of interval 1 and interval 2, respectively; if D0 and D1 are both erroneous data units and belong to the same interval 1, then the data recovery operation of D0 and D1 in interval 1 is stopped.
[0108] This application provides a hard disk data processing method. When the business state is a second business state and the target data is not yet full but contains multiple erroneous data units, the method first determines whether they are in different error correction intervals. If they are in different error correction intervals, data recovery is performed separately, thereby making full use of the verification information of each error correction interval, efficiently repairing each erroneous data unit, and improving the data recovery success rate. If they are in the same error correction interval, data recovery is stopped, avoiding situations where multiple errors within the same error correction interval exceed its error correction capability, leading to ineffective recovery or even further data damage.
[0109] As an optional implementation, based on any of the above embodiments, the following steps are also included:
[0110] First, when the business status is the second business status and all error correction intervals of the target not being full are filled with valid data units, obtain the verification data corresponding to each error correction interval.
[0111] Optionally, the determination can be made by querying the count of valid data units corresponding to each error correction interval. When the count of valid data units is equal to the total number of data units in the error correction interval, it means that the interval is full.
[0112] Optionally, when the business status is the second business status and all error correction intervals of the target not being full are filled with valid data units, the verification data corresponding to each error correction interval is obtained, that is, the independent verification data generated and stored by each error correction interval during the data writing process.
[0113] Secondly, perform an XOR operation on each verification data to generate the final verification data for targets with incomplete stripes.
[0114] It should be noted that since each error correction interval has been filled with valid data, the strip is actually in a "nearly full" state. By integrating the verification data of each interval to generate the final verification data, it can meet the needs of subsequent overall strip error recovery.
[0115] Finally, the final verification data is written to the storage area of the preset verification unit.
[0116] The preset verification unit is a dedicated verification storage unit corresponding to the target stripe that is not full, similar to the verification block in the RAID5 architecture, used to store the final verification information at the stripe level.
[0117] It should be noted that after each error correction interval is filled, the final stripe verification data is generated by integrating the interval verification data. This not only retains the efficiency advantage of interval-based recovery in high-load scenarios, but also provides complete verification data support for the recovery of cross-interval errors that may occur in subsequent stripes.
[0118] This application provides a hard disk data processing method. When all error correction intervals of a target stripe are filled with valid data in a second business state, the method integrates the verification data of each error correction interval through an XOR operation to generate final verification data and writes it to the storage area, thus achieving centralized management of verification data. Unified storage of the final verification data improves the efficiency of data integrity verification. In subsequent error recovery, this data can be directly called to quickly complete the verification, reducing unnecessary write operations, effectively suppressing write amplification effects, and extending the lifespan of the SSD.
[0119] As an optional implementation, based on any of the above embodiments, it further includes:
[0120] First, after the data recovery of the erroneous data unit is completed, the recovered data is compared with the original data read from the erroneous data unit.
[0121] The original read data refers to the distorted data read from the error data unit when the read error is triggered, i.e., the error data that triggers the error reporting. The recovered data refers to the corrected data obtained through the recovery process. The purpose of the comparison is to verify the accuracy of the recovery results.
[0122] Secondly, if the comparison results between the recovered data and the original read data are inconsistent, update the error statistics information for the target not being a full stripe.
[0123] Optionally, if the recovered data does not match the original read data, it means that the data recovery is successful and the expected effect is achieved. Then, the error statistics are recorded. The error statistics can be maintained by the SSD controller and can include indicators such as the number of errors occurring in the physical blocks corresponding to the target incomplete stripe, the number of error recovery failures, and the error frequency per unit time.
[0124] Finally, if the error statistics exceed the preset error threshold, the physical block corresponding to the target's incomplete stripe is marked as a faulty block and a garbage collection operation is triggered.
[0125] The preset error threshold can be preset according to the hardware characteristics of NAND flash memory. For example, the preset error threshold can be "the number of error recovery failures per unit time is ≥5" or "the cumulative number of errors is ≥10".
[0126] Optionally, when the error statistics meet the preset error threshold, it indicates that the bit error rate of the corresponding physical block has exceeded the safe range. Continued use may lead to data loss. At this time, it is marked as a faulty block, and the SSD's garbage collection (GC) mechanism is triggered to migrate all valid data stored in the faulty block to a pre-reserved normal physical block. After the data migration is completed, the storage resources of the faulty block are released, and no new data is written to the faulty block in the future, thereby ensuring the overall data storage security.
[0127] This application provides a hard disk data processing method. After data recovery is completed, the recovered data is compared with the original read data. If the results are inconsistent, the recovery is successful, and error statistics are updated to identify data errors where the target stripe is not full. When the error statistics exceed a preset threshold, the corresponding physical block is marked as a faulty block, and garbage collection is triggered. This quickly isolates faulty areas and ensures the overall data storage quality of the hard disk. Garbage collection can release space from faulty blocks, optimize storage resource allocation, and improve hard disk performance and lifespan.
[0128] Figure 4 This is a schematic diagram of the structure of a hard disk data processing device provided in an embodiment of this application, as shown below. Figure 4As shown, the hard disk data processing device provided in this embodiment is located in an electronic device. The hard disk data processing device 40 provided in this embodiment includes: a receiving module 41, a determining module 42, an acquiring module 43, and a data recovery module 44.
[0129] Specifically, the receiving module 41 is used to receive read error information from the hard disk, wherein the read error information includes the incomplete stripe identifier and the location of the erroneous data unit where the read error occurred; the determining module 42 is used to determine the target incomplete stripe based on the incomplete stripe identifier, and to determine the erroneous data unit in the target incomplete stripe based on the location of the erroneous data unit; the acquiring module 43 is used to acquire the current business status of the hard disk; wherein the business status is determined based on the business time difference between adjacent businesses; the data recovery module 44 is used to perform data recovery on the erroneous data unit using a preset operation based on the intermediate verification data generated during the data writing process of the target incomplete stripe and the valid data units in the target incomplete stripe if the business status is the first business status; the data recovery module 44 is also used to perform data recovery on the erroneous data unit using a preset operation based on the verification data of the error correction interval where the erroneous data unit is located and the valid data units in the error correction interval if the business status is the second business status; wherein the error correction interval is pre-divided based on the number of programming erases of the physical block corresponding to the target incomplete stripe; the load value corresponding to the first business status is less than the load value corresponding to the second business status.
[0130] Optionally, when the data recovery module 44 performs data recovery on the erroneous data unit using preset operations based on the verification data of the error correction interval where the erroneous data unit is located and the valid data units within the error correction interval, it is specifically used to: determine the logical offset of the erroneous data unit position in the target incomplete stripe; determine the error correction interval based on the logical offset and the division rules of the error correction interval; and perform data recovery on the erroneous data unit using an XOR operation based on each valid data unit within the error correction interval and the verification data of the error correction interval.
[0131] Optionally, the intermediate verification data is the XOR check value of the valid data units written in the target incomplete stripe; the preset operation is XOR operation, and the data recovery result of the erroneous data unit is the XOR operation result of the XOR check value and each valid data unit in the target incomplete stripe.
[0132] Optionally, the hard disk data processing device provided in this embodiment further includes a valid data unit determination module.
[0133] Optionally, the valid data unit determination module is used to: determine whether a data unit other than an erroneous data unit in a target incomplete stripe is a valid data unit by using the valid data unit count of the hard disk; and determine that the corresponding data unit is an invalid data unit if the valid data unit count of any data unit is a first preset value.
[0134] Optionally, the hard disk data processing device provided in this embodiment further includes an error correction interval division module.
[0135] Optionally, the error correction interval division module is used to: determine the number of target partitions based on the number of programmed erases of the physical blocks corresponding to the incomplete target stripe; set the number of target partitions to a second preset value when the number of programmed erases exceeds a first threshold; set the number of target partitions to a third preset value when the number of programmed erases exceeds the second threshold; wherein the second threshold is greater than the first threshold and the third preset value is greater than the second preset value; and divide the incomplete target stripe into error correction intervals according to the order of data units based on the number of target partitions.
[0136] Optionally, the hard disk data processing device provided in this embodiment further includes a verification module.
[0137] Optionally, the verification module is used to: verify whether each data unit in the target unfilled strip, excluding the erroneous data unit, has completed the physical write operation when the business state is the first business state; and suspend the data recovery operation if any data unit is detected to have not completed the physical write operation.
[0138] Optionally, the hard disk data processing device provided in this embodiment further includes an error correction interval determination module.
[0139] Optionally, the error correction interval determination module is used to: determine whether multiple erroneous data units are located in different error correction intervals when the business state is the second business state and there are multiple erroneous data units in the target not full strip; if multiple erroneous data units are located in different error correction intervals, then perform data recovery on each erroneous data unit separately; if multiple erroneous data units are located in the same error correction interval, then stop data recovery on the erroneous data units within the error correction interval.
[0140] Optionally, the hard disk data processing device provided in this embodiment further includes a verification data storage module.
[0141] Optionally, the verification data storage module is used to: obtain the verification data corresponding to each error correction interval when the business state is the second business state and each error correction interval of the target not being full is filled with valid data units; perform an XOR operation on each verification data to generate the final verification data of the target not being full; and write the final verification data into the storage area of the preset verification unit.
[0142] Optionally, the hard disk data processing device provided in this embodiment further includes a fault block recycling module.
[0143] Optionally, the fault block recycling module is used to: compare the recovered data with the original read data of the fault data unit after the data recovery of the fault data unit is completed; update the error statistics information of the target incomplete stripe if the comparison results of the recovered data and the original read data are inconsistent; and mark the physical block corresponding to the target incomplete stripe as a fault block and trigger garbage collection operation if the error statistics information exceeds the preset error threshold.
[0144] It should be noted that the technical effects of the hard disk data processing device in this embodiment have been explained in the above embodiment of the hard disk data processing method, and therefore will not be repeated in this embodiment.
[0145] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, as shown below. Figure 5 As shown, the electronic device 50 provided in the embodiments of this application includes: a memory 51 and a processor 52.
[0146] The memory 51 stores a computer program, and the processor 52 is configured to run the computer program to perform the steps in any of the above embodiments of the hard disk data processing method.
[0147] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described embodiments of the hard disk data processing method.
[0148] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0149] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described embodiments of the hard disk data processing method.
[0150] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described hard disk data processing method embodiments.
[0151] Any of the components, modules, units, parts, methods, and operations described herein can be implemented using software, firmware, hardware (e.g., fixed logic circuitry), manual processing, or any combination thereof. Alternatively or additionally, any functionality described herein can be executed at least in part by one or more hardware logic components, such as, but not limited to, a central processing unit (CPU), a field-programmable gate array (FPGA), an application-specific integrated circuit (ASIC), an application-specific standard product (ASSP), a system-on-a-chip (SoC), a complex programmable logic device (CPLD), a microprocessor (MCU), etc. The terms "system," "computing device," or "apparatus" as used herein encompass various means, devices, and machines for processing data, including, for example, one or more programmable processors, computers, SoCs, or combinations thereof. The apparatus may also include code that creates an execution environment for the computer program in question, such as code constituting processor firmware, a protocol stack, a database management system, an operating system, a cross-platform runtime environment, a virtual machine, or one or more combinations thereof. The aforementioned computer program (also known as a program, software, software application, app, script, or code) can be written in any form of programming language, including compiled or interpreted languages, declarative or procedural languages, and can be deployed in any form, including as a standalone program or as a module, component, subroutine, object, or other unit suitable for a computing environment.
[0152] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0153] The solution provided in this application has been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only intended to help understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A data processing method for a hard disk, characterized in that, include: Receive read error information from the hard disk, wherein the read error information includes an incomplete stripe identifier and the location of the erroneous data unit where the read error occurred; The target incomplete stripe is determined based on the incomplete stripe identifier, and the erroneous data unit in the target incomplete stripe is determined based on the erroneous data unit position; Obtain the current service status of the hard disk; wherein the service status is determined based on the service time difference between adjacent services; If the business status is the first business status, then based on the intermediate verification data generated during the data writing process of the target incomplete stripe and the valid data units in the target incomplete stripe, the erroneous data units are recovered using a preset operation; If the service status is the second service status, then based on the verification data of the error correction interval where the error data unit is located and the valid data units within the error correction interval, the error data unit is recovered using the preset operation; wherein, the error correction interval is pre-divided based on the number of programming erases of the physical block corresponding to the target incomplete stripe; the load value corresponding to the first service status is less than the load value corresponding to the second service status.
2. The method according to claim 1, characterized in that, The step of recovering data from the erroneous data unit using the preset operation based on the verification data of the error correction interval where the erroneous data unit is located and the valid data units within the error correction interval includes: Determine the logical offset of the location of the erroneous data unit in the incomplete stripe of the target; The error correction interval is determined based on the logical offset and the division rules of the error correction interval; Based on each valid data unit within the error correction interval and the verification data of the error correction interval, the erroneous data unit is recovered using an XOR operation.
3. The method according to claim 1, characterized in that, The intermediate verification data is the XOR verification value of the valid data units already written in the incomplete stripe of the target; The preset operation is an XOR operation, and the data recovery result of the erroneous data unit is the XOR operation result of the XOR check value and each valid data unit in the target incomplete stripe.
4. The method according to claim 1, characterized in that, Also includes: Using the effective data unit count of the hard disk, determine whether the data units in the target incomplete stripe, excluding the erroneous data units, are valid data units; If the number of valid data units in any data unit is a first preset value, the corresponding data unit is determined to be an invalid data unit.
5. The method according to claim 1, characterized in that, Also includes: The number of target partitions is determined based on the number of programmed erases of the physical blocks corresponding to the unfilled stripes of the target. If the number of programmable erase attempts exceeds a first threshold, the number of target partitions is set to a second preset value; When the number of program erase attempts exceeds the second threshold, the number of target partitions is set to a third preset value; wherein the second threshold is greater than the first threshold, and the third preset value is greater than the second preset value; Based on the number of target partitions, the incomplete stripes of the target are divided into error correction intervals according to the order of data units.
6. The method according to claim 1, characterized in that, Also includes: When the business status is the first business status, verify whether each data unit in the target unfilled strip, except for the erroneous data unit, has completed the physical write operation; If any data unit is detected as not having completed a physical write operation, the data recovery operation is paused.
7. The method according to claim 1, characterized in that, Also includes: When the business state is the second business state and there are multiple erroneous data units in the target stripe, it is determined whether the multiple erroneous data units are located in different error correction intervals; If multiple erroneous data units are located in different error correction intervals, then data recovery is performed on each of the erroneous data units separately; If multiple erroneous data units are located in the same error correction interval, then data recovery for the erroneous data units within the error correction interval shall be stopped.
8. The method according to claim 1, characterized in that, Also includes: When the business state is the second business state and all error correction intervals of the target not being full are filled with valid data units, obtain the verification data corresponding to each error correction interval. Perform an XOR operation on each of the aforementioned verification data to generate the final verification data for the target that is not full of bands; The final verification data is written into the storage area of the preset verification unit.
9. The method according to any one of claims 1-8, characterized in that, Also includes: After the data recovery of the erroneous data unit is completed, the recovered data is compared with the original read data of the erroneous data unit; If the comparison results between the recovered data and the original read data are inconsistent, update the error statistics information of the target not having a full band; If the error statistics exceed a preset error threshold, the physical block corresponding to the target's incomplete stripe is marked as a faulty block and a garbage collection operation is triggered.
10. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the method as claimed in any one of claims 1-9.