Control method of storage device, storage device, and computer-readable storage medium
By using different types of storage blocks in a tiered manner within the storage device, and utilizing fast storage blocks to store data in the early stages and then migrating it to other types of blocks after it is occupied, the problem of write performance degradation caused by garbage collection in storage devices is solved, achieving more efficient data writing and storage space utilization.
Patent Information
- Application Number
- CN202111348104.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-15
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2041-11-15
AI Technical Summary
In big data writing scenarios, storage devices experience a sharp decline in write performance because idle storage blocks are not frequently garbage collected.
A tiered usage strategy is adopted, using different types of storage blocks (such as SLC and MLC, TLC, QLC, etc.). Data is stored in the first storage block with faster data writing speed, and after it is exhausted, it is migrated to the second storage block. The type of the migrated first storage block is changed to the second storage block to increase storage space and reduce the number of garbage collections.
It improves data write speed, reduces the number of garbage collections in the storage device, and enhances the data write performance of the storage device.
Smart Images

Figure CN116126212B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of storage devices, in particular to a control method of a storage device, the storage device and a computer readable storage medium. BACKGROUND
[0002] The storage device is used for storing data, so that a control device connected thereto can realize data reading and writing and writing.
[0003] The inventor has found through long-term research that in the related art, a storage device adopts a write acceleration mechanism to improve data writing speed. However, in the scenario of large data writing, the write performance will sharply decrease due to insufficient garbage collection of idle storage blocks. SUMMARY
[0004] The present application mainly solves the technical problem of providing a control method of a storage device, the storage device and a computer readable storage medium, which can increase the storage space of the storage device, thereby reducing the number of garbage collection in the storage device and improving the data writing performance of the storage device.
[0005] To solve the above problems, the present application provides a control method of a storage device, which comprises: obtaining to-be-written data; storing the to-be-written data by using a first storage block, and storing the remaining to-be-written data by using a second storage block after the first storage block is occupied; wherein the types of the first storage block and the second storage block are different, the data writing speed of the first storage block is greater than that of the second storage block, and the amount of data that can be stored by the first storage block is less than that of the second storage block; performing data migration on the data stored in the first storage block, and setting the first storage block after data migration to the same type as the second storage block.
[0006] The data migration on the data stored in the first storage block comprises: obtaining a first data amount of the to-be-written data written into the second storage block; when the first data amount meets a data migration condition, performing data migration on the data stored in the first storage block.
[0007] When the first data amount meets the data migration condition, the data migration on the data stored in the first storage block comprises: when the first data amount meets the data migration condition, determining an idle second storage block and a target first storage block; migrating a second data amount of to-be-written data in the target first storage block to the idle second storage block; wherein the second data amount is less than the first data amount.
[0008] The method comprises the following steps: determining whether the data stored in the target first storage block is all migrated to the idle second storage block; and setting the target first storage block to the same type as the second storage block if the data stored in the target first storage block is all migrated to the idle second storage block.
[0009] The method comprises the following steps: obtaining a first time at which the second storage block writes the to-be-written data; and performing data migration on the data stored in the first storage block when the first time meets a data migration condition.
[0010] The method comprises the following steps: obtaining a third data amount of the to-be-written data written into the second storage block within the first time when the first time meets the data migration condition; and performing data migration on the first storage block based on the third data amount.
[0011] The method comprises the following steps: determining an idle second storage block and a target first storage block; and migrating a fourth data amount of the to-be-written data in the target first storage block to the idle second storage block, wherein the fourth data amount is less than the third data amount.
[0012] The method comprises the following steps: obtaining a second time at which no write data operation is performed on the storage device; and storing the to-be-written data in the first storage block if the second time exceeds a preset time.
[0013] To solve the above problems, another technical solution adopted by the present application is to provide a storage device, which comprises a processor and a memory coupled with the processor, the memory storing a computer program, and the processor being configured to execute the computer program to implement the method provided in the above technical solution.
[0014] To solve the above problems, another technical solution adopted by the present application is to provide a computer readable storage medium, which stores a computer program, and the computer program, when executed by a processor, implements the method provided in the above technical solution.
[0015] The beneficial effects of the present application are: different from the prior art, the storage device control method, the storage device and the computer readable storage medium provided by the present application, the method comprises: obtaining to-be-written data; using a first storage block to store the to-be-written data, and using a second storage block to store the remaining to-be-written data after the first storage block is occupied; wherein the types of the first storage block and the second storage block are different, the data writing speed of the first storage block is greater than that of the second storage block, and the amount of data that can be stored by the first storage block is less than that of the second storage block; performing data migration on the data stored in the first storage block, and setting the first storage block after data migration to be of the same type as the second storage block. Through the above manner, on the one hand, in the early stage of data writing, the first storage block with faster data writing speed is used to store data, which can improve the data writing speed, and on the other hand, the first storage block is migrated while the second storage block stores data, so as to change the first storage block into the second storage block, which can increase the storage space of the storage device, thereby reducing the number of garbage collection in the storage device and improving the data writing performance of the storage device. BRIEF DESCRIPTION OF DRAWINGS
[0016] Figure 1 is a flowchart of an embodiment of the storage device control method provided by the present application;
[0017] Figure 2 is a flowchart of another embodiment of the storage device control method provided by the present application;
[0018] Figure 3 is a flowchart of an embodiment of step 24 provided by the present application;
[0019] Figure 4 is a flowchart of an embodiment of step 25 provided by the present application;
[0020] Figure 5 is a flowchart of another embodiment of the storage device control method provided by the present application;
[0021] Figure 6 is a flowchart of an embodiment of step 54 provided by the present application;
[0022] Figure 7 is a flowchart of an embodiment of step 542 provided by the present application;
[0023] Figure 8 is a flowchart of another embodiment of the storage device control method provided by the present application;
[0024] Figure 9 is a structural diagram of an embodiment of the storage device provided by the present application;
[0025] Figure 10is a structural schematic diagram of an embodiment of the computer readable storage medium provided in the present application.
[0026] Figure 11 is a performance comparison schematic diagram of the present application and related technologies provided in the present application. DETAILED DESCRIPTION
[0027] The technical solutions in the embodiments of the present application will be clearly and completely described in combination with the drawings in the embodiments of the present application. It can be understood that the specific embodiments described herein are only used to explain the present application, rather than limit the present application. In addition, it should be noted that, for the convenience of description, only the parts related to the present application are shown in the drawings, rather than all the structures. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0028] The terms "first", "second", and the like in the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units not listed or optionally includes other steps or units inherent to the process, method, product or device.
[0029] Reference to "embodiments" herein means that the specific features, structures or characteristics described in connection with the embodiments can be included in at least one embodiment of the present application. The phrase appears at various places in the specification does not necessarily all refer to the same embodiment, nor is it necessarily mutually exclusive of other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0030] Reference is made to Figure 1 , Figure 1 is a flowchart of an embodiment of the control method of the storage device provided in the present application. The method comprises:
[0031] Step 11: obtaining data to be written.
[0032] In the present embodiment, the storage device can be a storage device of FLASH (Flash) architecture, such as UFS (Universal Flash Storage), EMMC (EMbedded Multi Media Card), etc. The storage device is connected with the control device.
[0033] The control device can be integrally arranged with the storage device, i.e., the storage device is arranged inside the control device and used as an internal storage device. For example, the control device can be integrally arranged with the storage device.
[0034] In other embodiments, the control device and the storage device are communicatively connected. For example, the storage device can be used as an external device of the control device, such as a mobile hard disk, and connected to the control device through a data line. In this case, the control device functions as a host and implements a pluggable function.
[0035] The control device can read data from the storage device or write data to the storage device.
[0036] Step 12: storing the to-be-written data in the first storage blocks and storing the remaining to-be-written data in the second storage blocks after the first storage blocks are occupied.
[0037] In this embodiment, the amount of to-be-written data written in the first storage blocks is determined according to the number of the first storage blocks. For example, the number of the first storage blocks can be set to a preset number.
[0038] The preset number of the first storage blocks can be set according to the total number of the storage blocks in the storage device. For example, the preset number of the first storage blocks can be set directly when the storage device is manufactured. For example, if the storage device has 1000 storage blocks, the preset number of the first storage blocks can be set to 100, and the remaining storage blocks are the second storage blocks. If the storage device has 2000 storage blocks, the preset number of the first storage blocks can be set to 200, and the remaining storage blocks are the second storage blocks.
[0039] In some embodiments, the preset number of the first storage blocks can be determined when data is written. For example, when data is written, the number of idle storage blocks is obtained to dynamically set the preset number of the first storage blocks. In an application scenario, when data is written, the number of idle storage blocks is obtained to be 500, and the preset number of the first storage blocks can be set to 50, i.e., the type of 50 idle storage blocks is modified to the type corresponding to the first storage blocks. The preset number and the number of idle storage blocks can be set according to 1:10, 1:20, 1:30, or 1:100, etc. When the number of idle storage blocks is small, the ratio between the preset number and the number of idle storage blocks is small, i.e., the preset number of the first storage blocks is small. When the number of idle storage blocks is large, the ratio between the preset number and the number of idle storage blocks is large, i.e., the preset number of the first storage blocks is large.
[0040] In this embodiment, the first storage blocks are SLC (Single-Level Cell, 1 order unit) type storage blocks. Using SLC type storage blocks can accelerate the writing speed of the to-be-written data and improve the writing performance.
[0041] The second storage block can be a MLC (Multi-Level Cell, 2-level cell) storage block, a TLC (Triple Level Cell, 3-level cell) type storage block, a QLC (Quad-Level Cell, 4-level cell) type storage block, or a PLC type storage block (Penta Level Cells, 5-level cell).
[0042] The PLC type storage block is a storage block capable of storing 5 bits / cell data.
[0043] After the first storage block is occupied, the remaining data to be written is stored in the second storage block.
[0044] In other embodiments, the first storage block is a MLC type storage block. The second storage block can be a TLC type storage block, a QLC type storage block, or a PLC type storage block.
[0045] In other embodiments, the first storage block is a TLC type storage block. The second storage block can be a QLC type storage block or a PLC type storage block.
[0046] In other embodiments, the first storage block is a QLC type storage block. The second storage block can be a PLC type storage block.
[0047] Step 13: Data migration is performed on the data stored in the first storage block, and the first storage block after data migration is set to the same type as the second storage block.
[0048] After a preset number of first storage blocks are written with data, the remaining data to be written is written into the second storage block.
[0049] The data write speed of the first storage block is greater than the data write speed of the second storage block, and the amount of data that can be stored in the first storage block is less than the amount of data that can be stored in the second storage block.
[0050] In this embodiment, the second storage block can be a MLC storage block, a TLC storage block, or a QLC storage block.
[0051] All storage blocks in the storage device can be MLC storage blocks, TLC storage blocks, or QLC storage blocks. When writing data, some MLC storage blocks, TLC storage blocks, or QLC storage blocks are modified to SLC storage blocks according to a preset rule, so as to preferentially store data by using the modified SLC storage blocks and improve the data write speed, i.e., the second storage block is modified to the first storage block.
[0052] The inventor has found through long-term research that, under the premise that the amount of data to be written is increasing, the second storage block is occupied more and more, and the second storage block needs to be frequently garbage collected to release the second storage block. However, frequent garbage collection will affect the writing speed. Moreover, although the first storage block also stores data, since the first storage block is modified from the second storage block, although the first storage block stores the data to be written, the actual storage space of the first storage block is not completely used, and the first storage block actually has free storage space. For example, the SLC storage block is modified from the TLC storage block, and the amount of data that can be stored by the TLC storage block is 3 times the amount of data that can be stored by the SLC storage block, so the first storage block actually has 2 unit free storage space.
[0053] After the SLC storage block is completely used for storing data, when the TLC storage block starts to write data, the data migration can be performed on the SLC storage block to release the SLC storage block, and the SLC storage block is changed to the TLC storage block. In this way, the SLC storage block becomes the TLC storage block and can store more data, so that the number of garbage collection in the storage device can be reduced, and the writing performance can be improved.
[0054] In some embodiments, after all the data to be written is written into the storage device, part of the second storage block can be set to the same type as the first storage block to ensure that there is sufficient first storage block for writing acceleration next time data is written. Specifically, after all the data to be written is written into the storage device, the idle second storage block is determined, and a preset number of idle second storage blocks are set to the same type as the first storage block.
[0055] In the embodiment, the data to be written is obtained, the first storage block is used to store the data to be written, and the second storage block is used to store the remaining data to be written after the first storage block is occupied. The types of the first storage block and the second storage block are different, the data writing speed of the first storage block is greater than that of the second storage block, and the amount of data that can be stored by the first storage block is less than that of the second storage block. The data stored in the first storage block is migrated, and the first storage block after data migration is set to the same type as the second storage block. On the one hand, in the early stage of data writing, the first storage block with faster data writing speed is used to store data, which can improve the data writing speed. On the other hand, while the second storage block stores data, the first storage block is migrated to change the first storage block to the second storage block, which can increase the storage space of the storage device, thereby reducing the number of garbage collection in the storage device and improving the data writing performance of the storage device.
[0056] Reference Figure 2 , Figure 2is a flowchart of an embodiment of the control method of the storage device provided in the present application. The method comprises:
[0057] Step 21: obtaining the data to be written.
[0058] In the present embodiment, the overall data amount of the data to be written can be determined, and if the overall data amount exceeds a preset value, step 22 is performed. If the overall data amount does not exceed the preset value, the second storage block is directly used to store the data to be written.
[0059] Step 22: using the first storage block to store the data to be written, and using the second storage block to store the remaining data to be written after the first storage block is occupied.
[0060] Step 23: obtaining a first data amount of the data to be written which is written into the second storage block.
[0061] In some embodiments, the first data amount can be obtained in a preset time. Alternatively, the first data amount can be obtained in real time when the data to be written is stored in the second storage block.
[0062] Step 24: performing data migration on the data stored in the first storage block when the first data amount meets a data migration condition.
[0063] The migration condition can be set as a preset data amount. For example, the preset data amount can be set as 50 MB, 100 MB or 200 MB.
[0064] When the first data amount meets the data migration condition, the first storage block storing the data to be written is subjected to data migration, so as to release the first storage block.
[0065] In some embodiments, the first data amount of the data to be written which is written into the second storage block can be obtained when the data to be written is stored in the second storage block. When the first data amount meets the data migration condition, the storage operation of the second storage block is suspended, the data stored in the first storage block is subjected to data migration, and then the data to be written is stored in the second storage block again after the present migration is completed.
[0066] In some embodiments, referring to Figure 3 , step 24 can be the following flowchart:
[0067] Step 241: determining an idle second storage block and a target first storage block when the first data amount meets the data migration condition.
[0068] The idle second storage block is a second storage block which does not store data.
[0069] Step 242: migrate the second data amount of to-be-written data in the target first storage block to the idle second storage block.
[0070] The second data amount is less than the first data amount.
[0071] In an application scenario, for example, the determined idle second storage block is A, and the target first storage block is a, the second data amount of to-be-written data in the target first storage block a can be migrated to the idle second storage block A.
[0072] The second data amount can be all to-be-written data in the first storage block, or can be set in a corresponding proportion according to the first data amount.
[0073] For example, the second storage block can store 9 MB of data, the first storage block can store 3 MB of data, and the data migration condition is that the first data amount exceeds 9 MB, then data migration is performed. The second data amount can be set to 1 MB, that is, when the storage space of each second storage block is occupied, the target first storage block is migrated once. In other words, after every three second storage blocks store data, the data in one first storage block is all migrated. At this time, the first storage block can be erased, and step 25 is performed.
[0074] For another example, the second storage block can store 3 MB of data, the first storage block can store 1 MB of data, and the data migration condition is that the first data amount exceeds 6 MB, then data migration is performed. The second data amount can be set to 0.5 MB, that is, when the storage space of every two second storage blocks is occupied, the target first storage block is migrated once. In other words, after every four second storage blocks store to-be-written data, the data in one first storage block is all migrated. At this time, the first storage block can be erased, and step 25 is performed.
[0075] Step 25: set the first storage block after data migration to the same type as the second storage block.
[0076] At this time, the type of the first storage block becomes the same as the type of the second storage block, so the first storage block of the changed type can be directly used to store the to-be-written data that has not been stored. At this time, because the type of the first storage block is the same as the type of the second storage block, the total amount of data that can be stored by the storage device increases, so the number of times of data recycling of the second storage block in the storage device can be reduced, and the data writing performance is improved.
[0077] In some embodiments, referring to Figure 4 , step 25 can be the following flow:
[0078] Step 251: determine whether the data stored in the target first storage block is all migrated to the idle second storage block.
[0079] If yes, step 252 is performed, and if no, step 251 is performed each time the data stored in the target first storage block is migrated.
[0080] Step 252: Set the target first storage block to the same type as the second storage block.
[0081] Wherein, the data writing speed of the first storage block is greater than the data writing speed of the second storage block, and the amount of data that can be stored by the first storage block is less than the amount of data that can be stored by the second storage block.
[0082] In this embodiment, by the above-mentioned manner, on the one hand, in the early stage of data writing, the first storage block with faster data writing speed is used to store data, which can improve the data writing speed, and on the other hand, the data migration is performed on the first storage block while the second storage block stores data, so as to change the first storage block into the second storage block, which can increase the storage space of the storage device, and further reduce the number of garbage collection in the storage device, and improve the data writing performance of the storage device.
[0083] Referring to Figure 5 , Figure 5 is a flowchart of an embodiment of the control method of the storage device provided in the present application. The method comprises:
[0084] Step 51: Obtain the to-be-written data.
[0085] Step 52: Store the to-be-written data by using the first storage block, and store the remaining to-be-written data by using the second storage block after the first storage block is occupied.
[0086] Step 51 and step 52 have the same or similar technical solutions as any of the above-mentioned embodiments, which will not be described here.
[0087] Step 53: Obtain the first time when the second storage block writes the to-be-written data.
[0088] Step 54: When the first time meets the data migration condition, perform data migration on the data stored in the first storage block.
[0089] In this embodiment, the time is used as the data migration condition, and when the second storage block writing the to-be-written data meets the data migration condition, the data migration is performed on the data stored in the first storage block, so as to release the first storage block.
[0090] In some embodiments, referring to Figure 6 , step 54 can be the following flow:
[0091] Step 541: When the first time meets the data migration condition, obtain the third data amount of the to-be-written data written into the second storage block within the first time.
[0092] Step 542: performing data migration on the first storage block based on the third data amount.
[0093] In some embodiments, referring to Figure 7 , step 542 can be the following flow:
[0094] Step 5421: determining the idle second storage block and determining the target first storage block.
[0095] Step 5422: migrating the fourth data amount of to-be-written data in the target first storage block to the idle second storage block.
[0096] Wherein, the fourth data amount is less than the third data amount.
[0097] In an application scenario, for example, the determined idle second storage block is B, and the target first storage block is b, then the fourth data amount of to-be-written data in the target first storage block b can be migrated to the idle second storage block B.
[0098] Wherein, the fourth data amount can be all data in the target first storage block b, or can be proportionally set according to the third data amount.
[0099] In an application scenario, the ratio of the fourth data amount to the third data amount is 1:10. For example, in the first time, the second storage block stores 9MB of data, i.e. the third data amount is 9MB. According to the ratio of 1:10, the fourth data amount is 0.9MB. Then, 0.9MB of to-be-written data in the target first storage block is migrated to the idle second storage block.
[0100] For example, the second storage block can store 9MB of data, and the first storage block can store 3MB of data. After four first times, the data in one first storage block is completely migrated. At this time, the first storage block can be erased, and step 55 is performed.
[0101] Since the data amount that can be migrated by four times of data migration is 3.6MB, after 3MB of data in one first storage block is migrated, another first storage block can be determined again, and the other first storage block is taken as the target first storage block, and 0.6MB of data is migrated from the new target first storage block.
[0102] In other embodiments, the ratio of the fourth data amount to the third data amount can be set according to actual needs, such as 1:5 or 1:20 or 1:30 or 1:40.
[0103] Step 55: setting the first storage block after data migration to the same type as the second storage block.
[0104] The data writing speed of the first storage block is greater than the data writing speed of the second storage block, and the data storage capacity of the first storage block is less than the data storage capacity of the second storage block.
[0105] In other embodiments, the data migration from the first storage block and the data writing to the second storage block are almost synchronized, so that the amount of data migrated from the first storage block is dynamically adjusted during the data writing to the second storage block. For example, as more and more first storage blocks are migrated, the second storage block will also increase, at which time the amount of data migrated from the first storage block can be reduced to slow down the increase of the second storage block. For example, as the number of idle second storage blocks decreases, the data writing continues, and when the number of idle second storage blocks is less than a preset value, the amount of data migrated from the first storage block can be increased to speed up the release of the first storage block, thereby increasing the number of second storage blocks.
[0106] In this embodiment, by the above method, on the one hand, in the early stage of data writing, the first storage block with faster data writing speed is used to store data, which can improve the data writing speed. On the other hand, the first storage block is migrated while the second storage block stores data, so as to change the first storage block into the second storage block, which can increase the storage space of the storage device, thereby reducing the number of garbage collection in the storage device and improving the data writing performance of the storage device.
[0107] Referring to Figure 8 , Figure 8 is a flowchart of another embodiment of the control method of the storage device provided by the present application. The method comprises:
[0108] Step 81: obtaining the data to be written.
[0109] Step 82: obtaining the second time when the storage device does not perform the data writing operation.
[0110] Step 83: if the second time exceeds the preset time, using the first storage block to store the data to be written.
[0111] If the second time exceeds the preset time, it indicates that the storage device currently does not use the first storage block to store data, so that the first storage block can be used for data storage to improve the writing speed.
[0112] Step 84: after the first storage block is occupied, using the second storage block to store the remaining data to be written.
[0113] Step 85: migrating the data stored in the first storage block, and setting the first storage block after data migration to the same type as the second storage block.
[0114] The data writing speed of the first storage block is greater than the data writing speed of the second storage block, and the data storage capacity of the first storage block is less than the data storage capacity of the second storage block.
[0115] Steps 84 and 85 have the same or similar technical solutions as any of the above embodiments, and will not be described here.
[0116] In an application scenario, the data writing in the storage device is controlled by a process. Each data writing corresponds to a process. For example, the first data writing corresponds to process A. The second data writing corresponds to process B. For example, the interval time between process B and process A is the second time. The second time is the time during which the storage device does not perform data writing operation.
[0117] If the second time does not exceed the preset time, it indicates that the first storage block has been used during the execution of process A. Therefore, when process B is executed, the corresponding data in process B is directly stored in the second storage block.
[0118] If the second time exceeds the preset time, it indicates that the first storage block has been completely migrated. A new first storage block can be generated based on the idle storage block. Therefore, step 83 is executed.
[0119] In this embodiment, when the second time exceeds the preset time, the data is stored in the first storage block, which can avoid repeated use of the first storage block for data storage. On the one hand, in the early stage of data writing, the first storage block with faster data writing speed is used to store data, which can improve the data writing speed. On the other hand, while the second storage block stores data, the data migration is performed on the first storage block to change the first storage block into the second storage block, which can increase the storage space of the storage device, thereby reducing the number of garbage collection in the storage device and improving the data writing performance of the storage device.
[0120] Referring to Figure 9 , Figure 9 is a structural schematic diagram of an embodiment of the storage device provided by the present application. The storage device 90 includes a processor 91 and a memory 92 coupled to the processor 91. The memory 92 stores a computer program. The processor 91 is configured to execute the computer program to implement the following method:
[0121] obtaining to-be-written data; storing the to-be-written data in a first storage block, and storing the remaining to-be-written data in a second storage block after the first storage block is occupied; the first storage block and the second storage block are of different types, the data writing speed of the first storage block is greater than the data writing speed of the second storage block, and the data storage capacity of the first storage block is less than the data storage capacity of the second storage block; performing data migration on the data stored in the first storage block, and setting the first storage block after data migration to be of the same type as the second storage block.
[0122] It can be understood that the processor 91 is further configured to execute the computer program to implement the method provided in any of the technical solutions above. For details, refer to any of the embodiments above, which will not be repeated here.
[0123] In this embodiment, the memory 92 can be divided into a first storage area and a second storage area. The first storage area is configured to store a computer program, and the second storage area is configured to store the to-be-written data.
[0124] Refer to Figure 10 , Figure 10 is a structural schematic diagram of an embodiment of the computer readable storage medium provided in the present application. The computer readable storage medium 100 stores a computer program 101. When the computer program 101 is executed by a processor, the following method is implemented:
[0125] obtaining to-be-written data; storing the to-be-written data by using a first storage block, and storing remaining to-be-written data by using a second storage block after the first storage block is fully occupied; wherein the first storage block and the second storage block are of different types, the data writing speed of the first storage block is greater than that of the second storage block, and the data storage capacity of the first storage block is less than that of the second storage block; performing data migration on the data stored in the first storage block, and setting the first storage block after data migration to be of the same type as the second storage block.
[0126] It can be understood that the computer program 101, when executed by a processor, also implements the method provided in any of the technical solutions above. For details, refer to any of the embodiments above, which will not be repeated here.
[0127] In an application scenario, in combination with Figure 11 , the following is explained:
[0128] In Figure 11 , the performance curves of data writing of the related art and the present application in application are respectively shown. In Figure 11 , the abscissa is the data writing time, and the ordinate is the performance value. The higher the performance value is, the better the writing performance is.
[0129] The performance curve of the related art will suddenly drop as the storage block is occupied more and more over time. However, the performance curve of the present application remains unchanged over time because the first storage block is released, thereby avoiding the problem of sharp decline in writing performance in the later stage of the related art.
[0130] To sum up, the application provides the above-mentioned any technical solution, on the one hand, in the early stage of data writing, the first storage block with faster data writing speed is used to store data, which can improve the data writing speed, on the other hand, the data migration is performed on the first storage block while the second storage block stores data, so as to change the first storage block into the second storage block, which can increase the storage space of the storage device, thereby reducing the number of garbage collection in the storage device and improving the data writing performance of the storage device.
[0131] In several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules or units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0132] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place or distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the present embodiment.
[0133] In addition, the functional units in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present alone, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0134] The integrated unit in the above-mentioned other embodiments, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the part of the prior art that makes a contribution or the whole or part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the method described in the embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various program code storage media.
[0135] The above merely describes the embodiments of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation, or direct or indirect application in other related technical fields, which is made according to the content of the present application specification and drawings, is also included in the patent protection scope of the present application.
Claims
1. A control method of a storage device, characterized by, The method comprises: acquiring data to be written; storing the data to be written by using a first storage block, and storing the remaining data to be written by using a second storage block after the first storage block is occupied; wherein the first storage block and the second storage block are of different types, the data writing speed of the first storage block is greater than the data writing speed of the second storage block, and the data storage capacity of the first storage block is less than the data storage capacity of the second storage block; performing data migration on the data stored in the first storage block, and setting the first storage block after data migration to the same type as the second storage block; wherein the data migration on the data stored in the first storage block comprises: acquiring a first data amount of the data to be written written into the second storage block; when the first data amount meets a data migration condition, determining an idle second storage block and a target first storage block; migrating a second data amount of the data to be written in the target first storage block to the idle second storage block; wherein the second data amount is less than the first data amount; or, the data migration on the data stored in the first storage block comprises: acquiring a first time when the second storage block writes the data to be written; when the first time meets a data migration condition, acquiring a third data amount of the data to be written written into the second storage block within the first time; determining an idle second storage block and a target first storage block; migrating a fourth data amount of the data to be written in the target first storage block to the idle second storage block; wherein the fourth data amount is less than the third data amount.
2. The method of claim 1, wherein setting the first storage block after data migration to the same type as the second storage block comprises: determining whether the data stored in the target first storage block is all migrated to the idle second storage block; if yes, setting the target first storage block to the same type as the second storage block.
3. The method of claim 1, wherein before storing the data to be written by using the first storage block, the method comprises: acquiring a second time when no data writing operation is performed on the storage device; if the second time exceeds a preset time, performing the step of storing the data to be written by using the first storage block.
4. A storage device, characterized by The storage device comprises a processor and a memory coupled to the processor, the memory stores a computer program, and the processor is configured to execute the computer program to implement the method of any one of claims 1-3.
5. A computer readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program, when executed by a processor, implements the method of any one of claims 1-3.
Citation Information
Patent Citations
Solid-state storage recovery system and solid-state storage recovery method
CN105912279A
Storage control method, device, equipment and computer storage medium
CN111104045A