Dynamic recovery processing method of stored data and storage device
Technical Field
The present invention relates to the field of memory technologies, and in particular, to a dynamic recovery processing method for stored data and a storage device.
Background
In the existing TLC FLASH storage product, part of TLC blocks generally use an SLC mode to cache data, and after the data is written to a certain extent, valid data cached in the SLC blocks is transferred to the TLC blocks, at this time, the number of SLC blocks is greatly reduced, only a small number of SLC blocks are reserved for caching data, generally 128 blocks, and because the number of SLC blocks is small, the number of data recovery times is increased, and the product performance is reduced.
Disclosure of Invention
The invention aims to provide a dynamic recovery processing method for stored data and a storage device aiming at the problem of performance reduction of products caused by a large number of data recovery times in the prior art, and the method and the device can effectively improve the performance of the products.
A dynamic recovery processing method of stored data comprises the following steps:
receiving a data writing command and acquiring a logical address in the data writing command;
judging whether the logic address has a corresponding storage unit according to a pre-established mapping table;
if the corresponding storage unit does not exist in the logical address, adding 1 to the effective logical capacity, and updating the mapping table;
calculating effective logic capacity according to the mapping table;
according to the size of the effective logic capacity, the data are stored by using the SLC block and the TLC block dynamically;
dynamically using SLC block internal recovery data and/or TLC block recovery data depending on the size of the available logical capacity and the number of SLC empty blocks.
Further, the effective logical capacity is the total capacity of the storage units corresponding to all the logical addresses in the mapping table;
according to the size of the effective logic capacity, the data is stored by using SLC blocks and TLC blocks dynamically, and the method comprises the following steps:
and detecting whether the effective logic capacity is less than or equal to a first capacity threshold value, and if so, storing data by using the SLC blocks completely.
Further, according to the size of the effective logic capacity, the data is stored dynamically by using the SLC blocks and the TLC blocks, and the method further comprises the following steps:
and detecting whether the effective logic capacity is larger than a first capacity threshold and smaller than or equal to a second capacity threshold, if so, partially adopting SLC blocks to store data, and partially adopting TLC blocks to store data, wherein the number of SLC blocks is more than that of TLC blocks.
Further, according to the size of the effective logic capacity, the data is stored dynamically by using the SLC blocks and the TLC blocks, and the method further comprises the following steps:
and detecting whether the effective logic capacity is larger than a second capacity threshold and smaller than or equal to a third capacity threshold, if so, partially adopting SLC blocks to store data, and partially adopting TLC blocks to store data, wherein the number of SLC blocks is less than that of TLC blocks.
Further, dynamically using SLC block internal recycle data and/or TLC block recycle data based on the size of the available logical capacity and the number of SLC empty blocks, comprising:
if the effective logical capacity is greater than the third capacity threshold and the number of SLC empty blocks is less than a third number threshold, then the stored data in the SLC blocks is transferred to the TLC blocks.
Further, if the effective logical capacity is greater than the second capacity threshold and less than or equal to a third capacity threshold and the number of SLC empty blocks is less than a second number threshold, then the stored data in the SLC blocks is transferred to corresponding TLC blocks and data is recovered inside the remaining SLC blocks.
Further, if the effective logical capacity is greater than the first capacity threshold and less than or equal to the second capacity threshold and the number of SLC empty blocks is less than a first number threshold, then all of the data is recycled inside the SLC blocks.
Further, the first capacity threshold is 1/3 of system capacity, the second capacity threshold is 1/2 of system capacity, and the third capacity threshold is 2/3 of system capacity.
Further, the first quantity threshold is 90% of the total number of SLC blocks for which the effective logical capacity is less than or equal to the first capacity threshold;
the second number threshold is 90% of the number of SLC blocks when the effective logical capacity is greater than the first capacity threshold and less than or equal to the second capacity threshold;
the third quantity threshold is 128.
A storage device comprises a main control unit and a storage module, wherein the storage module is used for storing a plurality of instructions, and the main control unit is used for reading the instructions and executing:
receiving a data writing command and acquiring a logical address in the data writing command;
judging whether the logic address has a corresponding storage unit according to a pre-established mapping table;
if the corresponding storage unit does not exist in the logical address, adding 1 to the effective logical capacity, and updating the mapping table;
calculating effective logic capacity according to the mapping table;
according to the size of the effective logic capacity, the data are stored by using the SLC block and the TLC block dynamically;
dynamically using SLC block internal recovery data and/or TLC block recovery data depending on the size of the available logical capacity and the number of SLC empty blocks.
According to the dynamic recovery processing method and the storage device for the storage data, provided by the invention, the data are dynamically recovered by adopting different recovery modes according to the size of the effective logic capacity, so that the recovery times can be effectively reduced, and the product performance and the stability can be improved.
Drawings
Fig. 1 is a flowchart of an embodiment of a method for dynamically recycling stored data according to the present invention.
Fig. 2 is a flowchart of another embodiment of a dynamic recovery processing method for stored data according to the present invention.
Fig. 3 is a schematic structural diagram of a memory device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and effects of the present invention clearer and clearer, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Example one
Referring to fig. 1, the present embodiment provides a method for dynamically recycling stored data, including:
step S101, receiving a data writing command and acquiring a logic address in the data writing command;
step S102, judging whether the logic address has a corresponding storage unit according to a pre-established mapping table;
step S103, if the corresponding storage unit does not exist in the logical address, adding 1 to the effective logical capacity, and updating the mapping table;
step S104, calculating effective logic capacity according to the mapping table;
step S105, according to the size of the effective logic capacity, the SLC block and the TLC block are used for storing data dynamically;
and a step S106 of dynamically using the SLC block internal recovery data and/or the TLC block recovery data according to the size of the effective logical capacity and the number of SLC empty blocks.
Specifically, step S101 is executed to detect whether a data write command of a user is received, and if so, a logical address in the data write command is acquired.
Further, step S102 is executed to determine whether the logical address has a corresponding storage unit according to a pre-established mapping table, where the mapping table is used to store a mapping relationship between the logical address and the storage unit.
Further, step S103 is executed to determine whether the logical address has a corresponding storage unit, that is, whether the logical address has a mapping record, if the logical address does not have a corresponding storage unit, add 1 to the effective logical capacity, and update the mapping table, and if the logical address has a corresponding storage unit, the effective logical capacity is not added.
Further, step S104 is executed to calculate an effective logical capacity according to a mapping table, where the effective logical capacity is a total capacity of storage units corresponding to all logical addresses in the mapping table.
Further, step S105 is executed to dynamically use the SLC block and the TLC block to store data according to the size of the available logical capacity, which specifically includes:
and detecting whether the effective logic capacity is less than or equal to a first capacity threshold value, and if so, storing data by using the SLC blocks completely.
As a preferred embodiment, the first capacity threshold is 1/3 of the system capacity, the system capacity is the total capacity of the system reported by the storage device, and when the effective logical capacity is less than 1/3 of the system capacity, all SLC blocks are used to store data, and the performance is optimal at this time.
Further, dynamically using the SLC block and the TLC block to store data according to the size of the available logical capacity, further comprises:
and detecting whether the effective logic capacity is larger than a first capacity threshold and smaller than or equal to a second capacity threshold, if so, partially adopting SLC blocks to store data, and partially adopting TLC blocks to store data, wherein the number of SLC blocks is more than that of TLC blocks.
In a preferred embodiment, the second capacity threshold is 1/2 of the system capacity, and when the available logical capacity is greater than 1/3 of the system capacity and less than or equal to 1/2 of the system capacity, the data is stored mainly using SLC blocks, and at the same time, a small number of TLC blocks are used to store data, that is, the number of SLC blocks is greater than the number of TLC blocks.
Further, dynamically using the SLC block and the TLC block to store data according to the size of the available logical capacity, further comprises:
and detecting whether the effective logic capacity is larger than a second capacity threshold and smaller than or equal to a third capacity threshold, if so, partially adopting SLC blocks to store data, and partially adopting TLC blocks to store data, wherein the number of SLC blocks is less than that of TLC blocks.
In a preferred embodiment, the third capacity threshold is 2/3 of the system capacity, and if the available logical capacity is less than 1/2 and less than or equal to 2/3, the TLC blocks are mainly used to store data while a small number of TLC blocks are used to store data, i.e. the number of TLC blocks is greater than the number of SLC blocks.
Further, step S106 is executed, and referring to fig. 2, the dynamically using the SLC block internal recycle data and/or the TLC block recycle data according to the size of the effective logical capacity and the number of SLC empty blocks specifically includes:
if the effective logical capacity is greater than the third capacity threshold and the number of SLC empty blocks is less than a third number threshold, then the stored data in the SLC blocks is transferred to the TLC blocks.
In a preferred embodiment, the third threshold number is the minimum number of SLC blocks in a conventional design, typically 128 blocks, and when the available logical capacity is greater than 2/3 system capacity, the number of SLC empty blocks is detected, and if the number of SLC empty blocks is less than the first threshold number, data recovery is performed, wherein all of the SLC blocks are transferred to TLC blocks, leaving only a portion of the SLC blocks as hot data buffers, since data is stored primarily in TLC blocks, a small portion is stored in SLC blocks, and the number of TLC blocks is greater than the number of SLC blocks.
Further, if the effective logical capacity is greater than the second capacity threshold and less than or equal to a third capacity threshold and the number of SLC empty blocks is less than a second number threshold, then the stored data in the SLC blocks is transferred to corresponding TLC blocks and data is recovered inside the remaining SLC blocks.
As a preferred embodiment, if the available logical capacity is greater than 1/2 system capacity and less than or equal to 2/3 system capacity, it is checked whether the number of SLC empty blocks is less than a second number threshold, which is 90% of the total number of current SLC blocks, and if the number of SLC empty blocks is less than the second number threshold, which is less than 90% of the total number, then data reclamation is required, where the data is primarily stored in SLC blocks, and where a small portion is stored in TLC blocks, where the number of SLC blocks is greater than the number of TLC blocks, the stored data of some SLC blocks is transferred to corresponding TLC blocks, and where the remaining portion of SLC block data is reclaimed inside the SLC blocks, and invalid data is reclaimed and the SLC blocks are freed.
Further, if the available logical capacity is greater than the first capacity threshold and less than or equal to the second capacity threshold and the number of SLC empty blocks is less than a first number threshold, then all SLA block internal reclamation data is used.
As a preferred embodiment, if the available logical capacity is greater than the first capacity threshold and less than or equal to the second capacity threshold, it is detected whether the number of SLC empty blocks is less than a first number threshold, the first number threshold being 90% of the total number of SLC blocks currently, and if the number of SLC empty blocks is less than the first number threshold, i.e. less than 90% of the total number, data recovery is performed.
SLC (Single-Level Cell), which is used to temporarily store data, has a small capacity and a high speed.
TLC (Triple-Level Cell) is used for long-term data storage, and has large capacity and large quantity.
The SLC block and TLC block may be switched to each other.
According to the dynamic recovery processing method for the stored data, the data are dynamically recovered by adopting different recovery modes according to the size of the effective logic capacity, so that the recovery times can be effectively reduced, and the product performance and the stability can be improved.
Example two
Referring to fig. 3, the present embodiment provides a storage apparatus, including a main control unit 201 and a storage module 202, where the storage module 202 is configured to store a plurality of instructions, and the main control unit 201 is configured to read the instructions and execute:
receiving a data writing command and acquiring a logical address in the data writing command;
judging whether the logic address has a corresponding storage unit according to a pre-established mapping table;
if the corresponding storage unit does not exist in the logical address, adding 1 to the effective logical capacity, and updating the mapping table;
calculating effective logic capacity according to the mapping table;
according to the size of the effective logic capacity, the data are stored by using the SLC block and the TLC block dynamically;
dynamically using SLC block internal recovery data and/or TLC block recovery data depending on the size of the available logical capacity and the number of SLC empty blocks.
As a preferred embodiment, the effective logical capacity is a total capacity of the storage units corresponding to all logical addresses in the mapping table.
Further, the main control unit 201 is further configured to perform:
and detecting whether the effective logic capacity is less than or equal to a first capacity threshold value, and if so, storing data by using the SLC blocks completely.
Further, the main control unit 201 is further configured to perform:
and detecting whether the effective logic capacity is larger than a first capacity threshold and smaller than or equal to a second capacity threshold, if so, partially adopting SLC blocks to store data, and partially adopting TLC blocks to store data, wherein the number of SLC blocks is more than that of TLC blocks.
Further, the main control unit 201 is further configured to perform:
and detecting whether the effective logic capacity is larger than a second capacity threshold and smaller than or equal to a third capacity threshold, if so, partially adopting SLC blocks to store data, and partially adopting TLC blocks to store data, wherein the number of SLC blocks is less than that of TLC blocks.
Further, the main control unit 201 is further configured to perform:
if the effective logical capacity is greater than the third capacity threshold and the number of SLC empty blocks is less than a third number threshold, then the stored data in the SLC blocks is transferred to the TLC blocks.
Further, the main control unit 201 is further configured to perform:
if the effective logical capacity is greater than the second capacity threshold and less than or equal to a third capacity threshold and the number of SLC empty blocks is less than a second number threshold, then the stored data in the SLC blocks is transferred to corresponding TLC blocks and data is recovered inside the remaining SLC blocks.
Further, the main control unit 201 is further configured to perform:
if the available logical capacity is greater than the first capacity threshold and less than or equal to the second capacity threshold and the number of SLC empty blocks is less than a first number threshold, then all of the data is recycled using the SLC blocks internally.
In a preferred embodiment, the first capacity threshold is 1/3 of the system capacity, the second capacity threshold is 1/2 of the system capacity, and the third capacity threshold is 2/3 of the system capacity.
As a preferred embodiment, the first number threshold is 90% of the total number of SLC blocks at which the effective logical capacity is less than or equal to the first capacity threshold;
the second number threshold is 90% of the number of SLC blocks when the effective logical capacity is greater than the first capacity threshold and less than or equal to the second capacity threshold;
the third quantity threshold is 128.
The storage device provided by the embodiment can dynamically recycle data by adopting different recycling modes according to the size of the effective logic capacity, can effectively reduce the recycling times, and has high product performance and stability.
It will be understood that modifications and variations can be made by persons skilled in the art in light of the above teachings and all such modifications and variations are intended to be included within the scope of the invention as defined in the appended claims.