A method, device, medium and equipment for storing data in a solid state hard disk
By introducing a separate storage solution of user data type in the solid-state drive, the problem of performance degradation of solid-state drives after deleting historical data is solved, and efficient garbage collection and performance maintenance are achieved.
Patent Information
- Application Number
- CN202510045006.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-13
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2045-01-13
AI Technical Summary
After the user deletes historical data, a large amount of junk data is generated internally by the solid-state drive, resulting in a decline in read and write performance and affecting the user experience.
By introducing a separate storage scheme for user data types in solid-state drives, data of different user data types are stored in different flash blocks. When deleting a certain type of data, as many complete flash blocks of the same type can be released, and these flash blocks can be directly recycled to improve garbage collection efficiency.
It maximizes the efficiency of garbage collection, reduces the delay of read and write, maintains the optimal performance of solid-state drives, solves the problem of degraded storage performance, and extends the service life of solid-state drives.
Smart Images

Figure CN119440424B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer storage, and particularly to a data storage method, device, medium and equipment for a solid state drive. Background Art
[0002] With the rapid development of the big data era, the amount of data has grown exponentially. People have increasingly higher requirements for the storage capacity and performance of data storage.
[0003] Taking an ordinary computer as an example, to achieve a faster startup speed and a smoother user experience, with the development of solid state drive (SSD) technology, the mechanical hard drive has been gradually replaced, bringing a significant improvement in speed. However, with the use of SSDs, after users delete some historical data, a large amount of garbage data appears inside the SSD, and the read / write performance of the SSD will drop severely. Eventually, it is manifested as a slower startup and a sharp decline in fluency, affecting the user experience. Taking a high-speed data recorder device as an example, to achieve large capacity and high bandwidth, users may use an SSD array to record multiple types of data with different rates simultaneously. After the disk is full, historical data is deleted and recording continues, and the performance is required to remain unchanged. However, with the use of SSDs, after users delete some historical data, a large amount of garbage data is generated inside the SSD, and the read / write performance of the SSD will drop severely, ultimately not meeting the user's needs. At this time, the solid state drive needs to perform garbage collection, select the block with the most garbage data, concentrate the remaining useful data into the block being written, and then erase the block to complete garbage collection. Usually, the garbage collection efficiency in this case is low, which will seriously affect the read / write performance of the SSD. Summary of the Invention
[0004] Based on this, in view of the above technical problems, it is necessary to provide a data storage method, device, medium and equipment for a solid state drive, which enables the solid state drive to have a high garbage collection efficiency without affecting the performance of the solid state drive.
[0005] The present invention adopts the following technical solutions:
[0006] The present invention provides a data storage method for a solid state drive, including:
[0007] Responding to a write command from a user, determining the sector number of the data to be written and the user data type;
[0008] Searching in the solid state drive for the current write data flash block of the user data type;
[0009] If the flash block currently written with user data type is not found, apply for an idle flash block from the list of idle flash blocks, and use the idle flash block as the flash block currently written with user data type in the solid-state drive;
[0010] Map the sector number of the data to be written to the flash block currently written with user data type to form a mapping relationship;
[0011] Store the mapping relationship in the flash translation layer mapping table, and write the data to be written to the flash block for writing.
[0012] Preferably, in response to a write command from the user, determining the sector number of the data to be written and the user data type includes:
[0013] Receive the write command from the user; the write command includes the data to be written and write parameters;
[0014] Parse the write parameters in the write command to obtain the sector number of the data to be written, the data size, and the user data type.
[0015] Preferably, the method further includes:
[0016] After writing the data to be written to the flash block for writing, return a signal indicating successful data writing to the user.
[0017] Preferably, the method further includes:
[0018] In response to a read command from the user, determine the read sector number of the data to be read;
[0019] Look up the flash block corresponding to the read sector number and the detailed address within the block in the flash translation layer mapping table;
[0020] Read the data according to the detailed address within the block of the flash block, and return the data to the user.
[0021] Preferably, after performing a deletion operation on the data of a specified user data type, all the data within the flash block occupied by the specified user data type becomes invalid data; the method further includes:
[0022] Through the garbage collection mechanism, add the flash block occupied by the specified user data type to the erase queue;
[0023] Erase the flash blocks in the erase queue through an erase task;
[0024] Return the erased flash blocks to the list of idle flash blocks.
[0025] Preferably, the solid-state drive sets the maximum number of supported user data types to the extended field of the identification information of the solid-state drive.
[0026] The present invention provides a data storage device for a solid-state drive, comprising:
[0027] a determination module, configured to determine a sector number of data to be written and a user data type in response to a write command of a user;
[0028] a lookup module, configured to look up a current write data flash block of the user data type in the solid-state drive;
[0029] a creation module, configured to, if the current write data flash block of the user data type is not found, apply for an idle flash block from a list of idle flash blocks, and use the idle flash block as the current write data flash block of the user data type in the solid-state drive;
[0030] a mapping module, configured to map the sector number of the data to be written to the current write data flash block of the user data type to form a mapping relationship;
[0031] a write module, configured to store the mapping relationship into a flash translation layer mapping table, and write the data to be written into the write data flash block.
[0032] The present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-mentioned data storage method for the solid-state drive.
[0033] The present invention provides a computer device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the above-mentioned data storage method for the solid-state drive when executing the program.
[0034] At least one of the above technical solutions adopted by the present invention can achieve the following beneficial effects:
[0035] In the present invention, the user data type is transmitted to the solid-state drive, and the solid-state drive is used to implement the separate storage of data according to the user data type, and data of different user data types are stored in different flash blocks. In this way, when deleting a certain type of data, it has nothing to do with other data. Therefore, when deleting data, as many complete flash blocks of the same type as possible can be released. For the completely released flash blocks, they will be directly recycled during garbage collection, which maximally improves the efficiency of garbage collection, reduces the read / write latency, enables the solid-state drive to perform at its best, and solves the problem of the degradation of the storage performance of the solid-state drive. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The drawings described herein are used to provide a further understanding of the present invention, and constitute a part of the present invention. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation to the present invention. In the drawings:
[0037] Figure 1 Schematic flowchart of a data storage method for a solid - state drive provided by the present invention;
[0038] Figure 2 Flowchart of steps for storing and destroying unclassified data provided by the present invention;
[0039] Figure 3 Flowchart of steps for classified storage and destruction of specified user data types provided by the present invention;
[0040] Figure 4 Schematic diagram of a data storage device for a solid - state drive provided by the present invention;
[0041] Figure 5 Schematic diagram of a computer device for implementing the data storage method of a solid - state drive provided by the present invention. Detailed implementation manners
[0042] To make the objectives, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below in conjunction with specific embodiments of the present invention and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of the present invention.
[0043] An Advanced Technology Attachment (ATA) protocol SSD with a NAND flash memory as the storage medium has a firmware algorithm for managing the NAND flash memory array, which is used to complete data recording, reading, and erasing, and needs to support functions such as bad block management, garbage collection, and wear leveling. Since users cannot specify and perceive the location where their data is stored in the NAND flash memory, various data of users are mixed and written into the blocks of the NAND flash memory. When deleting some data, only part of the data in the NAND flash memory block is deleted, and a large number of NAND flash memory blocks have both useful data and garbage data. At this time, the firmware algorithm needs to perform garbage collection, select the block with the most garbage data, concentrate the remaining useful data into the block being written, and then erase the block to complete garbage collection. Usually, the garbage collection efficiency in this case is relatively low, which will seriously affect the read - write performance of the SSD. Due to a large amount of continuously generated NAND flash memories facing garbage collection with low efficiency, the performance of the SSD will eventually continue to decline and cannot be restored during use.
[0044] Among them, the firmware is a dedicated program inside the solid-state drive for completing the FTL function, processing the recording, reading, and erasing of user data, and also needs to support functions such as bad block management, garbage collection, and wear leveling.
[0045] The reason for the continuous decline in the performance of ATA protocol-based SSDs is the chaotic data storage. With use, a large amount of garbage data appears, and the recycling efficiency of the garbage data is relatively low, ultimately pulling the performance of the SSD down to 20% or even lower of the initial performance.
[0046] Therefore, designing a firmware that can maximize the garbage collection efficiency and maintain the read and write performance of the SSD to the greatest extent during long-term use is an important and beneficial requirement.
[0047] Based on this, the present invention proposes a data storage method for a solid-state drive. This method is an extension based on the ATA protocol. The user data type is passed to the storage product firmware through an extended field. Through the storage product firmware, a separate storage scheme for user data according to the data type is implemented, and the data is stored in different flash blocks. When deleting a certain type of data, it has nothing to do with other data, and as many complete flash blocks of the same type as possible can be released. For the completely released flash blocks, they will be directly recycled during garbage collection, maximizing the garbage collection efficiency, reducing the read and write latency, exerting the best performance of the storage product, optimizing and solving the problem of the decline in the single-disk storage performance, effectively extending the lifespan of the storage product, improving the problem of system lag in electronic products, and enhancing the user experience.
[0048] The following will, in conjunction with the accompanying drawings, elaborate in detail on the technical solutions provided by each embodiment of the present invention. The present invention is described with a solid-state drive as the execution subject.
[0049] Figure 1 It is a schematic flowchart of a data storage method for a solid-state drive in the present invention, specifically including the following steps:
[0050] S101, in response to a write command from the user, determine the sector number of the data to be written and the user data type.
[0051] First of all, "Information technology - ATA / ATAPI Command Set - 3 (ACS-3)" defines the standard ATA protocol, which stipulates the access method of storage products that support the standard ATA protocol. The present invention extends the data write command based on this standard ATA protocol.
[0052] Specifically, in the parameter structure of write commands (including WRITE BUFFER (CMDE8), WRITE BUFFER DMA (CMDEB), WRITE DMA (CMDCA), WRITE DMA EXT (CMD35), WRITE DMA FUA EXT (CMD3D), WRITEFPDMAQUEUED (CMD61), WRITE MULTIPLE (CMDC5), WRITE MULTIPLE EXT (CMD39), WRITEMULTIPLE FUA EXT (CMDCE), WRITE SECTOR (CMD30), WRITE SECTOR EXT (CMD34)) sent to the solid-state drive, look for reserved fields, such as Bit[3:0] of the Device parameter (hereinafter referred to as Bit[3:0] of the Device parameter to represent the user data type parameter), and extend the definition to the user data type, which is used to notify the solid-state drive of the user data type parameter carried by the current command. Among them, the user data type is defined by the user. In the present invention, the user data type refers to the encoding of the user data type, which is represented by a type serial number from 0 to N, and N is the maximum number of supported user data types.
[0053] In the data structure defined by the basic information identification (Identify) of the solid-state drive in the ATA protocol, look for reserved fields, such as Word
[70] (hereinafter use Word
[70] to represent the maximum number of supported user data types with extended definition), and extend the definition of the maximum number of supported user data types. Limited by the field width of the user data type in the write command, taking Bit[3:0] of the Device parameter as an example, a maximum of 16 data types are supported.
[0054] The reserved field only serves as a placeholder in the ATA protocol and has no practical meaning. Products that support the standard ATA protocol do not parse this field, which has no impact on the product itself and is compatible with the standard protocol. The solid-state drive involved in the present invention will classify data according to this parameter to complete the work of classifying and storing user data.
[0055] Based on the cascading relationship of the NAND FLASH designed by the hardware of the solid-state drive, a complete Flash Translation Layer (FTL) mapping table is formed, and at the same time, a flash block management table is formed, and the maximum number of supported user data types is set to the extended field of the identification information of the solid-state drive.
[0056] The maximum number of user data types supported by the solid-state drive is stored in Word
[70] of the Identify information of the solid-state drive. Word
[70] is a reserved field in the standard ATA protocol. In the present invention, this reserved field is used as the storage location for the maximum number of supported user data types. When the host identifies the solid-state drive, it will read this Identify information to obtain information such as the model, serial number, and capacity of the solid-state drive. At the same time, it will parse the extended field Word
[70] for the maximum number of supported user data types to obtain the maximum number of supported user data types. The user data type mentioned in the present invention is a new feature extended by the solid-state drive.
[0057] Whether the solid-state drive supports setting user data type parameters is reflected in the Identify information of the solid-state drive. After the host obtains the Identify information, it can query whether it supports user data type parameters and the maximum number of supported user data types.
[0058] Specifically, in response to a write command from the user, determining the sector number and user data type of the data to be written includes: receiving the write command from the user; the write command includes the data to be written and write parameters; parsing the write parameters in the write command to obtain the sector number, data size, and user data type of the data to be written.
[0059] Among them, the write parameters sent to the solid-state drive are protocol instructions supported by the solid-state drive. Therefore, the solid-state drive can directly parse the write parameters to obtain the sector number, data size, and user data type of the data to be written.
[0060] S102, search for the current write data flash block of the user data type in the solid-state drive. If the current write data flash block of the user data type is not found, apply for an idle flash block from the list of idle flash blocks, and use the idle flash block as the current write data flash block of the user data type in the solid-state drive.
[0061] Search for the current write data flash block of the user data type in the solid-state drive. This current write data flash block refers to the flash block that has not been filled with data yet. In the solid-state drive, a mapping relationship between the user data type and the current flash block being written with data can be stored. Therefore, the corresponding current flash block being written with data can be directly searched according to the user data type. If found, the found write data flash block is determined as the current write data flash block of the user data type.
[0062] If the current flash block of the user data type is not found, apply for an idle flash block from the list of idle flash blocks, and use the idle flash block as the current write data flash block of the user data type in the solid-state drive. The list of idle flash blocks includes multiple empty flash blocks.
[0063] S103. Map the sector number of the data to be written to the flash memory block currently being written with user data type to form a mapping relationship.
[0064] Among them, the mapping relationship may include the correspondence between the sector number and the flash memory block number and the detailed address of the flash memory block.
[0065] S104. Store the mapping relationship in the flash translation layer mapping table and write the data to be written to the flash memory block for writing.
[0066] Among them, the flash translation layer is used to complete the translation, or mapping, from the host logical address space to the flash physical address space. Every time a solid-state drive writes a piece of user logical data to the flash memory address space, it records the mapping relationship from this logical address to the physical address. The next time the host wants to read this data, the firmware can read this data from the flash memory according to this mapping and then return it to the user. The mapping from the logical address to the flash physical address space completed by the flash translation layer inside the firmware forms a conversion relationship record table, which is the flash translation layer mapping table.
[0067] Store the mapping relationship in the flash translation layer mapping table. When reading data, the storage location of the data can be found from the flash translation layer mapping table; then the solid-state drive writes the data to be written carried by the write command to the current flash memory block for writing.
[0068] Optionally, after writing the data to be written to the flash memory block for writing, return a signal indicating successful data writing to the user.
[0069] In an exemplary embodiment, the data storage method of the solid-state drive of the present invention also supports writing data of an unspecified data type. Specifically, writing data of an unspecified data type includes the following steps:
[0070] S11. The user transfers the write parameters (including the sector number and data size) and the data to be written to the solid-state drive through a write command.
[0071] S12. After the solid-state drive receives the write parameters and the data to be written, it first parses the write parameters to obtain the sector number and the data size.
[0072] S13. The solid-state drive searches for the current flash memory block for writing. If it has been used up, execute S14 to create a new one. If it has not been used up, skip S14 and execute S15.
[0073] S14. The solid-state drive applies for a flash memory block from the free flash memory block list as the current flash memory block for writing.
[0074] S15. The solid-state drive maps the sector number specified by the write command to the current flash memory block for writing to form a new FTL mapping relationship.
[0075] S16, the solid-state drive writes the data to be written carried by the write command into the current write data flash block.
[0076] S17, when the write operation of the unspecified user data type is completed, the write command returns successfully.
[0077] S18, the user can repeat S11~S17 to complete writing more data into consecutive flash blocks.
[0078] The writing of the specified user data type provided by the present invention specifically includes:
[0079] S21, the user transfers the write parameters (including sector number, data size, extended user data type) and the data to be written to the solid-state drive through a write command.
[0080] S22, after receiving the write parameters and the data to be written, the solid-state drive first parses the write parameters to obtain the sector number, data size, and extended user data type.
[0081] S23, the solid-state drive searches for the current write data flash block of this user data type. If not found, S24 is executed for creation. If found, S24 is skipped and S25 is executed.
[0082] S24, the solid-state drive applies for a flash block from the list of free flash blocks as the current write data flash block of this user data type.
[0083] S25, the solid-state drive maps the sector number specified by the write command to the current write data flash block of the user data type specified by the write command to form a new FTL mapping relationship.
[0084] S26, the solid-state drive writes the data to be written carried by the write command into the current write data flash block of the user data type specified by the write command.
[0085] S27, when the write operation of the specified user data type is completed, the write command returns successfully.
[0086] S28, the user can repeat steps 21~27 to complete writing data of different user data types into different flash blocks.
[0087] In the present invention, the write operation of the specified user data type selects different flash blocks to store data according to the user-specified user data type. The method for extending the ATA protocol data write command in this operation and the method for allocating flash blocks by extending the user data type in the firmware algorithm belong to the scope of the present invention.
[0088] In an exemplary embodiment, after writing data to the solid-state drive, the data can also be read from the solid-state drive. This embodiment includes: in response to a user's read command, determining the read sector number of the data to be read; looking up the flash memory block and the detailed address within the block corresponding to the read sector number in the flash translation layer mapping table; reading the data according to the detailed address within the flash memory block, and returning the data to the user.
[0089] Specifically, the user data reading can include the following steps:
[0090] S31, the user transfers the read parameters (including sector number, data size) and the data to be read to the solid-state drive through a read command.
[0091] S32, after receiving the read parameters and the data to be read, the solid-state drive first parses the read parameters to obtain the read sector number and the data size.
[0092] S33, the solid-state drive looks up the flash memory block and the detailed address within the block corresponding to the read sector number in the FTL mapping table.
[0093] S34, the solid-state drive reads the data from the detailed address within the found flash memory block.
[0094] S35, the solid-state drive returns the read data to the host.
[0095] S36, the user data reading operation is completed.
[0096] S37, the user can repeatedly execute S31~S36 to complete the reading of all data.
[0097] Completing this operation does not affect the storage location of the data. It should be noted that the user data reading does not require specifying the user data type. The solid-state drive can locate the flash memory block and the detailed address within the block where the data is stored through the FTL mapping table according to the sector number to be accessed. This operation is consistent with the reading operation in the standard ATA protocol, and the present invention is compatible with the standard ATA data reading operation.
[0098] In an exemplary embodiment, the user data can also be destroyed. The specific process of destroying the user data includes:
[0099] S41, the user transfers the parameters and the data to be destroyed to the solid-state drive through a data management command.
[0100] S42, after receiving the data management command parameters and the data to be destroyed, the solid-state drive parses the parameters and the data to be destroyed to obtain the list of sectors to be destroyed; the list of sectors to be destroyed includes at least one sector to be destroyed.
[0101] S43, The solid-state drive finds the sector to be destroyed and its detailed address mapped to the flash block in the FTL mapping table.
[0102] S44, The solid-state drive releases the mapping relationship.
[0103] S45, The user data destruction operation is completed.
[0104] S46, The user can repeat S41~S45 to complete the operation of destroying all sector ranges where the specified data type data is written.
[0105] Among them, releasing the mapping relationship is divided into two types: covering the mapping relationship and actively releasing the mapping relationship.
[0106] Covering the mapping relationship: That is, the user updates the data by covering and writing the same logical address space. At the same time, the firmware algorithm releases the original mapping relationship in the mapping table and establishes a new mapping relationship from the logical address to the flash physical address space; Actively releasing the mapping relationship: That is, the user actively notifies the storage product through the storage interface protocol that the data at some logical addresses is no longer needed. The firmware algorithm releases the specified mapping relationship in the mapping table according to the address range given by the user.
[0107] It should be noted that for user data destruction, there is no need to specify the data type. By destroying the sector numbers where the data is written, the space of the specified data can be destroyed. This operation is consistent with the data destruction operation in the standard ATA protocol, and the present invention is compatible with the standard ATA data destruction operation.
[0108] In an exemplary embodiment, after the deletion operation of the data of the specified user data type, all the data in the flash block occupied by the specified user data type is invalid data; Recycling the flash block occupied by the specified user data type includes: adding the flash block occupied by the specified user data type to the erase queue through the garbage collection mechanism; Erasing the flash blocks in the erase queue through the erase task; Returning the erased flash blocks to the free flash block list. Specifically, it includes the following steps:
[0109] S51, When the data destruction operation of the specified user data type is completed, all the data in the flash block occupied by the specified user data type is invalid data, and other data is stored in other flash blocks, which does not affect the flash block occupied by this user data type.
[0110] S52, The solid-state drive appends the flash block occupied by the specified user data type to the erase queue through garbage collection.
[0111] S53, The solid-state drive erase task erases the flash blocks in the erase queue and waits for completion.
[0112] After the solid - state drive (SSD) erases a flash block, it returns the flash block to the free queue.
[0113] S55, the SSD repeats S52 - S54 to complete the recycling of all flash blocks occupied by the specified user data types, and there is no data migration operation during this period.
[0114] Among them, garbage collection is a firmware algorithm of the SSD that selects the flash block with the least amount of valid data from all flash blocks, reads the valid data on this flash block and records it in other blocks, simultaneously updates the valid data mapping relationship to the FTL mapping table, and then erases this flash block to obtain a new available flash block.
[0115] It should be noted that this operation is based on the implementation of the present invention, which stores different types of data in different flash blocks by specifying user data types, so that when the data is destroyed, the occupied flash blocks can be completely released, achieving the effect of direct garbage collection, thereby reducing write amplification, extending the life of the SSD, improving the response speed of the SSD, and optimizing and solving the problem of single - disk storage performance degradation to the greatest extent.
[0116] In an exemplary embodiment, to illustrate the effectiveness of the method of the present invention, a comparison of the recycling of flash blocks occupied by unclassified data is carried out, specifically including:
[0117] S61, unclassified data is stored in flash blocks in a mixed order according to the writing sequence. When part of the unclassified data type destruction operation is completed and a part of the user data is deleted, some data is valid and some data is invalid in the occupied multiple flash blocks.
[0118] S62, the SSD finds the flash block with the least amount of useful data from all used flash blocks through garbage collection.
[0119] S63, the SSD reads out the useful data in this flash block.
[0120] S64, the SSD writes the read - out data into the flash block being written.
[0121] S65, the SSD updates the original FTL mapping of the read - out data.
[0122] S66, the SSD repeats S63 - S65 to complete the migration of all valid data in this flash block.
[0123] S67, the SSD adds this flash block to the erase queue through garbage collection.
[0124] S68, the SSD erases the flash blocks in the erase queue through the erase task and waits for completion.
[0125] After the solid-state drive erases a flash memory block and completes the erasure, it returns the flash memory block to the free queue.
[0126] The solid-state drive repeats S62 - S69 to complete garbage collection for more flash memory blocks.
[0127] It should be noted that this operation is based on a general solid-state drive firmware algorithm, which realizes a general garbage collection function. Since data is not classified and various data is stored mixedly in the flash memory block, after some data is destroyed, it is impossible to completely destroy all the data in some flash memory blocks. Therefore, data migration is required to rewrite the useful data into the currently written flash memory block and update the mapping table, and then the original flash memory block can be released. The garbage collection efficiency of the general firmware algorithm is relatively low. After long-term use, data is continuously stored in a chaotic state, write amplification persists, which affects the lifespan of the solid-state drive, and the command response time increases significantly, affecting the user experience.
[0128] Among them, write amplification means that when a user wants to write a certain amount of data, the solid-state drive performs data migration during garbage collection to make room for writing this data, which causes additional data write operations, resulting in a phenomenon where the amount of data written into the flash memory is larger than the actual data written by the user, which is called write amplification.
[0129] In an exemplary embodiment, as Figure 2 and Figure 3 shown, Figure 2 is a flowchart of the steps for unclassified data storage and destruction, Figure 3 is a flowchart of the steps for classified storage and destruction of specified user data types. Please refer to Figure 2 , in the second step, three types of data are written and stored without classification, and the data is sequentially stored in the flash memory block; in the third step, the second type of data is destroyed, and there are both valid data and invalid data in flash memory block 1 and flash memory block 2; when performing garbage collection, the remaining valid data in flash memory block 1 and flash memory block 2 is migrated to flash memory block 3 (the fourth step), and the FTL mapping table of the valid data is updated to obtain flash memory block 1 and flash memory block 2 that are all full of garbage (the fifth step), and then flash memory block 1 and flash memory block 2 that are all full of garbage are erased to complete the recycling (the sixth step).
[0130] Please refer to Figure 3 , in the second step, three types of data are written and stored with user data classification, and the data is stored in different flash memory blocks according to different user data types; in the third step, the second type of data is destroyed, and all the data in flash memory block 2 is invalid, obtaining a flash memory block full of garbage data; in the fourth step, the invalid data in flash memory block 2 is erased to complete the recycling of flash memory block 2.
[0131] In the storage method of the solid-state drive provided by the present invention, by allocating flash blocks according to user data types, data of different user data types are stored in different flash blocks. Deleting data of a certain type will completely release the flash block, thereby realizing the direct recycling of the flash block, achieving the effect of not affecting the performance of the solid-state drive, and solving the problem of performance degradation of the solid-state drive after long-term use.
[0132] At the same time, by realizing the direct recycling of flash blocks, the present invention greatly reduces the data migration during the garbage collection process, minimizes the write amplification of the solid-state drive, and thus extends the service life of the solid-state drive. For data recording products, multiple data classifications are stored, and historical data is cyclically overwritten and deleted, which will maximize the optimal management of the flash blocks proposed by the present invention and achieve the effect of continuously maintaining the initial performance of the solid-state drive, completely solving the problem of performance degradation of data recording devices composed of ATA protocol SSD arrays. For ordinary electronic products, data is classified and stored. After deleting certain types of data, the garbage collection efficiency is greatly optimized, the performance of the storage product is improved, and thus the card lag problem of electronic products is maximally improved, enhancing the user experience.
[0133] When applying the data storage method of the solid-state drive provided by the present invention, it is not necessary to execute according to Figure 1 the order of the steps shown. The specific execution order of each step can be determined according to needs, and the present invention does not limit this.
[0134] The above is the data storage method of the solid-state drive provided by one or more embodiments of the present invention. Based on the same idea, the present invention also provides a corresponding data storage device for the solid-state drive, as Figure 4 shown.
[0135] Figure 4 FIG. is a schematic diagram of a data storage device for a solid-state drive provided by the present invention. The device 400 includes:
[0136] A determination module 401, configured to determine the sector number and user data type of the data to be written in response to a write command of a user;
[0137] A search module 402, configured to search for the current write data flash block of the user data type in the solid-state drive;
[0138] A creation module 403, configured to, if the current write data flash block of the user data type is not found, apply for an idle flash block from the list of idle flash blocks and use the idle flash block as the current write data flash block of the user data type in the solid-state drive;
[0139] A mapping module 404, configured to map the sector number of the data to be written to the flash memory block currently writing data of the user data type, so as to form a mapping relationship;
[0140] A writing module 405, configured to store the mapping relationship into the flash translation layer mapping table, and write the data to be written into the flash memory block for writing data.
[0141] For the specific limitations of the data storage device of the solid-state drive, reference can be made to the limitations of the data storage method of the solid-state drive in the above text, which will not be elaborated here. Each module in the above data storage device of the solid-state drive can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor in the computer device in hardware form or be independent of it, or can be stored in the memory in the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.
[0142] The present invention also provides a computer-readable storage medium, which stores a computer program, and the computer program can be used to execute the above Figure 1 provided data storage method of the solid-state drive.
[0143] The present invention also provides Figure 5 the structural schematic diagram of the computer device shown in, as Figure 5 shown, at the hardware level, the computer device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory. Of course, other hardware required for other services may also be included. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the above Figure 1 provided data storage method of the solid-state drive.
[0144] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the various embodiments provided by the present invention can include at least one of non-volatile and volatile memories. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0145] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded by the present invention.
Claims
1. A data storage method for a solid state hard disk, characterized in that: include: Receiving a write command from a user; the write command includes data to be written and write parameters; Parsing the write parameters in the write command to obtain the sector number, data size and user data type of the data to be written; the user data type is determined by extending the write command through the standard ATA protocol and is defined by the user, the solid-state drive sets the maximum supported number of user data types to the extended field of the identification information of the solid-state drive, the user data type is represented by a type serial number from 0 to N, N is the maximum number of supported user data types, and one user data type corresponds to one type serial number; Searching the solid state drive for a current written data flash memory block for the user data type; If the current data writing flash memory block for the user data type is not found, apply for a free flash memory block from the free flash memory block list, and use the free flash memory block as the current data writing flash memory block for the user data type in the solid state drive; Mapping the sector number of the data to be written and the current write data flash memory block of the user data type to form a mapping relationship; The mapping relationship is stored in a flash translation layer mapping table, and the data to be written is written into the write data flash memory block; After the data of the specified user data type is deleted, all data in the flash memory block occupied by the specified user data type is invalid data; the method also includes: adding the flash memory block occupied by the specified user data type to the erase queue through a garbage collection mechanism; erasing the flash memory blocks in the erase queue through an erase task; and returning the erased flash memory blocks to the free flash memory block list.
2. The method according to claim 1, characterized in that The method further comprises: After the data to be written is written into the write data flash memory block, a signal indicating that the data is written successfully is returned to the user.
3. The method according to claim 1, characterized in that The method further comprises: In response to a read command from a user, determining a read sector number of data to be read; Searching the flash memory block corresponding to the read sector number and the detailed address in the block in the flash memory translation layer mapping table; Data is read according to the detailed address within the flash memory block, and the data is returned to the user.
4. A data storage device of a solid state hard disk, characterized in that: include: A determination module, configured to receive a write command from a user; the write command includes data to be written and write parameters; Parsing the write parameters in the write command to obtain the sector number, data size and user data type of the data to be written; the user data type is determined by extending the write command through the standard ATA protocol and is defined by the user, the solid-state drive sets the maximum supported number of user data types to the extended field of the identification information of the solid-state drive, the user data type is represented by a type serial number from 0 to N, N is the maximum number of supported user data types, and one user data type corresponds to one type serial number; A search module, used for searching the current written data flash memory block of the user data type in the solid state drive; A creation module is used for applying for a free flash block from a free flash block list if the current write data flash block of the user data type is not found, and using the free flash block as the current write data flash block of the user data type in the solid state drive; A mapping module, used for mapping the sector number of the data to be written with the current writing data flash memory block of the user data type to form a mapping relationship; A writing module, used for storing the mapping relationship in a flash translation layer mapping table, and writing the data to be written into the write data flash memory block; After the data of the specified user data type is deleted, all data in the flash memory block occupied by the specified user data type are invalid data; the device is also used to add the flash memory block occupied by the specified user data type to the erasure queue through a garbage collection mechanism; Erasing the flash memory blocks in the erase queue by an erase task; The flash memory blocks whose erasure is completed are returned to the free flash memory block list.
5. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
6. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Data storage method and storage equipment
CN107092439A
Data writing method and storage equipment
CN107967121A
Hard disk data storage method and device and storage medium
CN110737404A