Data protection method for solid state hard disk and solid state hard disk
By performing error correction processing and data backup when the solid-state drive is abnormally powered off, data instability and loss problems are solved, data stability and consistent recovery are achieved, and cost is reduced.
Patent Information
- Application Number
- CN202111045531.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-07
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2041-09-07
AI Technical Summary
When the SSD is abnormally powered off, the data is not fully saved, resulting in incomplete L2P table, resulting in data loss or inconsistency. The existing external capacitor methods increase costs and cannot completely solve the data instability problem.
When the solid-state drive is powered off abnormally, the pending data is obtained for error correction processing, the error correction data is saved to the cache protection area as a backup, and the invalid data is discarded after the L2P table is established, and the valid data is copied to the flash memory to form stable recovery data.
Ensure data stability and consistency, improve data recovery efficiency, reduce costs, avoid the increase of external capacitors, and ensure the accuracy of the L2P table.
Smart Images

Figure CN113849426B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage, and in particular to a data protection method for a solid-state hard disk and a solid-state hard disk. Background Art
[0002] Solid-state drives (SSDs) are storage hard drives made with solid-state electronic memory chips. They primarily consist of a controller, storage media, and cache units. Currently, the most popular SSDs use flash memory as the storage medium to store data, such as non-volatile NAND flash.
[0003] When using an SSD to store data, a Flash Translation Layer (FTL) mapping table, also called an L2P (Logical to Physical Table), is required. This table records the mapping between the host's logical space addresses and the Flash memory's physical addresses. The L2P is a sequential table indexed by LBAs and containing PBAs.
[0004] For SSDs using NAND flash as their primary storage medium, if a power outage occurs during data writing, the data is not completely saved. At this time, the L2P table is not completely refreshed. When the SSD is powered on again, the L2P table read does not contain the mapping relationship of the latest stored data, resulting in user data loss or inconsistent data read multiple times. This makes programming errors very likely to occur, leading to instability of the page data currently being written by the SSD.
[0005] Currently, external capacitors are commonly used to power SSDs, ensuring sufficient power to write data to the SSD in the event of an abnormal power outage. However, this method increases costs due to the additional external capacitors, and data stability cannot be guaranteed after the capacitors are depleted. Even if the external capacitors have problems, data instability cannot be resolved. Summary of the Invention
[0006] In view of the above problems, an object of the present invention is to provide a data protection method for a solid state drive and a solid state drive to solve the problems existing in the prior art.
[0007] According to one aspect of the present invention, a data protection method for a solid-state drive is provided, wherein the solid-state drive includes a flash memory, and the data protection method includes:
[0008] Acquire the data to be processed that the flash memory is receiving when the solid state drive loses power abnormally;
[0009] performing error correction processing on erroneous data in the data to be processed to obtain error-corrected data;
[0010] Copying the error correction data to a cache protection zone preset in the flash memory as backup data;
[0011] Establishing an L2P table according to valid data in the backup data; and
[0012] Copying the valid data in the backup data to the flash memory as recovery data after the solid state drive is powered on,
[0013] The valid data is all data before the first data that cannot be corrected that appears in the error correction process.
[0014] Optionally, the erroneous data includes data whose reading results are not completely consistent over multiple times.
[0015] Optionally, the error correction process is performed on each physical page in the data to be processed, and the first data that cannot be corrected is data in the first physical page that cannot be corrected.
[0016] Optionally, error correction processing is performed on the err data using an err handle error handling checking tool.
[0017] Optionally, the cache protection area is an SLC cache area inside the flash memory.
[0018] Optionally, the step of establishing an L2P table according to valid data in the backup data includes:
[0019] Reading the backup data from the cache protection area;
[0020] discarding the invalid data in the backup data, wherein the backup data consists of the valid data and the invalid data;
[0021] An L2P table of data to be processed after the SSD is powered on is established using the valid data in the backup data.
[0022] Optionally, the data to be processed is located in a first physical block, the restored data is located in a second physical block, and the first physical block and the second physical block are different physical blocks in the flash memory.
[0023] According to another aspect of the present invention, there is provided a solid state drive, comprising:
[0024] A controller, connected to the host, for exchanging data with the host;
[0025] A flash memory, connected to the controller, storing the write data of the host,
[0026] In which, the flash memory includes a cache protection zone. When the solid-state hard disk is abnormally powered off, the error data in the data to be processed being received by the flash memory is corrected after error correction processing and is copied to the cache protection zone for storage, and the valid data in the backup data in the cache protection zone is used to establish an L2P table. After the L2P table is established, the valid data in the cache protection zone is copied back to the flash memory as recovery data after the solid-state hard disk is powered on. The valid data is all data before the first uncorrectable data appearing in the error correction data.
[0027] Optionally, the cache protection area is an SLC cache area inside the flash memory.
[0028] Optionally, the data to be processed and the recovery data are located in different physical blocks of the flash memory.
[0029] The data protection method and solid-state hard drive provided by the present application first obtain the pending data that the flash memory was receiving when the solid-state hard drive was abnormally powered off after it is powered on and restarted, then perform error correction on the erroneous data therein and save it in the cache protection zone as backup data to maintain the stability of the error-corrected data; at the same time, the backup data is read from the cache protection zone, invalid data is discarded, and an L2P table is established based on the valid data after the invalid data is discarded, thereby ensuring the stability of the data; finally, the valid data in the cache protection zone is copied to the flash memory to form the recovery data after power is turned on. Through a series of operations, the unstable data in the pending data is discarded, and the L2P table is established only with stable data, ensuring the accuracy of the mapping relationship of the L2P table, and the data is saved in the cache protection zone, thus forming stable data protection and maintaining the consistency and stability of the data. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The above and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:
[0031] Figure 1 A flow chart of a method for protecting data from a solid-state drive according to an embodiment of the present invention is shown;
[0032] Figure 2 A schematic diagram showing storage of data of a solid state drive in a flash memory according to an embodiment of the present invention is shown;
[0033] Figure 3 A schematic diagram showing data distribution in a first physical block of a flash memory after a solid-state drive is powered on again according to an embodiment of the present invention is shown;
[0034] Figure 4 A schematic diagram of the operation flow of a data protection method for a solid state drive according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0035] The present invention will be described in more detail below with reference to the accompanying drawings. In each of the accompanying drawings, identical elements are represented by similar reference numerals. For the sake of clarity, the various parts in the accompanying drawings are not drawn to scale. In addition, some well-known parts may not be shown.
[0036] The present invention is described below based on the following embodiments, but the present invention is not limited to these embodiments. In the detailed description of the present invention below, certain specific details are described in detail. Those skilled in the art can fully understand the present invention without these details. To avoid obscuring the essence of the present invention, well-known methods, processes, procedures, components, and circuits are not described in detail.
[0037] Unless the context clearly requires otherwise, throughout the specification and claims, words like "include," "comprising," and similar expressions should be construed as inclusive, rather than exclusive or exhaustive; that is, as meaning "including but not limited to." In describing the present invention, it should be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. Furthermore, in describing the present invention, unless otherwise specified, "plurality" means two or more.
[0038] The specific implementation of the present invention is further described in detail below with reference to the accompanying drawings and examples.
[0039] Figure 1 A flow chart of a method for protecting data of a solid state drive according to an embodiment of the present invention is shown.
[0040] A solid-state drive (SSD) is a storage hard drive made with solid-state electronic memory chips. The SSD of this embodiment includes a controller and a storage medium. It uses flash memory as the storage medium to store data, and the controller executes the SSD data protection method. The data protection method of this embodiment includes the following steps:
[0041] In step S101, the data to be processed that is being received by the flash memory when the solid state drive is abnormally powered off is obtained.
[0042] When the solid-state drive loses power abnormally, the write data being received by the flash memory will be disconnected. After the solid-state drive is powered on again, the data written during the power outage must be restored first. The data being received during the power outage is called pending data. This data is stored in the first physical block of the flash memory. For example, the pending data is located in the head blk (head block).
[0043] In step S102, error correction processing is performed on erroneous data in the data to be processed to obtain error-corrected data.
[0044] When an abnormal power outage occurs, the data being written in the flash memory is not completely saved. Then, due to the incomplete mapping relationship, the results of multiple data reads are inconsistent (for example, the first read is correct, and the second read is incorrect). This will result in inconsistent data pointed to by the pointer, which will cause the system to judge the table error and an abnormal situation. Therefore, when the solid-state drive loses power, the data is unstable. In this embodiment, the unstable data or erroneous data in the head blk (the block currently being written by the SSD) must first be error-handled and the data must be restored as much as possible. Then, the erroneous data includes data whose results of multiple reads are not completely consistent. The reading here is not a read operation performed by the user. In this embodiment, multiple read judgments are required to determine the erroneous data to avoid the omission of erroneous data due to only reading once, thereby ensuring the accuracy of the data results. In addition, in the multiple read process, as long as the reading result of one time is inconsistent with the data received before the power outage, the data is considered to be erroneous data. For example, if the data on a page is correct when read for the first time, but displays an incorrect result when read for the second time, and is still correct when read for the third or even Nth time, such data will also be considered as incorrect data. This ensures that the data pointed to by the pointer in the retained data is correct each time, making the recovered data more accurate.
[0045] In this step, error correction is performed on each physical page of the data being processed. Errors in the data being processed are corrected using error handling tools such as errhandle, generating corrected data. Using pre-stored error correction tools within the SSD, error correction is performed on the data, enabling timely and rapid repair of erroneous data, improving repair speed and capabilities.
[0046] In step S103, the error correction data is copied to a cache protection area preset in the flash memory as backup data.
[0047] In this step, since the data to be processed in the first physical block is still unstable even after error correction, the corrected data is copied to a cache protection area preset in the flash memory and saved as backup data. The cache protection area can be an SLC (Single Level Cell) cache area inside the flash memory, which has good storage stability, thereby ensuring the stability of the backup data. In addition, when the backup data is read from the SLC and copied to the flash memory again, since they are all data operations inside the flash memory, data transmission time can be saved and data can be quickly restored. Using this SLC cache area to cache backup data can utilize the working performance of the SLC, accelerate read and write performance, and improve data processing speed. In addition, this area does not occupy the user's available capacity, and can save backup time while quickly and completely saving backup data, thereby improving the data recovery processing process.
[0048] Figure 2 A schematic diagram showing storage of data of a solid state drive in a flash memory according to an embodiment of the present invention is shown.
[0049] like Figure 2 As shown, the flash memory includes an SLC cache area 220 and other data storage areas, and the other data storage areas include a first physical block 201 and a second physical block 202. In step S103, the SSD controller makes a first copy of the error correction data in the first physical block (Head blk) 201 and stores the copy in the SLC cache area 220 as backup data.
[0050] In step S104, an L2P table is created according to the valid data in the backup data.
[0051] In this step, the L2P table is established based on the stable backup data stored in the SLC cache area 220. Valid data is all data preceding the first uncorrectable data encountered during error correction. Correspondingly, invalid data is all data following the first uncorrectable data encountered during error correction. In other words, error correction data consists of invalid data and valid data. Error correction is performed on a physical page-by-physical page basis, so the first uncorrectable data is the data on the first uncorrectable physical page.
[0052] The steps for establishing an L2P table based on valid data in the backup data include: reading the backup data from the cache protection area; discarding invalid data in the backup data; and establishing an L2P table for the data to be processed after the SSD is powered on, using the valid data in the backup data. The data read from the cache protection area is error-corrected after power-on and stored in the more stable SLC cache area, so its data accuracy is high, and the L2P table restored from this area is also highly accurate. Furthermore, the first uncorrectable data in the backup data and all subsequent data are discarded, and the L2P table is established only for the remaining data. This ensures that the data used to establish the L2P table is correct, eliminating the need to re-verify the accuracy of the restored L2P table, thereby improving data recovery efficiency and performance.
[0053] Figure 3 A schematic diagram of data distribution in a first physical block of a flash memory after a solid-state drive is powered on again according to an embodiment of the present invention is shown.
[0054] Typically, a flash memory device has several dies (a die is the basic unit for receiving and executing flash memory commands), each die has several planes, each plane has several blocks, and each block includes multiple pages (physical pages). The first physical block mentioned in this embodiment refers to the same block on all planes of all dies.
[0055] like Figure 3 As shown, each plane of each die of the head blk includes page0-page85, and each page of each pln (0 or 1) of each die stores a piece of data. Error correction processing is performed on the basis of this page. V (valued) indicates that the data therein is correct data, E (empty) indicates that no data has been written into this space, and F (fail) indicates that an error has occurred in the data. When the SSD loses power, for example, only the data before the position of die1-pln1-page82 is written. Then, after the SSD is restarted, the data to be processed is the data in the box, which has been error-corrected. The circled F data (die1-pln0-page81 data) indicates the first data in the error-corrected data that has not been error-corrected. Then, this data and all subsequent data are considered invalid data and unstable data. The data before this data will be considered valid data.
[0056] All error-corrected data within the box is copied to the SLC cache area 220 as backup data. When the L2P table needs to be restored, the backup data is read from the SLC cache area 220, invalid data in the backup data is discarded, and only valid data is used to establish the L2P table. This ensures data consistency in the L2P table and avoids misreading. Due to the storage capacity of the solid-state drive itself, this embodiment copies the data of three rows of physical pages (page80-page82) on all dies simultaneously as the data to be processed to the SLC cache area 220. Other solid-state drives may copy and store data of different numbers of physical pages as a whole.
[0057] In step S105 , valid data in the backup data is copied to the flash memory as recovery data after the solid state drive is powered on.
[0058] After the L2P table is established, when the disk needs to be recognized, the valid data in the backup data in the SLC cache area 220 is read out and re-copied to a new physical block of the flash memory.
[0059] See again Figure 2 , copying the valid data in the backup data in the SLC cache area 220 to the second physical block 202 as the recovery data after power-on, thereby restoring data stability. Then, the data to be processed is located in the first physical block 201, and the recovery data is located in the second physical block 202. The first physical block 201 and the second physical block 202 are different physical blocks in the flash memory. The second physical block 202 is, for example, a blank physical block within the flash memory. Therefore, there is no need to erase the first physical block 201 before performing any operations. Instead, the second physical block 202 can be directly written to. When the data is restored to the second physical block 202, the data in the first physical block is automatically invalidated, reducing the workload of the processor within the SSD and improving the speed and efficiency of data recovery. Furthermore, if an unexpected event occurs again during the data recovery process, the backup physical block of the first physical block 201 is still in the SLC cache area 220, and the data can be restored again.
[0060] Through the data protection method for the solid-state hard disk of the embodiment of the present invention, the data to be processed is first error-corrected, and then the error-corrected data is copied from the unstable data storage area to the stable SLC cache area 220. Thereafter, the backup data is read from the SLC cache area 220, and the L2P table is established after the invalid data is removed to ensure data consistency. Finally, the stable valid data is copied to the new physical block, while ensuring the data stability and consistency after the solid-state hard disk is powered on.
[0061] Accordingly, the solid-state hard disk disclosed in the embodiment of the present invention includes: a controller and a flash memory. The controller is connected to the host and is used to exchange data with the host; the flash memory is connected to the controller and stores the write data of the host. The flash memory includes a cache protection zone. When the solid-state hard disk is abnormally powered off, the error data in the data to be processed that the flash memory is receiving is corrected after error correction processing and is copied to the cache protection zone for storage, and the valid data in the backup data in the cache protection zone is used to establish an L2P table. After the L2P table is established, the valid data in the cache protection zone is copied back to the flash memory as the recovery data after the solid-state hard disk is powered on. The valid data is all data before the first uncorrectable data that appears in the error correction data. The cache protection zone is the SLC cache area inside the flash memory. The data to be processed and the recovery data are located in different physical blocks of the flash memory.
[0062] Figure 4 A schematic diagram of the operation flow of a data protection method for a solid state drive according to an embodiment of the present invention is shown.
[0063] Figure 4 and Figure 1 The disclosed embodiments are basically the same. Figure 4 As shown, the operation process includes steps S401-S407. Specifically:
[0064] Combine Figures 1-4 In step S401, after the SSD is abnormally powered off and restarted, the data of the head blk must be read first as the data to be processed.
[0065] In step S402, it is determined whether the data in the head blk is stable, that is, whether there are any errors in the data. If there are any errors, step S403 is executed to perform error correction; otherwise, step S404 is directly executed.
[0066] In step S403, error correction processing is performed on the erroneous data to generate error-corrected data.
[0067] In step S404, the error-corrected data or the error-free data to be processed is saved, that is, the data in the headblk is copied to the SLC for storage to maintain data stability.
[0068] In step S405, the L2P table is prepared for restoration and is restored based on the data stored in the SLC.
[0069] In step S406, the L2P table after the first occurrence of uncorrectable error data in the SLC is discarded. In this step, invalid data in the SLC is discarded and only valid data is used to establish the L2P table to maintain data consistency.
[0070] In step S407, the stable head block's valid data is copied back to the new block. In this step, the valid data stored in the SLC is copied back to the block as recovery data after the SSD is powered on. This maintains both data consistency and stability.
[0071] In summary, the data protection method and solid-state hard drive provided in the embodiments of the present application, after the solid-state hard drive is powered on and restarted, first obtains the pending data that the flash memory was receiving when the power was abnormally cut off, then performs error correction on the erroneous data therein and stores it in the cache protection zone to maintain the stability of the error-corrected data; at the same time, reads data from the cache protection zone, discards invalid data, and establishes an L2P table based on the data after discarding the invalid data, which can ensure the stability of the data. Finally, the valid data in the cache protection zone is copied to the flash memory to form the recovery data after power is turned on. Through a series of operations, the unstable data in the pending data is discarded, and the L2P table is established only with stable data, ensuring that the mapping relationship of the L2P table is accurate, and the data is stored in the cache protection zone, forming stable data protection, while maintaining the consistency and stability of the data.
[0072] While embodiments of the present invention have been described above, these embodiments do not exhaustively describe all details and do not limit the invention to the specific embodiments described. Obviously, many modifications and variations are possible based on the above description. These embodiments are selected and described in detail in this specification in order to better explain the principles and practical applications of the present invention, thereby enabling those skilled in the art to better utilize the present invention and its modifications. The present invention is limited only by the claims and their full scope and equivalents.
Claims
1. A data protection method for a solid-state drive, wherein the solid-state drive includes a flash memory, the data protection method comprising: Acquire data to be processed that is being received by the flash memory when the solid state drive loses power abnormally, where the data to be processed is located in a first physical block of the flash memory; performing error correction processing on erroneous data in the data to be processed to obtain error-corrected data; Copying the error correction data to a cache protection zone preset in the flash memory as backup data; Reading the backup data from the cache protection area, discarding invalid data in the backup data, and establishing an L2P table of data to be processed after the SSD is powered on based only on valid data in the backup data; as well as Copying the valid data in the backup data to the flash memory as recovery data after the solid state drive is powered on, The valid data is all data before the first data that cannot be corrected that appears in the error correction process.
2. The data protection method according to claim 1, wherein: The erroneous data includes data whose results of multiple readings are not completely consistent.
3. The data protection method according to claim 1, wherein: The error correction process is performed on the data to be processed based on each physical page, and the first data that cannot be corrected is the data in the first physical page that cannot be corrected.
4. The data protection method according to claim 3, wherein: The err handle error handling checking tool is used to perform error correction processing on the err data.
5. The data protection method according to claim 1, wherein: The cache protection area is an SLC cache area inside the flash memory. The data protection method according to claim 1 , wherein: The recovery data is located in a second physical block, and the first physical block and the second physical block are different physical blocks in the flash memory.
7. A solid-state hard drive, comprising: A controller, connected to the host, for exchanging data with the host; A flash memory, connected to the controller, storing the write data of the host, In which, the flash memory includes a cache protection zone and a first physical block. When the solid-state hard disk loses power abnormally, the error data in the data to be processed being received by the flash memory is copied to the cache protection zone for storage after error correction processing, and the invalid data in the backup data in the cache protection zone is discarded. Only the valid data in the backup data is used to establish an L2P table of the data to be processed after the SSD is powered on. After the L2P table is established, the valid data in the cache protection zone is copied back to the flash memory as recovery data after the solid-state hard disk is powered on. The valid data is all data before the first data that cannot be corrected in the error correction data. The data to be processed is located in the first physical block of the flash memory.
8. The solid-state drive according to claim 7, wherein: The cache protection area is an SLC cache area inside the flash memory.
9. The solid-state drive according to claim 7, wherein: The data to be processed and the recovery data are located in different physical blocks of the flash memory.
Citation Information
Patent Citations
Solid state disc and power failure protection method and system thereof
CN102591748A
Method for improving reliability of flash memory and solid-state hard disk
CN108595286A
Data storage system and storage method of memory and storage system
CN112015339A
Power-on reconstruction method and device and solid state disk
CN113296694A