Solid state hard disk and reading and writing method thereof
By introducing metadata into the data unit of the solid-state drive to determine the sector status, the data error problem of solid-state drive when writing sectors under the error mapping relationship is solved, and the FTL mapping table size is not increased and the read and write time is not extended. Data writing accuracy improves read and write performance.
Patent Information
- Application Number
- CN202011123714.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-20
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2040-10-20
AI Technical Summary
When an existing solid-state drive is dealing with an error mapping relationship, writing a sector directly will cause the host to read the value of other sectors incorrectly. Existing solutions such as changing the FTL mapping unit or rejecting the host command will increase resource usage or extend read. Write time.
Introduce metadata into the data unit of the solid state drive, including sector status information, judge sector status through metadata, return correct data or error information, avoid directly writing to the wrongly mapped data unit, and update the element when writing Data to maintain sector state.
Without increasing the size of the FTL map table and not rejecting host commands, ensure data write accuracy, reduce error processing time, improve read and write performance, and save resources.
Smart Images

Figure CN112230855B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to a solid state drive, and in particular to a reading and writing technology of a solid state drive. Background Art
[0002] Solid-State Disk (SSD), also known as Solid-State Drive (SSD), is a computer storage device that mainly uses flash memory (NAND) as non-volatile memory. The SSD is connected to the host (HOST) and executes the read and write instructions from the host. The Flash Translation Layer (FTL) of the SSD stores a mapping table, which stores the correspondence between the logical address (LDA) and the physical address (PDA) on the NAND. The data is read and written through this mapping table. The unit of data read and written on the host side is sector. The size of each sector is 512 bytes or 4KB, while the unit of data read and written on NAND is data unit (DU). DU is also the basic unit of the FTL mapping table. The size of a DU is 4KB (it can also be configured to other sizes, such as 8KB, etc.). When the sector uses 512 bytes, due to the different units of data read and written by the host and NAND, multiple sectors correspond to one DU. When the host wants to write a sector, it will use the value of a certain DU as the basic data, modify the value of one sector, and write the new and old data into the DU. When the DU has an error map (mapping relationship failure), if you write a sector directly and use it as a normal DU, the host will read the values of other sectors of this DU incorrectly. At this time, a method is needed to inform the host whether the data read is correct.
[0003] There are two existing solutions:
[0004] Solution 1: Change the basic mapping unit of the FTL mapping table to sector, that is, one basic mapping unit corresponds to one sector. The problem with this solution is that it will greatly increase the size of the FTL mapping table and occupy more resources. For example, when the size of each sector is 512 bytes, if the basic mapping unit of the FTL mapping table is changed to sector, the FTL mapping table will increase to 8 times the original size compared to the original basic mapping unit DU of 4KB.
[0005] 2. Reject the command from the host, and the host will resend the command after knowing it. The problem with this solution is that it will increase the reading and writing time and repeat unnecessary operations. Summary of the invention
[0006] The purpose of the present disclosure is to provide a solid-state hard disk and a reading and writing method thereof, which completes the operation of writing data of a sector size into a data unit marked with an error mapping without increasing the size of the FTL mapping table, rejecting the host command, and affecting the correctness judgment of the read data.
[0007] The present application discloses a method for reading a solid state hard disk, wherein each data unit stored in the solid state hard disk includes metadata and user data of at least two sectors, wherein the metadata includes a sector status set for indicating status information of each sector in the data unit, wherein the status information includes a valid status and an invalid status; the method includes:
[0008] When a read command to read part of the sectors in a data unit is received from the host, the solid-state drive returns actual data to the host for sectors in a valid state and returns information indicating a read error to the host for sectors in an invalid state based on the sector status set stored in the metadata of the data unit.
[0009] In a preferred example, the step of "the solid state hard disk returns actual data to the host for sectors in a valid state and returns information indicating a read error to the host for sectors in an invalid state according to the sector status set stored in the metadata of the data unit" further includes:
[0010] The flash memory conversion layer of the solid state drive converts the logical address of the sector to be read in the read command into a physical address in the solid state drive, and reads the corresponding data unit according to the physical address;
[0011] The flash translation layer determines whether the corresponding data unit is in a valid state;
[0012] If the corresponding data unit is in a valid state, further judging whether the to-be-read sector is in a valid state according to the sector state set in the data unit, returning data of the to-be-read sector to the host if the to-be-read sector is in a valid state, and returning information indicating a read error to the host if the to-be-read sector is in an invalid state;
[0013] If the corresponding data unit is in an invalid state, information indicating a read error is returned to the host.
[0014] In a preferred example, the sector status set is a bitmap, and each bit in the bitmap is used to indicate status information of a sector.
[0015] In a preferred example, the step of "determining whether the sector to be read is in a valid state according to the sector status set in the data unit, returning the data of the sector to be read to the host if the sector to be read is in a valid state, and returning information indicating a read error to the host if the sector to be read is in an invalid state" is implemented by the firmware in the solid-state drive.
[0016] The present application also discloses a method for writing to a solid-state hard disk, wherein each data unit stored in the solid-state hard disk includes metadata and user data of at least two sectors, wherein the metadata includes a sector status set for indicating status information of each sector in the data unit, wherein the status information includes a valid status and an invalid status; the method includes:
[0017] When receiving a command from the host to write data to a portion of sectors in a data unit, the solid state drive reads the data unit;
[0018] Replacing the user data of the corresponding sector in the read data unit with the data of the sector to be written to obtain the data unit to be written, and setting the sector to be written to a valid state in the sector state set of the data unit to be written, while keeping the original state of other sectors;
[0019] The data unit to be written is written into the storage medium of the solid state drive.
[0020] In a preferred embodiment, the solid state drive reads the data unit, further comprising:
[0021] The flash memory conversion layer of the solid state drive converts the logical address of the sector to be written in the write command into a physical address in the solid state drive, and reads the corresponding data unit according to the physical address.
[0022] In a preferred example, the sector status set is a bitmap, and each bit in the bitmap is used to indicate status information of a sector.
[0023] The present application also discloses a solid state hard disk, the solid state hard disk comprising a storage medium and a controller;
[0024] Each data unit stored in the storage medium includes metadata and user data of at least two sectors, the metadata includes a sector status set for indicating status information of each sector in the data unit, the status information includes a valid state and an invalid state;
[0025] The controller is used to execute the reading method described above and / or the writing method described above.
[0026] In a preferred example, the storage medium is a flash memory.
[0027] In a preferred example, the controller includes a hardware chip and firmware.
[0028] In the embodiments of the present disclosure, metadata is used to store information about the quality of sectors, thereby improving read and write performance, not only eliminating the need to increase the FTL mapping table, saving resources, but also reducing the number of host failures in processing read and write commands, thereby improving read and write performance. In addition, error handling is performed using software and hardware coordination, thereby reducing the time required for error handling and improving read and write performance.
[0029] A large number of technical features are recorded in the specification of the present disclosure, which are distributed in various technical solutions. If all possible combinations of technical features of the present disclosure (i.e., technical solutions) are to be listed, the specification will be too long. In order to avoid this problem, the various technical features disclosed in the above invention content, the various technical features disclosed in the various embodiments and examples below, and the various technical features disclosed in the accompanying drawings can be freely combined with each other to form various new technical solutions (these technical solutions should all be deemed to have been recorded in this specification), unless such a combination of technical features is technically infeasible. For example, in one example, feature A+B+C is disclosed, and in another example, feature A+B+D+E is disclosed, and features C and D are equivalent technical means that play the same role. Technically, only one can be used, and it is impossible to use them at the same time. Feature E can be combined with feature C technically. Then, the solution of A+B+C+D should not be deemed to have been recorded because it is technically infeasible, and the solution of A+B+C+E should be deemed to have been recorded. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 is a flowchart of a method for reading a solid state drive according to a first embodiment of the present disclosure;
[0031] Figure 2 It is a flowchart of a method for reading a solid state drive according to the second embodiment of the present disclosure. DETAILED DESCRIPTION
[0032] In the following description, many technical details are provided to help readers better understand the present disclosure. However, those skilled in the art can understand that the technical solution claimed in the present disclosure can be implemented even without these technical details and various changes and modifications based on the following embodiments.
[0033] Description of some concepts:
[0034] DU: Data unit, which refers to the smallest unit of FTL mapping relationship.
[0035] HOST: Host, such as a computer host.
[0036] NAND: Flash memory, also known as NAND Flash memory, is a non-volatile storage medium that can be used as a storage medium for solid-state drives.
[0037] FTL: Flash Translation Layer, which converts HOST logical address to NAND physical address.
[0038] META: Metadata refers to information that describes data attributes.
[0039] SECTOR: Sector, the smallest unit for the host to read and write data.
[0040] LDA: logical address (Logic DU Address).
[0041] PDA: Physical address (Physical DU Address).
[0042] In order to make the objectives, technical solutions and advantages of the present disclosure more clear, the embodiments of the present disclosure will be further described in detail below with reference to the accompanying drawings.
[0043] The first embodiment of the present disclosure relates to a method for reading a solid state drive, wherein each data unit stored in the solid state drive includes metadata and user data of at least two sectors, wherein the metadata includes a sector status set for indicating status information of each sector in the data unit, wherein the status information includes a valid state and an invalid state. When a read command for reading a part of sectors in a data unit is received from a host, the solid state drive returns actual data to the host for sectors in a valid state, and returns information indicating a read error to the host for sectors in an invalid state according to the sector status set stored in the metadata of the data unit.
[0044] In one embodiment, the sector status set is a bitmap, and each bit in the bitmap is used to indicate the status information of a sector. Each bit in the bitmap of a data unit corresponds one-to-one to each sector in the data unit. Each sector is indicated by a bit (for example, 0 represents a valid state, 1 represents an invalid state, of course, 1 can also represent a valid state, and 0 represents an invalid state, as long as it is agreed in advance), saving storage space. In other embodiments, the sector status set can also be other types of data structures. For example, the storage of the status information of each sector can be implemented in a more redundant manner (such as error correction code). The present disclosure does not limit the specific form of the sector status set, as long as it can store the status information of each sector.
[0045] In one embodiment, Figure 1As shown, the reading method of the solid state hard disk includes:
[0046] In step 101, the solid state drive obtains a read command from a host.
[0047] In step 102, the flash translation layer of the solid state drive converts the logical address (LDA) of the sector to be read in the read command into a physical address (PDA) in the solid state drive.
[0048] The mapping table in the SSD records the correspondence between LDA and PDA, which is mainly divided into two situations.
[0049] 1.LDA->Normal PDA, which is a physical address in a specific NAND storage medium.
[0050] 2. LDA->PDA_err, where PDA_err is a specific value representing an error mapping, for example, PDA_err can be represented by the 32-bit maximum value 0xFFFFFFFF.
[0051] In step 103, the flash translation layer determines whether the corresponding data unit is in a valid state (in one embodiment, it can determine whether a data unit is invalid based on the information in the FTL mapping table). If the corresponding data unit is in a valid state, it proceeds to step 104; if the corresponding data unit is in an invalid state (for example, the physical address is PDA_err), it proceeds to step 106, and the solid-state drive returns information indicating a read error to the host.
[0052] In step 104, the corresponding data unit is read according to the physical address.
[0053] In step 105, it is further determined whether the sector to be read is in a valid state (for example, whether the value of the bit corresponding to the sector to be read in the bitmap is 0 or 1) based on the sector status set in the data unit. If the sector to be read is in a valid state, step 107 is entered, and the solid-state hard disk returns the data of the sector to be read to the host. If the sector to be read is in an invalid state, step 106 is entered, and the solid-state hard disk returns information indicating a read error to the host.
[0054] Preferably, each of the above steps can be implemented by the hardware and firmware of the solid-state drive in coordination. Hardware refers to the chip of the solid-state drive controller, and firmware refers to the program that works on the solid-state drive and plays a control role. In one embodiment, step 105 can be implemented by hardware and firmware together, wherein the hardware first performs a preliminary check, and if the hardware finds a sector in an invalid state, the firmware will then check it carefully, so as to avoid performance degradation caused by the firmware checking each data unit. Optionally, each of the above steps can also be implemented entirely by hardware or entirely by firmware. In one embodiment, the hardware of the solid-state drive can be a logic circuit.
[0055] A second embodiment of the present disclosure relates to a method for writing a solid-state hard disk (which can be used in conjunction with the method for reading a solid-state hard disk of the first embodiment), wherein each data unit stored in the solid-state hard disk includes metadata and user data of at least two sectors, and the metadata includes a sector status set for indicating status information of each sector in the data unit, and the status information includes a valid state and an invalid state.
[0056] In one embodiment, the sector status set is a bitmap, and each bit in the bitmap is used to indicate the status information of a sector. Each sector is indicated by a bit (for example, 0 represents a valid state, and 1 represents an invalid state), which can save storage space. In other embodiments, the sector status set can also be other types of data structures, for example, the storage of the status information of each sector can be implemented in a more redundant manner (such as an error correction code). The present disclosure does not limit the specific form of the sector status set, as long as it can store the status information of each sector.
[0057] In one embodiment, Figure 2 As shown, the writing method of the solid state hard disk specifically includes the following steps:
[0058] In step 201, a write command is received from a host.
[0059] In step 202 , the solid state drive determines whether the entire data unit is written, and if so, proceeds to step 203 , otherwise, proceeds to step 204 .
[0060] In step 203, the solid state drive allocates a corresponding physical address (PDA) according to the logical address (LDA) of the data unit to be written, and writes the entire data unit to the physical address, wherein the bitmap in the metadata of the written data unit is all 0 (valid state).
[0061] In step 204, if the write command is to write data to a part of the sectors in a data unit, the flash translation layer (FTL) of the solid state drive converts the logical address of the sector to be written in the write command into a physical address in the solid state drive, and reads the corresponding data unit according to the physical address. The data unit includes both the sector to be written and other sectors, and also includes the metadata (including the bitmap) of the data unit.
[0062] In step 205, the user data of the corresponding sector in the read data unit is replaced with the data of the sector to be written to obtain the data unit to be written, and the sector to be written is set to a valid state in the bitmap of the data unit to be written, and other sectors remain in their original state.
[0063] In step 206, the data unit to be written is written into the storage medium of the solid state drive, wherein the written data unit includes a bitmap.
[0064] Specifically, there are three situations:
[0065] 1. If the original LDA corresponds to a PDA, in general, its bitmap is all 0, indicating that everything is valid. The data part is read-modify-write, and the bitmap part is still all 0.
[0066] 2. If the original LDA corresponds to a PDA, its bitmap is not all 0, indicating that part is valid. The data part is read-modified-written, and the bitmap part is also read-modified-written, and the whole is written to NAND.
[0067] 3. If the original LDA does not correspond to a certain PDA, but corresponds to PDA_err, then the bitmap is initialized to all 1s. Clear the bitmap position corresponding to the newly written sector to 0, indicating that the sector is valid. The unwritten sector is still 1, indicating that the sector is invalid. Figure 1 Start writing to NAND.
[0068] Preferably, the above steps can be implemented by the hardware and firmware of the solid state drive in coordination. Optionally, the above steps can also be implemented completely by the hardware of the solid state drive or completely by the firmware of the solid state drive.
[0069] The third embodiment of the present application relates to a solid state hard disk, which includes a storage medium and a controller. The storage medium is a flash memory. The controller includes a hardware chip and firmware.
[0070] Each data unit stored in the storage medium includes metadata and user data of at least two sectors, the metadata includes a sector status set for indicating status information of each sector in the data unit, and the status information includes a valid state and an invalid state.
[0071] The controller is used to execute the reading method described in the first embodiment and / or the writing method described in the second embodiment.
[0072] It should be noted that, in the disclosure, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or equipment. In the absence of more restrictions, the elements defined by the sentence "include one" do not exclude the existence of other identical elements in the process, method, article or equipment including the elements. In the present disclosure, if it is mentioned that a certain action is performed according to a certain element, it means that at least the action is performed according to the element, which includes two situations: performing the action only according to the element and performing the action according to the element and other elements. Multiple, multiple, multiple, etc. expressions include 2, 2 times, 2 kinds and more than 2, more than 2 times, more than 2 kinds.
[0073] This specification includes combinations of the various embodiments described herein. Individual references to an embodiment (e.g., "one embodiment" or "some embodiments" or "preferred embodiments") do not necessarily refer to the same embodiment; however, these embodiments are not mutually exclusive unless indicated as mutually exclusive or it is clear to a person skilled in the art that they are mutually exclusive. It should be noted that the word "or" is used in this specification in a non-exclusive sense unless the context clearly indicates or requires otherwise.
[0074] All documents mentioned in the present disclosure are considered to be included in the disclosure of the present disclosure as a whole, so that they can be used as the basis for modification when necessary. In addition, it should be understood that after reading the content of the present disclosure, those skilled in the art can make various changes or modifications to the present disclosure, and these equivalent forms also fall within the scope of protection claimed by the present disclosure.
Claims
1. A method for reading a solid state hard disk, characterized in that: Each data unit stored in the solid state drive includes metadata and user data of at least two sectors, the metadata includes a sector status set for indicating status information of each sector in the data unit, the status information includes a valid state and an invalid state; the method includes: When a read command for reading part of the sectors in a data unit is received from the host, if the data unit is in a valid state, whether the sector to be read is in a valid state is further determined based on the sector status set in the metadata of the data unit; if the sector to be read is in a valid state, the actual data of the sector to be read is returned to the host; if the sector to be read is in an invalid state, information indicating a read error is returned to the host; if the data unit is in an invalid state, information indicating a read error is returned to the host.
2. The method for reading a solid state hard disk according to claim 1, wherein: When a read command for reading a portion of sectors in a data unit is received from the host, the method further comprises: The flash memory conversion layer of the solid state drive converts the logical address of the sector to be read in the read command into a physical address in the solid state drive, and reads the corresponding data unit according to the physical address; The flash translation layer determines whether the corresponding data unit is in a valid state.
3. The method for reading a solid state hard disk according to claim 1, wherein: The sector status set is a bitmap, and each bit in the bitmap is used to indicate status information of a sector.
4. The method for reading a solid state hard disk according to claim 1, wherein: The step of "determining whether the sector to be read is in a valid state based on the sector status set in the metadata of the data unit, returning the actual data of the sector to be read to the host if the sector to be read is in a valid state, and returning information indicating a read error to the host if the sector to be read is in an invalid state" is implemented by the firmware in the solid-state hard disk.
5. A method for writing to a solid state hard disk, characterized in that: Each data unit stored in the solid state drive includes metadata and user data of at least two sectors, the metadata includes a sector status set for indicating status information of each sector in the data unit, the status information includes a valid state and an invalid state; the method includes: When receiving a command from the host to write data to a portion of sectors in a data unit, the solid state drive reads the data unit; Replacing the user data of the corresponding sector in the read data unit with the data of the sector to be written to obtain the data unit to be written, and setting the sector to be written to a valid state in the sector state set of the data unit to be written, while keeping the original state of other sectors; The data unit to be written is written into the storage medium of the solid state drive.
6. The method for writing to a solid state drive according to claim 5, wherein: The solid state hard disk reads the data unit, further comprising: The flash memory conversion layer of the solid state drive converts the logical address of the sector to be written in the command to write data into a physical address in the solid state drive, and reads the corresponding data unit according to the physical address.
7. The method for writing to a solid state drive according to claim 5, wherein: The sector status set is a bitmap, and each bit in the bitmap is used to indicate status information of a sector.
8. A solid state hard disk, characterized in that: The solid state drive includes a storage medium and a controller; Each data unit stored in the storage medium includes metadata and user data of at least two sectors, the metadata includes a sector status set for indicating status information of each sector in the data unit, the status information includes a valid state and an invalid state; The controller is used to execute the reading method described in any one of claims 1-4 and / or the writing method described in any one of claims 5-7.
9. The solid state drive according to claim 8, wherein: The storage medium is a flash memory.
10. The solid state drive according to claim 8, wherein: The controller includes a hardware chip and firmware.
