Storage Block Management Method, Device, Storage Device, and Storage Medium
By dividing memory blocks into different types of storage pools and dynamically adjusting their status, giving priority to using high-wear blocks and performing wear equalization operations, the problems of uneven wear of memory blocks and write amplification effects are solved, extending the service life of the storage device and improving performance stability.
Patent Information
- Application Number
- CN202510329319.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2045-03-20
AI Technical Summary
Existing memory blocks are not uniformly worn, severe write amplification effect, limited service life of storage devices, and insufficient performance stability.
By dividing the storage blocks into the corresponding type of storage pool (used storage block pool, first free storage block pool, second free storage block pool, and high wear storage block pool), the storage block with the highest erasing is preferred, the state of the storage block and the partition of the pool are dynamically adjusted, and the wear equalization operation is performed to balance the wear distribution.
It effectively alleviates the problem of uneven wear of memory blocks, reduces the write amplification effect, significantly improves the service life and performance stability of storage devices, and ensures the reliability and efficiency of data storage.
Smart Images

Figure CN119847453B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of storage technology, and in particular, to a storage block management method, apparatus, storage device, and storage medium. Background Art
[0002] In modern storage systems, NAND flash memory has become the core storage medium for solid-state drives (SSDs), memory cards, and embedded storage devices due to its advantages such as high density, high performance, and low power consumption. The storage units of NAND flash memory have the characteristic that write and erase operations need to be performed in units of blocks, and at the same time, the number of erase times for each storage unit is limited. In actual use, the user data written by the host can generally be divided into two categories: hot data (data that will be frequently modified) and cold data (data that remains unchanged for a long time). After hot data is stored in NAND flash memory, the original data in the storage block will become invalid due to frequent updates by the host, thus triggering an erase operation; while once cold data is stored in a storage block, it may not be modified for a long time, resulting in the storage block where it is located remaining in a low-erase state. To extend the service life of NAND flash memory devices, the storage system usually adopts the wear leveling (WL) technology to move cold data to storage blocks with heavier wear to balance the erase count distribution of storage blocks.
[0003] However, there are many problems in the existing wear leveling technology in practical applications. First, since the host cannot accurately distinguish between hot data and cold data when writing data, cold data may be stored in low-wear blocks for a long time, while hot data causes the storage blocks where it is located to quickly wear due to frequent update operations, resulting in a serious imbalance in the hot and cold distribution between storage blocks. Second, to solve the problem of uneven wear, wear leveling garbage collection (WL GC) will move cold data from low-wear blocks to high-wear blocks, but this process will introduce a large number of additional write and erase operations, resulting in a significant increase in the write amplification effect (actual NAND write volume / host write data volume). The direct consequence of write amplification is a double decline in the life and performance of the storage device. In addition, the existing wear leveling strategies lack a dynamic adjustment mechanism and cannot be optimized according to the real-time state of all storage blocks in the disk, making it difficult to achieve an effective balance between wear leveling and write amplification.
[0004] Therefore, how to effectively reduce the write amplification effect while balancing the wear distribution of storage blocks has become an important problem that needs to be solved urgently. Summary of the Invention
[0005] In view of this, an embodiment of the present application provides a storage block management method, apparatus, storage device, and storage medium, which can effectively solve the problems of uneven wear of storage blocks, serious write amplification effect, limited service life of storage devices, and insufficient performance stability in the prior art.
[0006] In a first aspect, an embodiment of the present application provides a storage block management method, including:
[0007] According to the status of each storage block in the storage device, each of the storage blocks is divided into a corresponding type of storage pool, and the types of the storage pool include a used storage block pool, a first free storage block pool, a second free storage block pool, and a high wear storage block pool;
[0008] In response to a free storage block request, select the first storage block with the highest number of erase times from the first free storage block pool for use;
[0009] If the status of the first storage block becomes the used state, divide the first storage block into the used storage block pool until it is re-divided into the first free storage block pool after performing garbage collection;
[0010] If there is a second storage block in the first free storage block pool whose number of erase times exceeds a first preset threshold, divide the second storage block into the high wear storage block pool to perform wear leveling.
[0011] In some embodiments, the method further includes:
[0012] If the number of erase times of the storage block with the smallest number of erase times in the first free storage block pool is equal to a second preset threshold, move all the storage blocks in the first free storage block pool to the second free storage block pool, and re-apply for a preset number of new storage blocks from the second free storage block pool and divide them into the first free storage block pool.
[0013] In some embodiments, the step of dividing each of the storage blocks into a corresponding type of storage pool according to the status of each storage block in the storage device includes:
[0014] If the current storage block is in the used state, divide the current storage block into the used storage block pool;
[0015] If the current storage block is in the free state and the number of erase times is less than the first preset threshold, divide the current storage block into the first free storage block pool;
[0016] If the minimum number of erase times of all storage blocks in the first free storage block pool is equal to the second preset threshold, divide all the storage blocks in the first free storage block pool into the second free storage block pool;
[0017] When the number of erasures of the current storage block in the first free storage block pool exceeds the first preset threshold, move the storage block out of the first free storage block pool and divide it into the high wear storage block pool.
[0018] In some embodiments, the dividing the first storage block into the used storage block pool until it is re-divided into the first free storage block pool after performing garbage collection operations includes:
[0019] When the amount of invalid data of the first storage block in the used storage block pool reaches a preset threshold, or when the number of available storage blocks in the first free storage block pool is lower than a preset capacity threshold, trigger the garbage collection operation;
[0020] In the garbage collection operation, clear the invalid data in the first storage block, restore the first storage block to the free state, and re-divide the cleared first storage block into the first free storage block pool.
[0021] In some embodiments, the applying for a preset number of new storage blocks from the second free storage block pool and dividing them into the first free storage block pool includes:
[0022] Sort the storage blocks in the second free storage block pool in ascending order according to the number of erasures;
[0023] According to the sorting result, screen out the storage blocks whose number of erasures meets the preset screening conditions as target storage blocks;
[0024] Apply for a preset number of new storage blocks from the target storage blocks and divide the applied new storage blocks into the first free storage block pool.
[0025] In some embodiments, the if there is a second storage block in the first free storage block pool whose number of erasures exceeds the first preset threshold, dividing the second storage block into the high wear storage block pool to perform wear leveling operations includes:
[0026] Real-time detect the number of erasures of the storage blocks in the first free storage block pool. When it is detected that there is a second storage block in the first free storage block pool whose number of erasures exceeds the first preset threshold, remove the second storage block from the first free storage block pool and divide it into the high wear storage block pool;
[0027] In the high wear storage block pool, select the storage block with the smallest number of erasures as the source block, select the storage block with the largest number of erasures as the target block, and migrate the data in the source block to the target block;
[0028] After the data migration is completed, update the erasure count of the source block, and dynamically adjust the first preset threshold and the second preset threshold.
[0029] In some embodiments, the first preset threshold is determined by adding the minimum erasure count of the storage blocks in the storage device to the second preset threshold; the second preset threshold is dynamically set according to the wear distribution state and wear leveling strategy of the storage blocks in the storage device.
[0030] In a second aspect, an embodiment of the present application provides a storage block management device, including:
[0031] A storage pool partitioning module, configured to partition each of the storage blocks into a corresponding type of storage pool according to the states of the storage blocks in the storage device, where the types of the storage pools include an in-use storage block pool, a first free storage block pool, a second free storage block pool, and a high-wear storage block pool;
[0032] A request response module, configured to respond to a free storage block request, and select a first storage block with the highest erasure count from the first free storage block pool for use;
[0033] A storage block partitioning module, configured to, if the state of the first storage block becomes an in-use state, partition the first storage block into the in-use storage block pool, and re-partition it into the first free storage block pool after performing a garbage collection operation;
[0034] A wear leveling execution module, configured to, if there is a second storage block in the first free storage block pool whose erasure count exceeds the first preset threshold, partition the second storage block into the high-wear storage block pool to perform a wear leveling operation.
[0035] In a third aspect, an embodiment of the present application provides a storage device, where the storage device includes a processor and a memory, the memory stores a computer program, and the processor is configured to execute the computer program to implement the storage block management method in the first aspect above.
[0036] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where when the computer program is executed on a processor, the storage block management method in the first aspect above is implemented.
[0037] The embodiments of the present application have the following beneficial effects:
[0038] The storage block management method of the present application divides each storage block in the storage device into corresponding types of storage pools according to its status, achieving efficient storage block management. When a request for a free storage block is received, the storage block with the highest number of erasure counts is selected from the first free storage block pool for use, ensuring that high-wear blocks are preferentially utilized and preventing low-wear blocks from being overused, thereby extending the overall service life of the storage blocks. If the status of the selected storage block changes to the used state, it is promptly divided into the used storage block pool to ensure the orderly management of storage resources. After performing the garbage collection operation, the storage blocks are re-divided into the first free storage block pool to maintain the dynamic balance of the storage blocks in the pool. In addition, when there are storage blocks in the first free storage block pool with the number of erasure counts exceeding the first preset threshold, they are divided into the high-wear storage block pool to perform wear leveling operations, effectively preventing a single storage block from failing prematurely due to frequent erasures and balancing the wear distribution of all storage blocks across the board. The storage block management method of the present application not only effectively alleviates the problem of uneven wear of storage blocks, reduces the write amplification effect, but also significantly improves the service life and performance stability of the storage device, ensuring the reliability and efficiency of data storage. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] To more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application and should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can also be obtained based on these drawings without creative efforts.
[0040] Figure 1 FIG. shows a flowchart of a storage block management method according to an embodiment of the present application;
[0041] Figure 2 FIG. shows a schematic diagram of storage block division in a storage block management method according to an embodiment of the present application;
[0042] Figure 3 FIG. shows a schematic structural diagram of a storage block management device according to an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0043] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments.
[0044] The components of the embodiments of the present application generally described and shown in the drawings herein may be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0045] Hereinafter, the terms "including", "having" and their cognates that can be used in various embodiments of the present application are intended only to indicate specific features, numbers, steps, operations, elements, components or a combination of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or a combination of the foregoing items or increasing the possibility of one or more features, numbers, steps, operations, elements, components or a combination of the foregoing items. In addition, the terms "first", "second", "third" and the like are only used to distinguish descriptions and cannot be understood as indicating or implying relative importance.
[0046] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present application belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present application.
[0047] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0048] Considering the problems of uneven wear of storage blocks, serious write amplification effect, limited service life of storage devices and insufficient performance stability in the prior art, a storage block management method is proposed. By dynamically monitoring the number of erase times and status of storage blocks, storage blocks are divided into corresponding storage pools and adjusted in real time according to their usage. Specifically, the utilization rate of storage blocks is optimized by preferentially selecting storage blocks with higher erase times from the first free storage block pool for use, and dynamically adjusting the storage pool to which they belong when the status changes; in addition, when the number of erase times of a storage block exceeds the set threshold, it is divided into a high-wear storage block pool and a wear leveling operation is performed, which effectively balances the wear distribution of storage blocks and reduces the write amplification effect, thereby improving the service life and performance stability of storage devices.
[0049] Figure 1The figure shows a flowchart of a storage block management method according to an embodiment of the present application. Exemplarily, the storage block management method includes the following steps:
[0050] Step S100, according to the status of each storage block in the storage device, divide each storage block into a corresponding type of storage pool. The types of storage pools include an in-use storage block pool, a first free storage block pool, a second free storage block pool, and a high wear storage block pool.
[0051] Exemplarily, based on the status of each storage block (such as whether it is in use, whether it is free, or the wear condition, etc.), divide the storage blocks into four storage pools with different functions to optimize storage management. Specifically, it includes the following types of storage pools:
[0052] In-use storage block pool (close block pool): Store the currently used storage blocks, and these blocks may be selected as source blocks for garbage collection (GC) in the future.
[0053] First free storage block pool (free array): Store the blocks with a smaller number of erase times selected from all free blocks, and preferentially select the storage blocks with a higher number of erase times from it when allocating free blocks.
[0054] Second free storage block pool (free block pool): Contain the remaining free storage blocks, which are supplementary resources for the first free storage block pool. The free block pool stores all free storage blocks that have not yet entered the free array. When the free array needs to be updated, the storage block with the lowest number of erase times will be selected from the free block pool and added to the free array.
[0055] High wear storage block pool (Wear Leveling pool): Store the storage blocks whose number of erase times exceeds a preset threshold. These blocks are relatively severely worn and are used to perform the wear leveling (WL) operation. By migrating the data of these blocks to the blocks with a lower number of erase times, the global wear is balanced.
[0056] This division method helps to achieve wear leveling and efficient utilization of resources by hierarchically managing various storage blocks, thereby extending the service life of the storage device and improving the overall performance of storage operations.
[0057] In an alternative embodiment, in step S100, according to the status of each storage block in the storage device, dividing each storage block into a corresponding type of storage pool includes:
[0058] Step S110, if the current storage block is in the used state, divide the current storage block into the used storage block pool.
[0059] Exemplarily, when a storage block in the storage device is allocated and in the used state, remove the storage block from the original storage pool (e.g., the first free storage block pool or the second free storage block pool), and divide it into the used storage block pool (close block pool) for management. In the used storage block pool, the storage block will continue to store valid data and its usage status will be monitored until the garbage collection (GC) trigger condition is met, and then a garbage collection operation will be performed on the storage block to clean up the invalid data. By dividing the used storage block into the used storage block pool, the management logic of free blocks and used blocks can be effectively distinguished, thereby optimizing resource allocation and wear leveling, and improving the overall performance and lifespan of the storage device.
[0060] Step S120, if the current storage block is in the free state and the number of erasure times is less than the first preset threshold, divide the current storage block into the first free storage block pool.
[0061] Exemplarily, when a storage block in the storage device is in the free state (not allocated and available for allocation), judge whether it is suitable to be divided into the first free storage block pool (free array) according to its number of erasure times (PE). If the number of erasure times of the storage block is less than the first preset threshold (minimum PE + WL GC threshold), where the WL GC threshold refers to the wear leveling threshold exceeding the limit and the garbage collection threshold exceeding the limit, then divide the storage block into the first free storage block pool for management. The first free storage block pool is mainly used to preferentially manage free blocks with fewer erasure times, so as to use these low-wear blocks during subsequent allocation, delay their premature entry into the high-wear state, reduce the write amplification effect, and improve the overall service life and performance of the storage device. This operation ensures the efficient utilization of free storage blocks and provides basic support for subsequent dynamic wear leveling and garbage collection.
[0062] Step S130, if the minimum number of erasure times of all storage blocks in the first free storage block pool is equal to the second preset threshold, divide all storage blocks in the first free storage block pool into the second free storage block pool.
[0063] Exemplarily, when it is detected that the minimum number of erasures of the storage blocks in the first free storage block pool (free array) is equal to the second preset threshold (WL GC threshold), that is, when the wear leveling threshold and the garbage collection threshold are reached respectively, a dynamic adjustment operation is triggered to move all the storage blocks in the free array back to the second free storage block pool (free block pool). Subsequently, a preset number (for example, 58 blocks) of storage blocks with the minimum number of erasures are re-screened from the free block pool and filled into the free array for management. The advantage of this mechanism is that the number of erasures (PE) of the storage blocks can be used in an orderly manner in batches of 58 blocks each until the number of erasures of these blocks reaches the WL GC threshold, that is, both the wear leveling threshold and the garbage collection threshold are reached. By preferentially allocating blocks with a larger number of erasures for use, the situation of cold data being written into blocks with a low number of erasures is effectively avoided in a certain strategy, thereby reducing the triggering frequency of the wear leveling (Wear Leveling - WL) operation, significantly optimizing the write amplification effect, effectively extending the overall service life of the storage device and improving the performance.
[0064] Step S140, if the number of erasures of the current storage block in the first free storage block pool exceeds the first preset threshold, move the storage block out of the first free storage block pool and divide it into the high wear storage block pool.
[0065] Exemplarily, when it is detected that the number of erasures of the current storage block in the first free storage block pool (free array) exceeds the first preset threshold (minimum PE + WL GC threshold), that is, when both the wear leveling threshold and the garbage collection threshold are reached, a dynamic migration operation is triggered to remove the storage block from the first free storage block pool and divide it into the high wear storage block pool (WearLeveling pool) for management. The high wear storage block pool is a small pool with a limited capacity (for example, a depth of 4) used to store blocks with a higher number of erasures, and these blocks will be preferentially processed in the subsequent wear leveling (Wear Leveling - WL) operation. Specifically, by migrating the data of the block with the minimum PE in the high wear storage block pool to the block with the maximum number of erasures in the whole disk, the number of erasures of the block with the minimum PE is increased, the wear distribution of the whole disk is balanced, and the WL GC wear leveling threshold and the garbage collection threshold are dynamically increased to adapt to future operations. This mechanism can not only effectively alleviate the problem of uneven wear of blocks, but also reduce the write amplification effect, thereby improving the service life and stability of the storage device.
[0066] In an optional implementation manner, the first preset threshold is determined by adding the minimum number of erasures of the storage blocks in the storage device to the second preset threshold; the second preset threshold is dynamically set according to the wear distribution state and the wear leveling strategy of the storage blocks in the storage device.
[0067] Exemplarily, the first preset threshold is calculated by adding the minimum number of erasures (minimum PE) of all storage blocks in the storage device to the second preset threshold (WL GC threshold). The minimum number of erasures represents the number of erasures of the least worn block in the current entire disk, and is used to reflect the lowest wear state of the block; the second preset threshold (WL GC threshold) is dynamically set according to the wear leveling strategy of the storage device to ensure that the wear leveling operation (Wear Leveling - WL) is triggered under appropriate conditions. Through this calculation method, the first preset threshold can dynamically adapt to the real - time wear state of the storage device, ensure the preferential use of blocks with low erasure counts, and avoid the over - use of blocks with high erasure counts. The dynamic adjustment of the second preset threshold (WL GC threshold) can flexibly optimize the trigger conditions according to the distribution of the number of erasures of the entire disk, further improve the efficiency of storage block management, and extend the overall service life of the device.
[0068] Step S200, in response to a request for an idle storage block, select the first storage block with the highest number of erasures from the first idle storage block pool for use.
[0069] Exemplarily, when the storage device receives a request for the allocation of an idle storage block, it selects the storage block with the highest number of erasures from the first idle storage block pool (free array) as the first storage block for allocation and use. The purpose of this allocation strategy is to preferentially use the first storage block with the highest number of erasures in the first idle storage block pool while avoiding blocks with smaller erasure counts from entering the used state prematurely, thereby effectively delaying the wear growth of blocks with low erasure counts, reducing the write amplification effect, and further optimizing the wear balance of the storage device, improving the overall life and performance.
[0070] Step S300, if the status of the first storage block changes to the used state, divide the first storage block into the used storage block pool until it is re - divided into the first idle storage block pool after the garbage collection operation is performed.
[0071] Exemplarily, when the first storage block allocated from the first idle storage block pool (free array) is actually used, its status is marked as the used state and divided into the used storage block pool (close block pool) for management. In the used storage block pool, the first storage block will continuously store data until the trigger condition for the garbage collection (GarbageCollection - GC) operation is met. After the garbage collection operation GC is performed, the invalid data in the storage block is cleared, the status is restored to the idle state, and it is re - divided back into the first idle storage block pool (free array) for subsequent allocation and use. This management process effectively optimizes the resource utilization rate of the storage block through the dynamic flow of the status, and at the same time provides a good foundation for wear balance.
[0072] In an alternative embodiment, in step S300, dividing the first storage block into the used storage block pool until it is re-divided into the first free storage block pool after performing a garbage collection operation includes:
[0073] When the amount of invalid data in the first storage block in the used storage block pool reaches a preset threshold, or the number of available storage blocks in the first free storage block pool is lower than a preset capacity threshold, a garbage collection operation is triggered. In the garbage collection (GarbageCollection-GC) operation, the invalid data in the first storage block is cleared, the first storage block is restored to the free state, and the cleaned first storage block is re-divided into the first free storage block pool.
[0074] Exemplarily, when it is detected that the amount of invalid data in a certain storage block in the used storage block pool (close block pool) reaches a preset data threshold (for example, the proportion of invalid data in the total capacity of the storage block reaches a certain percentage), or when it is detected that the number of available storage blocks in the first free storage block pool (free array) is lower than a preset capacity threshold (for example, lower than 10% of the total capacity of the storage blocks in the first free storage block pool), a garbage collection operation (Garbage Collection-GC) is triggered.
[0075] In the garbage collection operation, the storage block containing invalid data is preferentially selected. After migrating the valid data therein to other free blocks, the invalid data in the storage block is cleared to restore it to the free state. The recycled storage block will be re-divided into the first free storage block pool to meet the subsequent block allocation requirements. Through this dynamic management mechanism, storage resources can be effectively released, the utilization efficiency of storage blocks can be improved, and at the same time, the normal operation of the storage device can be ensured when resources are scarce or the inefficiency of data is high, thereby extending the service life of the device and optimizing the overall performance.
[0076] Step S400, if there is a second storage block in the first free storage block pool whose erasure count exceeds a first preset threshold, divide the second storage block into the high-wear storage block pool to perform a wear leveling operation.
[0077] Exemplarily, when the number of erasures of some storage blocks (i.e., the second storage blocks) in the first free storage block pool (free array) exceeds a preset first preset threshold (minimum PE + WL GC threshold), these storage blocks are identified as high-wear blocks and are partitioned from the first free storage block pool to the high-wear storage block pool (Wear Leveling pool). In the high-wear storage block pool, these blocks will participate in the garbage collection operation (Garbage Collection - GC). By migrating the data on the high-wear blocks to blocks with a lower number of erasures, the load on the high-wear blocks is reduced, the wear distribution of the storage device is further optimized, thereby extending the overall service life of the storage device and improving its reliability.
[0078] In an alternative embodiment, in step S400, if there are second storage blocks in the first free storage block pool whose number of erasures exceeds the first preset threshold, partitioning the second storage blocks into the high-wear storage block pool to perform wear leveling operations includes:
[0079] Real-time detect the number of erasures of the storage blocks in the first free storage block pool. When it is detected that there are second storage blocks in the first free storage block pool whose number of erasures exceeds the first preset threshold, remove the second storage blocks from the first free storage block pool and partition them into the high-wear storage block pool.
[0080] Exemplarily, perform real-time detection on the storage blocks in the first free storage block pool (free array), and judge their current status by monitoring the number of erasures (PE) of each storage block. When it is detected that there are second storage blocks in the first free storage block pool whose number of erasures exceeds the first preset threshold ((minimum PE + WL GC threshold)), trigger a dynamic adjustment operation, remove the storage block from the first free storage block pool, and partition it into the high-wear storage block pool (Wear Leveling pool) for dedicated management. The storage blocks in the high-wear storage block pool will become the target blocks for subsequent wear leveling (Wear Leveling - WL) operations to optimize the erasure balance distribution of the entire disk through means such as data migration. This real-time detection mechanism can dynamically monitor the wear condition of the storage blocks, timely adjust the partitioning status of the storage blocks, thereby effectively avoiding further overuse of high-wear blocks and enhancing the overall life and reliability of the storage device.
[0081] In the high-wear storage block pool, select the storage block with the minimum number of erasures as the source block, select the storage block with the maximum number of erasures as the target block, and migrate the data in the source block to the target block.
[0082] Exemplarily, after the storage blocks are divided into a high wear-leveling pool, an analysis is performed based on the number of erasures (PE) of the storage blocks across the entire disk to perform a wear-leveling (WL) operation. Specifically, first, the storage block with the minimum number of erasures is selected from all the storage blocks on the disk as the source block, and its data is used as the source data for migration. At the same time, the storage block with the maximum number of erasures is selected as the target block to store the data of the source block. By migrating the data of the source block to the target block, the number of erasures of the source block will be increased, thereby reducing the gap in the number of erasures across the entire disk and achieving the purpose of optimizing the wear distribution. This block selection mechanism based on the number of erasures across the entire disk can effectively alleviate the overuse of high wear blocks, extend the service life of the storage device, and improve the overall stability of the storage system.
[0083] After the data migration is completed, update the number of erasures of the source block and dynamically adjust the second preset threshold.
[0084] Exemplarily, after the data migration operation is completed, update the status of the source block and the target block. First, increment the number of erasures (PE) of the source block by 1 to reflect the change in the number of erasure operations that occurred during the data migration process, and at the same time update its status to an idle block that can be reallocated. Second, dynamically adjust the second preset threshold (WL GC threshold) according to the current erasure count distribution across the entire disk to ensure that the trigger condition for the next wear-leveling (WL) operation is more reasonable. Through this dynamic adjustment mechanism, the threshold setting can be optimized after each wear-leveling operation, gradually narrowing the gap in the number of erasures between storage blocks, balancing the wear of storage blocks, and thus effectively extending the service life of the storage device and improving performance stability.
[0085] In an alternative embodiment, the storage block management method of the present application further includes:
[0086] If the number of erasures of the storage block with the minimum number of erasures in the first idle storage block pool is equal to the second preset threshold, move all the storage blocks in the first idle storage block pool to the second idle storage block pool, and then re-apply for a preset number of new storage blocks from the second idle storage block pool and divide them into the first idle storage block pool.
[0087] Exemplarily, during the block management process of a storage device, when the number of erasures of the storage block with the minimum number of erasures in the first free storage block pool (free array) is equal to the second preset threshold (WL GC threshold), all the storage blocks in the first free storage block pool are moved back to the second free storage block pool (free block pool), and the resources of the first free storage block pool are released. Subsequently, storage blocks (e.g., 58 blocks) are re-screened from the second free storage block pool and divided into the first free storage block pool. The purpose of this operation is to dynamically adjust the block group in the first free storage block pool to ensure that it is always composed of blocks with a lower number of erasures, thereby optimizing the block allocation order, delaying the wear of blocks with a lower number of erasures, and further improving the lifespan and wear leveling of the storage device. This mechanism ensures the dynamicity and flexibility of storage block management and helps to avoid the problem of excessive aging caused by uneven distribution of block erasure times.
[0088] In an alternative embodiment, applying a preset number of new storage blocks from the second free storage block pool and dividing them into the first free storage block pool includes:
[0089] Sort the storage blocks in the second free storage block pool in ascending order of the number of erasures.
[0090] Exemplarily, as Figure 2 shown, all the storage blocks in the second free storage block pool (free block pool) are sorted in ascending order of their number of erasures (PE). The sorting operation is based on the wear state of the storage blocks, with blocks having a smaller number of erasures being preferentially arranged at the front of the list, and blocks having a larger number of erasures being arranged at the back of the list. Through this sorting method, blocks with a smaller number of erasures can be quickly identified and screened to meet the requirements of subsequent resource allocation. For example, low-wear blocks are preferentially allocated to the first free storage block pool (free array). This operation optimizes the usage order of the storage blocks, helps to achieve wear leveling (Wear Leveling - WL), extends the overall service life of the storage device, and provides basic data support for subsequent screening and block management operations.
[0091] According to the sorting result, screen out the storage blocks whose number of erasures meets the preset screening conditions as the target storage blocks.
[0092] Exemplarily, after sorting the storage blocks in the second free block pool in ascending order of the number of erasures (PE), a screening operation is performed on the sorted result according to a preset screening condition. The screening condition may include that the number of erasures is less than a certain threshold (for example, PE ≤ min + 100, where min is the minimum number of erasures of the current storage block), to ensure that the number of erasures of the target storage block is within a specified range. The result of the screening operation is to extract the storage blocks that meet the screening condition as the target storage block set, providing suitable candidate storage blocks for subsequent allocation and management operations. Through this screening mechanism, storage blocks with too high a number of erasures can be effectively prevented from entering the low wear block pool, thereby further optimizing the usage strategy of storage blocks and enhancing the service life and performance of the storage device.
[0093] Apply for a preset number of new storage blocks from the target storage blocks and divide the applied new storage blocks into the first free block pool.
[0094] Exemplarily, apply for a preset number of new storage blocks (for example, 58 blocks) from the target storage block set and divide these newly applied storage blocks into the first free array. During the operation, first, according to the sorting result of the number of erasures (PE) of the target storage blocks, select the blocks in sequence, ensuring that the storage blocks with the minimum number of erasures are selected first until the preset number (for example, 58 blocks) is reached. After the selection is completed, these newly applied storage blocks are filled into the first free array for subsequent storage resource allocation. Through this mechanism, it can be ensured that blocks with a lower number of erasures are preferentially used, while preventing low-erasure blocks from being worn prematurely, extending the overall life of the storage device, and reducing the risk of cold data being written to low-erasure blocks, thereby optimizing storage performance and resource utilization efficiency.
[0095] The storage block management method according to the embodiments of the present application dynamically divides storage blocks into different types of storage pools, and flexibly allocates and transfers them according to parameters such as the state of the blocks and the number of erasures. First, by introducing a first free storage block pool (free array), storage blocks with a smaller number of erasures are effectively screened out for priority management, and blocks with a higher number of erasures are selected during allocation, thereby avoiding premature wear of blocks with a low number of erasures, optimizing the wear distribution, and extending the overall life of the storage device. Second, the combination of the used storage block pool (close block pool) and the garbage collection mechanism realizes the efficient recycling and reallocation of storage blocks, further improving the utilization efficiency of storage blocks. In addition, by performing garbage collection (Garbage Collection - GC) operations on storage blocks whose number of erasures exceeds a preset threshold through the high wear storage block pool (WearLeveling pool), the over - aging of high - wear blocks is effectively prevented, and the write amplification effect caused by frequent triggering of wear leveling is reduced. It not only achieves a good balance between wear leveling and write amplification optimization, but also significantly improves the reliability, service life, and performance of the storage system.
[0096] Figure 3 FIG. shows a schematic structural diagram of a storage block management device according to an embodiment of the present application. Exemplarily, the device includes:
[0097] A storage block pool division module 31, configured to divide each of the storage blocks into a corresponding type of storage pool according to the state of each storage block in the storage device, where the types of the storage pools include a used storage block pool, a first free storage block pool, a second free storage block pool, and a high wear storage block pool;
[0098] A request response module 32, configured to respond to a free storage block request, and select a first storage block with the highest number of erasures from the first free storage block pool for use;
[0099] A storage block division module 33, configured to, if the state of the first storage block becomes a used state, divide the first storage block into the used storage block pool, and re - divide it into the first free storage block pool after performing a garbage collection operation;
[0100] A wear leveling execution module 34, configured to, if there is a second storage block in the first free storage block pool whose number of erasures exceeds a first preset threshold, divide the second storage block into the high wear storage block pool to perform a wear leveling operation.
[0101] It can be understood that the device in this embodiment corresponds to the storage block management method in the above - mentioned embodiment, and the optional items in the above - mentioned embodiment are also applicable to this embodiment, so they will not be described repeatedly here.
[0102] The present application also provides a storage device. For example, a solid-state drive, an embedded storage device eMMC, UFS, etc. Exemplarily, the storage device includes a processor and a memory. Among them, the memory stores a computer program, and the processor executes the computer program to enable the storage device to perform the functions of the above-mentioned method or each module in the above-mentioned device.
[0103] Among them, the processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including at least one of a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc., and can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application.
[0104] The memory can be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc. Among them, the memory is used to store a computer program, and after receiving an execution instruction, the processor can execute the computer program accordingly.
[0105] The present application also provides a computer-readable storage medium for storing the computer program used in the above storage device. For example, the computer-readable storage medium can include, but is not limited to: various media that can store program codes such as a USB flash drive, 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 disc.
[0106] In several embodiments provided in this application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and structural diagrams in the drawings show the possible architectures, functions, and operations of devices, methods, and computer program products according to multiple embodiments of this application. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the blocks can occur in a different order than that marked in the drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the structural diagram and / or flowchart, as well as the combination of blocks in the structural diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0107] In addition, each functional module or unit in various embodiments of this application can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.
[0108] If the above functions are implemented in the form of software functional modules and sold or used as an independent product, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a storage device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application.
[0109] The above is only the specific implementation manner of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art within the technical scope disclosed in this application can easily think of changes or substitutions, which should all be covered by the protection scope of this application.
Claims
1. A storage block management method, characterized in that The method includes: Dividing each storage block in a storage device into a corresponding type of storage pool according to the state of each storage block in the storage device, where the types of the storage pools include an in-use storage block pool, a first free storage block pool, a second free storage block pool, and a high wear storage block pool; Among them, the in-use storage block pool is used to store the currently used storage blocks; the first free storage block pool is used to store the storage blocks with a smaller number of erasure times selected from all free storage blocks, and preferentially select the storage blocks with a higher number of erasure times when allocating free storage blocks; the second free storage block pool is used to store the remaining free storage blocks that do not enter the first free storage block pool, and preferentially select the storage block with the lowest number of erasure times when the first free storage block pool is updated; the high wear storage block pool is used to store the storage blocks with the number of erasure times exceeding a preset threshold; The dividing each storage block in the storage device into a corresponding type of storage pool according to the state of each storage block in the storage device includes: If the state of the current storage block is the in-use state, dividing the current storage block into the in-use storage block pool; If the state of the current storage block is the free state and the number of erasure times is less than a first preset threshold, dividing the current storage block into the first free storage block pool; If the minimum number of erasure times of all storage blocks in the first free storage block pool is equal to a second preset threshold, dividing all storage blocks in the first free storage block pool into the second free storage block pool; If the number of erasure times of the current storage block in the first free storage block pool exceeds the first preset threshold, moving the storage block out of the first free storage block pool and dividing it into the high wear storage block pool; Responding to a free storage block request, selecting the first storage block with the highest number of erasure times from the first free storage block pool for use; If the state of the first storage block becomes the in-use state, dividing the first storage block into the in-use storage block pool until it is re-divided into the first free storage block pool after performing a garbage collection operation; If there is a second storage block with the number of erasure times exceeding the first preset threshold in the first free storage block pool, dividing the second storage block into the high wear storage block pool to perform a wear leveling operation, including: after the data migration is completed, updating the number of erasure times of the source block, and dynamically adjusting the first preset threshold and the second preset threshold.
2. The storage block management method according to claim 1, wherein The method further includes: If the number of erasure times of the storage block with the minimum number of erasure times in the first free storage block pool is equal to the second preset threshold, moving all storage blocks in the first free storage block pool to the second free storage block pool, and re-applying for a preset number of new storage blocks from the second free storage block pool and dividing them into the first free storage block pool.
3. The storage block management method according to claim 1, wherein, The dividing the first storage block into the in-use storage block pool until it is re-divided into the first free storage block pool after performing a garbage collection operation includes: When the amount of invalid data of the first storage block in the in-use storage block pool reaches a preset threshold, or the number of available storage blocks in the first free storage block pool is lower than a preset capacity threshold, triggering the garbage collection operation; In the garbage collection operation, invalid data in the first storage block is cleared, the first storage block is restored to the free state, and the cleared first storage block is re-partitioned into the first free storage block pool.
4. The storage block management method according to claim 2, characterized in that The applying for a preset number of new storage blocks from the second free storage block pool and partitioning them into the first free storage block pool includes: Sorting the storage blocks in the second free storage block pool in ascending order of the number of erasures; According to the sorting result, screening out the storage blocks whose number of erasures meets the preset screening condition as target storage blocks; Applying for a preset number of new storage blocks from the target storage blocks and partitioning the applied new storage blocks into the first free storage block pool.
5. The storage block management method according to claim 1, characterized in that The if there is a second storage block in the first free storage block pool whose number of erasures exceeds the first preset threshold, partitioning the second storage block into the high-wear storage block pool to perform wear leveling operations, includes: Real-time detecting the number of erasures of the storage blocks in the first free storage block pool. When it is detected that there is a second storage block in the first free storage block pool whose number of erasures exceeds the first preset threshold, removing the second storage block from the first free storage block pool and partitioning it into the high-wear storage block pool; In the high-wear storage block pool, selecting the storage block with the smallest number of erasures as the source block, selecting the storage block with the largest number of erasures as the target block, and migrating the data in the source block to the target block.
6. The storage block management method according to claim 1 or 2, characterized in that, The first preset threshold is determined by adding the minimum number of erasures of the storage blocks in the storage device to the second preset threshold; the second preset threshold is dynamically set according to the wear distribution state and wear leveling strategy of the storage blocks in the storage device.
7. A storage block management device, characterized in that, The device includes: A storage pool partitioning module, configured to partition each storage block into a corresponding type of storage pool according to the state of each storage block in the storage device. The types of the storage pools include an in-use storage block pool, a first free storage block pool, a second free storage block pool, and a high-wear storage block pool. Among them, the in-use storage block pool is used to store the currently used storage blocks; the first free storage block pool is used to store the storage blocks with a smaller number of erasures selected from all free storage blocks, and preferentially selects the storage blocks with a higher number of erasures when allocating free storage blocks; the second free storage block pool is used to store the remaining free storage blocks that have not entered the first free storage block pool, and preferentially selects the storage block with the lowest number of erasures when the first free storage block pool is updated; the high-wear storage block pool is used to store the storage blocks whose number of erasures exceeds the preset threshold; The partitioning each storage block into a corresponding type of storage pool according to the state of each storage block in the storage device includes: If the current storage block is in the used state, partitioning the current storage block into the in-use storage block pool; If the current storage block is in the free state and the number of erasures is less than the first preset threshold, partitioning the current storage block into the first free storage block pool; When the minimum number of erasures of all storage blocks in the first free storage block pool is equal to the second preset threshold, all storage blocks in the first free storage block pool are divided into the second free storage block pool; When the number of erasures of the current storage block in the first free storage block pool exceeds the first preset threshold, the storage block is removed from the first free storage block pool and divided into the high wear storage block pool; A request response module, configured to respond to a free storage block request, and select a first storage block with the highest number of erasures from the first free storage block pool for use; A storage block division module, configured to, if the status of the first storage block becomes the used state, divide the first storage block into the used storage block pool, and re-divide it into the first free storage block pool after performing garbage collection operations; A wear leveling execution module, configured to, if there is a second storage block in the first free storage block pool whose number of erasures exceeds the first preset threshold, divide the second storage block into the high wear storage block pool to perform wear leveling operations, including: after data migration is completed, updating the number of erasures of the source block, and dynamically adjusting the first preset threshold and the second preset threshold.
8. A storage device, characterized in that, The storage device includes a processor and a memory, the memory stores a computer program, and the processor is configured to execute the computer program to implement the storage block management method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, It stores a computer program, and when the computer program is executed on a processor, it implements the storage block management method according to any one of claims 1-6.
Citation Information
Patent Citations
Method for optimizing RAID5 / 6 writing performance by means of invalid data of SSD
CN103631536A
Solid-state storage device garbage collection method and solid-state storage device
CN109144885A