Disclosure of Invention
In view of this, embodiments of the present invention mainly provide a data storage method and apparatus, which can improve storage speed and save storage cost.
In order to achieve the purpose, the technical scheme of the invention is realized as follows:
the invention provides a data storage method which is applied to a mixed solid state disk comprising at least two Nand Flash memories, wherein each Nand Flash memory comprises a plurality of blocks, and the method comprises the following steps:
in the garbage recycling process, selecting part of the blocks as recycling blocks;
and when the moving times of the effective pages in the recovery block reach a first carrying threshold value, carrying the effective pages to a Nand Flash memory with the service life shorter than that of the current Nand Flash memory.
Preferably, the method further comprises:
and when the moving times of the effective pages in the recovery blocks do not reach a first carrying threshold value but reach a second carrying threshold value and the utilization rate of the current Nand Flash memory reaches a preset value, carrying the effective pages to the Nand Flash memory with the service life shorter than that of the current Nand Flash memory.
Preferably, the method further comprises:
and when the moving times of the effective pages in the recovery blocks do not reach a second threshold value, moving the effective pages to the non-recovery blocks of the current Nand Flash memory, and weighting the moving times of the effective pages.
Preferably, the method further comprises:
the number of shifts of the overwritten page is decremented.
Preferably, the method further comprises:
and storing the primarily stored data in a Nand Flash memory with longer service life and the idle rate meeting a preset storage threshold.
The invention provides a mixed solid state disk which comprises a Flash translation layer FTL and at least two Nand Flash memories, wherein each Nand Flash memory comprises a plurality of blocks; wherein,
the flash translation layer FTL is used for selecting part of the blocks as recovery blocks in a garbage recovery process; and when the moving times of the effective pages in the recovery block reach a first carrying threshold value, carrying the effective pages to a Nand Flash memory with the service life shorter than that of the current Nand Flash memory.
Preferably, the Flash translation layer FTL is further configured to, when the number of times of moving the valid page in the recovery block does not reach the first transportation threshold but reaches the second transportation threshold, and the usage rate of the current Nand Flash memory reaches a preset value, transport the valid page to a Nand Flash memory having a shorter life than the current Nand Flash memory.
Preferably, the Flash translation layer FTL is further configured to, when the number of times of moving the valid page in the recovery block does not reach the second threshold, move the valid page to the non-recovery block of the current Nand Flash memory, and weight the number of times of moving the valid page.
Preferably, the flash translation layer FTL is further configured to reduce the number of times of moving the overwritten page.
Preferably, the Flash translation layer FTL is further configured to store the primarily stored data in a Nand Flash memory with a long service life and an idle rate meeting a preset storage threshold.
From the above, the technical solution of the embodiment of the present invention includes: the method is applied to a mixed solid state disk comprising at least two Nand Flash memories, wherein each Nand Flash memory comprises a plurality of blocks, and the method comprises the following steps: in the garbage recycling process, selecting part of the blocks as recycling blocks; and when the moving times of the effective pages in the recovery block reach a first carrying threshold value, carrying the effective pages to a Nand Flash memory with the service life shorter than that of the current Nand Flash memory. Therefore, data (cold data) which are not operated frequently are conveyed to a Nand Flash memory with the service life shorter than that of the current Nand Flash memory in the garbage collection process, so that a storage space with good performance (the Nand Flash memory with high cost, small capacity and long service life) is free, a storage space with poor performance (the Nand Flash memory with low cost, large capacity and short service life) is fully utilized, the storage speed can be improved, and the storage cost can be saved.
Detailed Description
The first embodiment of the data storage method provided by the invention is applied to a mixed solid state disk comprising at least two Nand Flash memories, wherein each Nand Flash memory comprises a plurality of blocks; as shown in fig. 1, the method includes:
step 101, in the garbage collection process, selecting part of the blocks as collection blocks.
And 102, when the moving times of the effective pages in the recovery blocks reach a first transport threshold value, transporting the effective pages to a Nand Flash memory with the service life shorter than that of the current Nand Flash memory.
Therefore, in the embodiment, data which is not operated frequently (data which is operated infrequently as the number of times of moving is increased without being modified) is moved to the Nand Flash memory with the service life shorter than that of the current Nand Flash memory in the garbage collection process, so that a storage space with good performance (the Nand Flash memory with high cost, small capacity and long service life) is free, a storage space with poor performance (the Nand Flash memory with low cost, large capacity and short service life) is fully utilized, the storage speed can be improved, and the storage cost can be saved.
The second embodiment of the data storage method provided by the invention is applied to a mixed solid state disk comprising at least two Nand Flash memories, wherein each Nand Flash memory comprises a plurality of blocks; as shown in fig. 2, the method includes:
step 201, in the garbage collection process, selecting part of the blocks as collection blocks.
And 202, when the moving times of the effective pages in the recovery blocks do not reach a first carrying threshold value but reach a second carrying threshold value and the utilization rate of the current Nand Flash memory reaches a preset value, carrying the effective pages to the Nand Flash memory with the service life shorter than that of the current Nand Flash memory.
Here, the preset value may be set to a value of 80% to 90%, and in practical application, the preset value may be set according to the specific situation of the Nand Flash memory.
Therefore, in the embodiment, when the valid pages in the recovery block are transported, the utilization rate of the current Nand Flash memory is also considered, and when the moving times of the valid pages in the recovery block do not reach the first transport threshold but reach the second transport threshold, the valid pages in the recovery block are still transported, so that the stored data can be reasonably distributed, and various Nand Flash memories in the mixed solid state disk can be more reasonably used.
The third embodiment of the data storage method provided by the invention is applied to a mixed solid state disk comprising at least two Nand Flash memories, wherein each Nand Flash memory comprises a plurality of blocks; as shown in fig. 3, the method includes:
step 301, in the garbage collection process, selecting part of the blocks as collection blocks.
And 302, when the moving times of the effective pages in the recovery blocks do not reach a second threshold value, moving the effective pages to the non-recovery blocks of the current Nand Flash memory, and weighting the moving times of the effective pages.
Therefore, the present embodiment counts the number of times of moving the valid page by weighting the number of times of moving the valid page in the non-recovery block of the current Nand Flash memory, so that the accurate number of times of moving the valid page can be obtained.
The fourth embodiment of the data storage method provided by the invention is applied to a mixed solid state disk comprising at least two Nand Flash memories, wherein each Nand Flash memory comprises a plurality of blocks; as shown in fig. 4, the method includes:
step 401, in the garbage collection process, selecting a part of the blocks as collection blocks.
And 402, when the moving times of the effective pages in the recovery blocks do not reach a second threshold value, moving the effective pages to the non-recovery blocks of the current Nand Flash memory, and weighting the moving times of the effective pages.
In step 403, the number of times of movement of the overwritten page is decremented.
Here, step 403 is not limited to being performed after step 402, and is performed at any time during the process of storing data.
Thus, the present embodiment can determine the use of the page more accurately by reducing the number of times the page is moved to be overwritten.
The fifth embodiment of the data storage method provided by the invention is applied to a mixed solid state disk comprising at least two Nand Flash memories, wherein each Nand Flash memory comprises a plurality of blocks; as shown in fig. 5, the method includes:
and 501, storing the primarily stored data in a NandFlash memory which has a long service life and a vacancy rate meeting a preset storage threshold value.
Step 502, in the garbage collection process, selecting a part of the blocks as collection blocks.
Step 503, judging whether the moving times of the effective pages in the recovery block reach a first carrying threshold value, and entering step 504 when the moving times of the effective pages in the recovery block do not reach the first carrying threshold value; when the first handling threshold is reached, step 506 is entered.
Step 504, judging whether the moving times of the effective pages in the recovery block reach a second carrying threshold value or not, and entering step 505 when the moving times of the effective pages in the recovery block reach the second carrying threshold value; when the second conveyance threshold is not reached, the process proceeds to step 507.
Here, the first conveyance threshold is larger than the second conveyance threshold.
505, judging whether the current utilization rate of the Nand Flash memory reaches a preset value, and entering 506 when the current utilization rate of the Nand Flash memory reaches the preset value; when the preset value is not reached, the process proceeds to step 507.
And step 506, the effective page is transported to a Nand Flash memory with the service life shorter than that of the current Nand Flash memory, and the process is ended.
And 507, moving the effective page to a non-recovery block of the current Nand Flash memory, and weighting the moving times of the effective page.
Step 508, decrement or clear the number of moves of the overwritten page.
Here, step 509 is not limited to being performed after step 508, and is performed at any time during the process of storing data.
Therefore, the embodiment stores the data stored for the first time in the Nand Flash memory with the long service life and the idle rate meeting the preset storage threshold, can reduce the times of stored data transportation, performs corresponding processing aiming at different conditions, can reasonably distribute the stored data, and further more reasonably uses various Nand Flash memories in the mixed solid state disk.
In the embodiment of the hybrid solid state disk provided by the invention, as shown in fig. 6, the hybrid solid state disk includes a Flash translation layer FTL601 and at least two Nand Flash memories 602, and each Nand Flash memory 602 includes a plurality of blocks; wherein,
the flash translation layer FTL601 is configured to select a part of the blocks as a recovery block in a garbage recovery process; and when the moving times of the effective pages in the recovery blocks reach a first carrying threshold value, carrying the effective pages to a Nand Flash memory 602 with the service life shorter than that of the current Nand Flash memory 602.
In this way, data which is not operated frequently (the more times of the data are moved without being modified, the more the data are cold data) is moved to the Nand Flash memory with the service life shorter than that of the current Nand Flash memory 602 in the garbage collection process, so that a storage space with good performance (the Nand Flash memory with high cost, small capacity and long service life) is free, a storage space with poor performance (the Nand Flash memory with low cost, large capacity and short service life) is fully utilized, the storage speed can be improved, and the storage cost can be saved.
Preferably, the Flash translation layer FTL601 is further configured to, when the number of times of moving the valid page in the recovery block does not reach the first transportation threshold but reaches the second transportation threshold, and the usage rate of the current Nand Flash memory reaches a preset value, transport the valid page to a Nand Flash memory with a shorter life than the current Nand Flash memory.
In this way, when the valid pages in the recovery block are transported, the utilization rate of the current Nand Flash memory is also considered, when the moving times of the valid pages in the recovery block do not reach the first transport threshold value but reach the second transport threshold value, the valid pages in the recovery block are still transported, the stored data can be distributed reasonably, and then various Nand Flash memories in the mixed solid state disk can be used more reasonably.
Preferably, the Flash translation layer FTL601 is further configured to, when the number of times of moving the valid page in the recovery block does not reach the second threshold, move the valid page to the non-recovery block of the current Nand Flash memory 602, and weight the number of times of moving the valid page.
In this way, the number of times of moving the valid page is counted by weighting the number of times of moving the valid page in the non-collection block moved to the current Nand Flash memory 602, and thus an accurate number of times of moving the valid page can be obtained.
Preferably, the flash translation layer FTL601 is further configured to reduce the number of times of moving the overwritten page.
In this way, by reducing the number of times of movement of the overwritten page, the use of the page can be determined more accurately.
Preferably, the Flash translation layer FTL601 is further configured to store the primarily stored data in the Nand Flash memory 602, which has a long life and an idle rate meeting a preset storage threshold.
Therefore, the data stored for the first time are stored in the Nand Flash memory 602 which has a long service life and a vacancy rate meeting a preset storage threshold, so that the times of stored data transportation can be reduced, the stored data can be distributed reasonably, and various Nand Flash memories 602 in the hybrid solid state disk can be used more reasonably.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described device embodiments are merely illustrative, for example, the division of the unit is only a logical functional division, and there may be other division ways in actual implementation, such as: multiple units or components may be combined, or may be integrated into another system, or some features may be omitted, or not implemented. In addition, the coupling, direct coupling or communication connection between the components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between the devices or units may be electrical, mechanical or other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units; can be located in one place or distributed on a plurality of network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, all the functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately regarded as one unit, or two or more units may be integrated into one unit; the integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
Those of ordinary skill in the art will understand that: all or part of the steps for realizing the method embodiments can be completed by hardware related to program instructions, the program can be stored in a computer readable storage medium, and the program executes the steps comprising the method embodiments when executed; and the aforementioned storage medium includes: a mobile storage device, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Alternatively, the integrated unit of the present invention may be stored in a computer-readable storage medium if it is implemented in the form of a software functional module and sold or used as a separate product. Based on such understanding, the technical solutions of the embodiments of the present invention may be essentially implemented or a part contributing to the prior art may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the methods described in the embodiments of the present invention. And the aforementioned storage medium includes: a mobile storage device, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.