Storage block management method and device, storage equipment and storage medium

By dynamically dividing memory blocks into different types of storage pools and real-time adjustments based on their status and erases, the problems of uneven wear and write amplification effects are solved, extending the service life of the storage device and improving performance stability.

CN119847453AActive Publication Date: 2025-04-18BIWIN STORAGE TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510329319.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-20
Publication Date
2025-04-18
Estimated Expiration
2045-03-20

AI Technical Summary

Technical Problem

In actual application, the existing wear balance technology has problems such as uneven wear of memory blocks, serious write amplification effect, limited service life of storage devices, and insufficient performance stability.

Method used

By dividing each memory block in the storage device into the corresponding type of storage pool according to the status of each memory block in the storage device, it is adjusted in real time according to its usage. Specific measures include selecting the storage block with the highest number of erased times from the first free storage block pool for use, dividing it into the used storage block pool in time, and re-dividing it back to the first free storage block pool after performing a garbage collection operation. When the number of erasings of a memory block exceeds a preset threshold, it is divided into a high wear memory block pool to perform wear equalization operations.

Benefits of technology

Effectively balance the wear distribution of memory blocks, reduce the write amplification effect, extend the service life of the storage device and improve performance stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119847453A_ABST
    Figure CN119847453A_ABST
Patent Text Reader

Abstract

The invention relates to the field of storage, and discloses a storage block management method and device, storage equipment and a storage medium, and the method comprises the steps: dividing storage blocks into storage pools of corresponding types according to the state of each storage block in the storage equipment, and responding to an idle storage block request; selecting a first storage block with the highest erasing frequency from the first free storage block pool for use, if the state of the first storage block is changed into a used state, dividing the first storage block into a used storage block pool, and re-dividing the first storage block into the first free storage block pool until garbage collection operation is executed, and if the storage blocks with the erasure times exceeding a first preset threshold value exist in the first free storage block pool, dividing the storage blocks into a high-wear storage block pool to execute wear leveling operation. According to the storage block management method, abrasion distribution of the storage blocks can be effectively balanced, the write amplification effect is remarkably reduced, the utilization rate of the storage blocks is increased, meanwhile, the service life of the storage device is prolonged, and the stability of the storage device is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present 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 unit of NAND flash memory has the characteristics that the write and erase operations need to be performed in blocks, and the number of erases for each storage unit is limited. In actual use, the user data written by the host can usually be divided into two categories: hot data (data that will be frequently changed) and cold data (data that does not change for a long time). After the hot data is stored in the NAND flash memory, the original data in the storage block will be invalidated due to the frequent updates of the host, thereby triggering the erase operation; once the cold data is stored in the storage block, it may not be changed for a long time, causing the storage block where it is located to remain in a low erase state. In order to extend the service life of NAND flash memory devices, storage systems usually use wear leveling (WL) technology to move cold data to storage blocks with heavier wear to balance the distribution of erase times of storage blocks.

[0003] However, the existing wear leveling technology has many problems 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 is frequently updated, causing the storage blocks to wear out quickly, resulting in a serious uneven distribution of hot and cold data between storage blocks. Secondly, in order to solve the problem of uneven wear, wear leveling garbage collection (WL Garbage Collection-GC, 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 amount / host write data amount). The direct consequence of write amplification is a double decrease in the life and performance of storage devices. In addition, the existing wear leveling strategy lacks a dynamic adjustment mechanism and cannot be optimized according to the real-time status of the entire disk storage block, 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 issue that needs to be solved urgently. Summary of the invention

[0005] In view of this, the embodiments of the present application provide a storage block management method, apparatus, storage device and storage medium, which can effectively solve the problems of uneven wear of storage blocks, severe 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: According to the status of each storage block in the storage device, each storage block is divided into a storage pool of corresponding type, 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; In response to a free storage block request, selecting a first storage block with the highest number of erase times from the first free storage block pool for use; If the state of the first storage block changes to a used state, the first storage block is divided into the used storage block pool, and is not divided into the first free storage block pool again after a garbage collection operation is performed; If there is a second storage block in the first free storage block pool whose erasure times exceed a first preset threshold, the second storage block is divided into the high-wear storage block pool to perform a wear leveling operation.

[0007] In some embodiments, the method further comprises: 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, all storage blocks in the first free storage block pool are moved to the second free storage block pool, and a preset number of new storage blocks are applied for from the second free storage block pool to be allocated to the first free storage block pool.

[0008] In some embodiments, the dividing each storage block into a storage pool of a corresponding type according to the status of each storage block in the storage device includes: If the current storage block is in a used state, the current storage block is divided into a used storage block pool; If the state of the current storage block is an idle state and the number of erasures is less than a first preset threshold, the current storage block is divided into a first idle storage block pool; If the minimum erasure count 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 a second free storage block pool; If the number of erasures of the current storage block in the first free storage block pool exceeds a first preset threshold, the storage block is moved out of the first free storage block pool and allocated to the high-wear storage block pool.

[0009] In some embodiments, the dividing the first storage block into the used storage block pool until a garbage collection operation is performed and then the first free storage block pool is divided again, comprises: 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, 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 an idle state, and the cleared first storage block is reallocated to the first idle storage block pool.

[0010] In some embodiments, applying for a preset number of new storage blocks from the second free storage block pool to be allocated to the first free storage block pool includes: Sorting the storage blocks in the second free storage block pool from small to large according to the number of erasures; According to the sorting result, the storage blocks whose erasure times meet the preset screening condition are screened out as target storage blocks; A preset number of new storage blocks are applied for from the target storage blocks, and the applied new storage blocks are divided into the first free storage block pool.

[0011] In some embodiments, if there is a second storage block in the first free storage block pool whose number of erase times exceeds a first preset threshold, dividing the second storage block into the high wear storage block pool to perform a wear leveling operation includes: detecting the number of erasures of storage blocks in the first free storage block pool in real time, and when detecting that there is a second storage block in the first free storage block pool whose number of erasures exceeds a first preset threshold, removing the second storage block from the first free storage block pool and assigning the second storage block to the high-wear storage block pool; In the high-wear storage block pool, a storage block with the smallest number of erasures is selected as a source block, a storage block with the largest number of erasures is selected as a target block, and data in the source block is migrated to the target block; After the data migration is completed, the erasure count of the source block is updated, and the first preset threshold and the second preset threshold are dynamically adjusted.

[0012] In some embodiments, the first preset threshold is determined by adding the minimum number of erase times of the storage block 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 block in the storage device.

[0013] In a second aspect, an embodiment of the present application provides a storage block management device, including: A storage pool division module, used to divide each storage block into a corresponding type of storage pool according to the status of each storage block in the storage device, wherein 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; A request response module, used for responding to a free storage block request, and selecting a first storage block with the highest number of erasure times from the first free storage block pool for use; a storage block partitioning module, configured to partition the first storage block into the used storage block pool if the state of the first storage block changes to a used state, and then partition the first storage block into the first free storage block pool again after a garbage collection operation is performed; The wear leveling execution module is used to divide the second storage block into the high wear storage block pool to perform a wear leveling operation if there is a second storage block with an erasure count exceeding a first preset threshold in the first free storage block pool.

[0014] In a third aspect, an embodiment of the present application provides a storage device, the storage device comprising a processor and a memory, the memory storing a computer program, and the processor being used to execute the computer program to implement the storage block management method of the first aspect.

[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, and when the computer program is executed on a processor, the storage block management method of the first aspect is implemented.

[0016] The embodiments of the present application have the following beneficial effects: The storage block management method of the present application realizes efficient storage block management by dividing each storage block in the storage device into a storage pool of the corresponding type according to the state of each storage block. When a free storage block request is received, the storage block with the highest number of erases is selected from the first free storage block pool for use, ensuring that the high-wear block is used first and avoiding the overuse of the low-wear block, thereby extending the overall service life of the storage block. If the state of the selected storage block changes to the use 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 block is divided back to the first free storage block pool to maintain the dynamic balance of the storage blocks in the pool. In addition, when there is a storage block in the first free storage block pool whose number of erases exceeds the first preset threshold, it is divided into the high-wear storage block pool to perform a wear leveling operation, effectively preventing a single storage block from failing prematurely due to frequent erasure, and balancing the wear distribution of the entire disk storage block. The storage block management method of the present application not only effectively alleviates the problem of uneven wear of the storage block and 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

[0017] In order 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 certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 A flow chart of a storage block management method according to an embodiment of the present application is shown; Figure 2 A schematic diagram of storage block division in a storage block management method according to an embodiment of the present application is shown; Figure 3 A schematic structural diagram of a storage block management device according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0019] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.

[0020] 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.

[0021] Hereinafter, the terms "including", "having" and their cognates 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.

[0022] 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.

[0023] 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.

[0024] 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.

[0025] Figure 1 A flow chart of a storage block management method according to an embodiment of the present application is shown. Exemplarily, the storage block management method comprises the following steps: Step S100, according to the status of each storage block in the storage device, each storage block is divided into a corresponding type of storage pool, the types of 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.

[0026] Exemplarily, based on the status of each storage block (e.g., whether it is used, whether it is idle, or whether it is worn out, etc.), the storage blocks are divided into four storage pools with different functions to optimize storage management. Specifically, the storage pools include the following categories: Close block pool: stores currently used storage blocks, which may be selected as source blocks for garbage collection (GC) in the future.

[0027] The first free storage block pool (free array): stores blocks with smaller erase counts selected from all free blocks, and gives priority to selecting storage blocks with higher erase counts when allocating free blocks.

[0028] The second free block pool (free block pool): contains the remaining free blocks and is a supplementary resource for the first free block pool. The free block pool stores all free blocks that have not yet entered the free array. When the free array needs to be updated, the block with the lowest number of erases will be selected from the free block pool and added to the free array.

[0029] Wear Leveling pool: stores blocks whose erase counts exceed a preset threshold. These blocks are severely worn and are used to perform wear leveling (WL) operations. The global wear is balanced by migrating the data of these blocks to blocks with low erase counts.

[0030] This division method helps to achieve wear leveling and efficient use of resources through hierarchical management of various types of storage blocks, thereby extending the service life of storage devices and improving the overall performance of storage operations.

[0031] In an optional implementation, in step S100, according to the status of each storage block in the storage device, each storage block is divided into a storage pool of a corresponding type, including: Step S110: if the state of the current storage block is in use, the current storage block is divided into a used storage block pool.

[0032] Exemplarily, when a storage block in a storage device is allocated and in use, the storage block is removed from the original storage pool (for example, the first free storage block pool or the second free storage block pool) and divided into a 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 a garbage collection operation is performed on the storage block to clean up invalid data. By dividing the storage blocks in use 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 life of the storage device.

[0033] Step S120: if the state of the current storage block is an idle state and the number of erasures is less than a first preset threshold, the current storage block is divided into a first idle storage block pool.

[0034] Exemplarily, when a storage block in a storage device is in an idle state (not allocated for use and available for allocation), it is determined whether it is suitable for being allocated to the first free storage block pool (free array) based on its erase count (PE). If the erase count 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, the storage block is allocated to the first free storage block pool for management. The first free storage block pool is mainly used to give priority to the management of free blocks with a smaller erase count, so as to facilitate the use of these low-wear blocks in subsequent allocations, delay their premature entry into a high-wear state, and reduce the write amplification effect, thereby improving the overall service life and performance of the storage device. This operation ensures the efficient use of free storage blocks and provides basic support for subsequent dynamic wear leveling and garbage collection.

[0035] Step S130: if the minimum erasure count of all the storage blocks in the first free storage block pool is equal to the second preset threshold, all the storage blocks in the first free storage block pool are divided into the second free storage block pool.

[0036] Exemplarily, when it is detected that the minimum number of erase times of storage blocks in the first free storage block pool (free array) is equal to the second preset threshold (WL GC threshold), that is, the wear leveling threshold and the garbage collection threshold are reached respectively, the dynamic adjustment operation is triggered, and all storage blocks in the free array are moved back to the second free storage block pool (free block pool). Subsequently, a preset number of storage blocks (for example, 58 blocks) with the minimum number of erase times 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 erase times (PE) of storage blocks can be used in an orderly manner in batches of 58 blocks each time until the number of erase times of these blocks reaches the WL GC threshold, that is, the wear leveling threshold and the garbage collection threshold are reached. By giving priority to allocating blocks with a large number of erase times for use, the situation of cold data being written to blocks with a low number of erase times is effectively avoided in a certain strategy, thereby reducing the triggering frequency of the wear leveling (WL) operation, significantly optimizing the write amplification effect, and effectively extending the overall service life of the storage device and improving performance.

[0037] Step S140: if the erasure count of the current storage block in the first free storage block pool exceeds a first preset threshold, the storage block is removed from the first free storage block pool and assigned to a high-wear storage block pool.

[0038] Exemplarily, when it is detected that the number of erases 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, the wear leveling threshold and the garbage collection threshold are reached, a dynamic migration operation is triggered, and the storage block is removed from the first free storage block pool and divided into a high wear storage block pool (WearLeveling pool) for management. The high wear storage block pool is a small pool with limited capacity (for example, a depth of 4) used to store blocks with a high number of erases, which will be given priority in subsequent wear leveling (WL) operations. Specifically, by migrating the data of the minimum PE block in the high wear storage block pool to the block with the largest number of erases in the entire disk, the number of erases of the minimum PE block is increased, the wear distribution of the entire 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 storage devices.

[0039] In an optional implementation, the first preset threshold is determined by adding the minimum number of erase times of a storage block in the storage device to a second preset threshold; the second preset threshold is dynamically set according to the wear distribution state of the storage block in the storage device and the wear leveling strategy.

[0040] Exemplarily, the first preset threshold is calculated by adding the minimum number of erase times (minimum PE) of all storage blocks in the storage device to the second preset threshold (WL GC threshold). The minimum number of erase times indicates the number of erase times of the block with the lightest wear in the current entire disk, which 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 (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 priority use of blocks with low erase times, and avoid excessive use of blocks with high erase times. 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 erase times of the entire disk, further improve the efficiency of storage block management, and extend the overall service life of the device.

[0041] Step S200 , in response to a free storage block request, a first storage block with the highest number of erase times is selected from a first free storage block pool for use.

[0042] Exemplarily, when the storage device receives an allocation request for a free storage block, it selects the storage block with the highest number of erase times from the first free storage block pool (free array) as the first storage block for allocation and use. The purpose of this allocation strategy is to give priority to the first storage block with the highest number of erase times in the first free storage block pool, while preventing the blocks with a smaller number of erase times from entering the use state too early, thereby effectively delaying the wear growth of the blocks with a low number of erase times, reducing the write amplification effect, and further optimizing the wear balance of the storage device, thereby improving the overall life and performance.

[0043] Step S300: If the state of the first storage block changes to a used state, the first storage block is divided into a used storage block pool, and is not divided into a first free storage block pool again until a garbage collection operation is performed.

[0044] Exemplarily, when the first storage block allocated from the first free storage block pool (free array) is actually used, its status will be marked as in use and divided into the used storage block pool (close block pool) for management. In the used storage block pool, the first storage block will continue to store data until the triggering condition of the garbage collection (Garbage Collection-GC) operation is met. After the garbage collection operation GC is executed, the invalid data in the storage block is cleared, the status is restored to the free state, and it is re-divided back to the first free storage block pool (free array) for subsequent allocation and use. This management process effectively optimizes the resource utilization of the storage block through the dynamic flow of status, and at the same time provides a good foundation for wear leveling.

[0045] In an optional embodiment, in step S300, the first storage block is divided into a used storage block pool, and then re-divided into a first free storage block pool after a garbage collection operation is performed, including: 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 (Garbage Collection - GC) operation, the invalid data in the first storage block is cleared, the first storage block is restored to an idle state, and the cleaned first storage block is reallocated to the first free storage block pool.

[0046] Exemplarily, when it is detected that the amount of invalid data in a storage block in a used storage block pool (close block pool) reaches a preset data threshold (for example, the proportion of invalid data to 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.

[0047] In the garbage collection operation, the storage blocks containing invalid data are preferentially selected, and after the valid data is migrated to other free blocks, the invalid data in the storage blocks is cleared to restore them to an idle state. The recovered storage blocks 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 the normal operation of storage devices can be guaranteed when resources are tight or the inefficiency of data is high, thereby extending the service life of the device and optimizing the overall performance.

[0048] Step S400: if there is a second storage block whose erase times exceed a first preset threshold in the first free storage block pool, the second storage block is divided into a high wear storage block pool to perform a wear leveling operation.

[0049] Exemplarily, when the number of erasures of certain storage blocks (i.e., the second storage blocks) in the first free storage block pool (free array) exceeds a pre-set first preset threshold (minimum PE+WL GC threshold), these storage blocks will be identified as high-wear blocks and divided 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), and the load of the high-wear blocks will be reduced by migrating the data on the high-wear blocks to the blocks with lower erasure times, thereby further optimizing the wear distribution of the storage device, thereby extending the overall service life of the storage device and improving its reliability.

[0050] In an optional embodiment, in step S400, if there is a second storage block whose number of erase times exceeds a first preset threshold in the first free storage block pool, the second storage block is divided into a high-wear storage block pool to perform a wear leveling operation, including: The number of erasure times of storage blocks in the first free storage block pool is detected in real time. When it is detected that there is a second storage block in the first free storage block pool whose erasure times exceed a first preset threshold, the second storage block is removed from the first free storage block pool and divided into a high wear storage block pool.

[0051] Exemplarily, the storage blocks in the first free storage block pool (free array) are detected in real time, and their current status is determined by monitoring the number of erases (PE) of each storage block. When it is detected that there is a second storage block in the first free storage block pool whose number of erases exceeds the first preset threshold ((minimum PE + WL GC threshold), a dynamic adjustment operation is triggered to remove the storage block from the first free storage block pool and divide it into a high wear storage block pool (Wear Leveling pool) for special management. The storage blocks in the high wear storage block pool will become the target blocks of subsequent wear leveling (WL) operations to optimize the erase balance distribution of the entire disk through data migration and other means. This real-time detection mechanism can dynamically monitor the wear of storage blocks and adjust the division status of storage blocks in a timely manner, thereby effectively avoiding further excessive use of high wear blocks and improving the overall life and reliability of storage devices.

[0052] In the high-wear storage block pool, a storage block with the smallest number of erase times is selected as a source block, a storage block with the largest number of erase times is selected as a target block, and data in the source block is migrated to the target block.

[0053] Exemplarily, after the storage blocks are divided into the high-wear storage block pool (Wear Leveling pool), the wear leveling (WL) operation is performed based on the number of storage block erases (PE) across the entire disk. Specifically, the storage block with the smallest number of erases is first selected from the storage blocks of the entire disk as the source block, and its data is used as the source data to be moved; at the same time, the storage block with the largest number of erases 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 erases of the source block will be increased, thereby reducing the difference in the number of erases across the entire disk and achieving the purpose of optimizing the wear distribution. This block selection mechanism based on the number of erases across the entire disk can effectively alleviate the excessive use of high-wear blocks, extend the service life of storage devices, and improve the overall stability of the storage system.

[0054] After the data migration is completed, the erasure count of the source block is updated, and the second preset threshold is dynamically adjusted.

[0055] Demonstratively, when the data migration operation is completed, the status of the source block and the target block are updated. First, the number of erases (PE) of the source block is increased by 1 to reflect the change in the number of erase operations that occurred to the block during the data migration process, and its status is updated to a reallocated free block. Secondly, according to the current distribution of erase times across the entire disk, the second preset threshold (WL GC threshold) is dynamically adjusted to ensure that the triggering 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 erase times between storage blocks, balancing the use wear of storage blocks, thereby effectively extending the service life of the storage device and improving performance stability.

[0056] In an optional embodiment, the storage block management method of the present application further includes: 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 the second preset threshold, all storage blocks in the first free storage block pool are moved to the second free storage block pool, and a preset number of new storage blocks are applied for from the second free storage block pool to be allocated to the first free storage block pool.

[0057] Exemplarily, in the block management process of the storage device, when the number of erase times of the storage block with the smallest number of erase times in the first free storage block pool (free array) is equal to the second preset threshold value (WL GC threshold value), all storage blocks in the first free storage block pool are moved back to the second free storage block pool (free block pool) to release the resources of the first free storage block pool. Subsequently, storage blocks (for example, 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 low number of erase times, thereby optimizing the allocation order of blocks, delaying the wear of blocks with a low number of erase times, and further improving the life and wear leveling of the storage device. This mechanism ensures the dynamic and flexibility of storage block management, and helps to avoid the problem of excessive aging caused by uneven distribution of block erase times.

[0058] In an optional implementation, applying for a preset number of new storage blocks from the second free storage block pool to be allocated to the first free storage block pool includes: The storage blocks in the second free storage block pool are sorted in ascending order according to the number of erase times.

[0059] For example, Figure 2As shown, all storage blocks in the second free storage block pool (free block pool) are sorted from small to large according to their erase count (PE). The sorting operation is based on the wear status of the storage blocks, and blocks with smaller erase counts are prioritized at the front of the list, while blocks with larger erase counts are prioritized at the back of the list. Through this sorting method, blocks with smaller erase counts can be quickly identified and screened to meet the needs 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 order of storage block usage, helps to achieve wear leveling (WL), extends the overall service life of storage devices, and provides basic data support for subsequent screening and block management operations.

[0060] According to the sorting result, the storage blocks whose erase times meet the preset screening conditions are selected as the target storage blocks.

[0061] Exemplarily, after the storage blocks in the second free storage block pool (free block pool) are sorted from small to large according to the number of erase times (PE), the sorting results will be screened according to preset screening conditions. The screening conditions may include that the number of erase times is less than a certain threshold (for example, PE≤min+100, where min is the minimum number of erase times of the current storage block) to ensure that the number of erase times 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 conditions as the target storage block set to provide suitable candidate storage blocks for subsequent allocation and management operations. Through this screening mechanism, it is possible to effectively prevent storage blocks with too high an erase time from entering the low-wear block pool, thereby further optimizing the use strategy of the storage blocks and improving the service life and performance of the storage device.

[0062] A preset number of new storage blocks are applied for from the target storage blocks, and the applied new storage blocks are divided into a first free storage block pool.

[0063] Exemplarily, a preset number of new storage blocks (for example, 58 blocks) are applied for from the target storage block set, and these newly applied storage blocks are divided into the first free storage block pool (free array). During the operation, the results are first sorted according to the number of erase times (PE) of the target storage blocks, and the blocks are selected in sequence to ensure that the storage blocks with the smallest number of erase times 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 storage block pool (free array) for subsequent storage resource allocation. Through this mechanism, it can be ensured that blocks with lower erase times are used first, while avoiding premature wear of blocks with low erase times, extending the overall life of the storage device, and reducing the risk of cold data being written to blocks with low erase times, thereby optimizing storage performance and resource utilization efficiency.

[0064] The storage block management method of the embodiment of the present application dynamically divides the storage blocks into different types of storage pools, and flexibly allocates and circulates them according to parameters such as the state of the block and the number of erases. First, by introducing the first free storage block pool (free array), the storage blocks with a small number of erases are effectively screened out for priority management, and the blocks with a high number of erases are selected during allocation, thereby avoiding premature wear of the blocks with low number of erases, while optimizing the wear distribution and extending the overall life of the storage device. Secondly, the combination of the used storage block pool (close block pool) and the garbage collection mechanism realizes the efficient recovery and reallocation of storage blocks, further improving the utilization efficiency of storage blocks. In addition, the high wear storage block pool (WearLeveling pool) performs garbage collection (Garbage Collection-GC) operations on storage blocks whose erase times exceed the preset threshold, effectively preventing excessive aging of high wear blocks, and reducing the write amplification effect caused by frequent triggering of wear leveling. Not only a good balance is achieved between wear leveling and write amplification optimization, but also the reliability, service life and performance of the storage system are significantly improved.

[0065] Figure 3 A schematic diagram of the structure of a storage block management device according to an embodiment of the present application is shown. Exemplarily, the device includes: The storage block pool division module 31 is used to divide each storage block into a corresponding type of storage pool according to the status of each storage block in the storage device, 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; 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 erase times from the first free storage block pool for use; A storage block partitioning module 33, configured to partition the first storage block into the used storage block pool if the state of the first storage block changes to a used state, and then partition the first storage block into the first free storage block pool again after a garbage collection operation is performed; The wear leveling execution module 34 is configured to divide the second storage block into the high wear storage block pool to perform a wear leveling operation if there is a second storage block with an erasure count exceeding a first preset threshold in the first free storage block pool.

[0066] It can be understood that the device of this embodiment corresponds to the storage block management method of the above embodiment, and the options in the above embodiment are also applicable to this embodiment, so they will not be described repeatedly here.

[0067] The present application also provides a storage device, such as a solid-state drive, an embedded storage device eMMC, UFS, etc. Exemplarily, the storage device includes a processor and a memory, wherein the memory stores a computer program, and the processor runs the computer program to enable the storage device to execute the functions of each module in the above method or the above apparatus.

[0068] Among them, the processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including 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 at least one of other programmable logic devices, discrete gates 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., which can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application.

[0069] The memory may 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 electric erasable programmable read-only memory (EEPROM), etc. The memory is used to store a computer program, and the processor may execute the computer program accordingly after receiving an execution instruction.

[0070] 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 may 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), a random access memory (RAM), a magnetic disk or an optical disk.

[0071] In several embodiments provided in the present 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 schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a 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 box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow diagram, and the combination of boxes in the structure diagram and / or the flow diagram, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0072] In addition, the functional modules or units in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0073] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling 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 the various embodiments of the present application.

[0074] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.

Claims

1. A storage block management method, characterized in that: The method comprises: According to the status of each storage block in the storage device, each storage block is divided into a storage pool of corresponding type, 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; In response to a free storage block request, selecting a first storage block with the highest number of erase times from the first free storage block pool for use; If the state of the first storage block changes to a used state, the first storage block is divided into the used storage block pool, and is not divided into the first free storage block pool again after a garbage collection operation is performed; If there is a second storage block in the first free storage block pool whose erasure times exceed a first preset threshold, the second storage block is divided into the high-wear storage block pool to perform a wear leveling operation.

2. The storage block management method according to claim 1, characterized in that: The method further comprises: 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, all storage blocks in the first free storage block pool are moved to the second free storage block pool, and a preset number of new storage blocks are applied for from the second free storage block pool to be allocated to the first free storage block pool.

3. The storage block management method according to claim 1, characterized in that: The step of dividing each storage block into a storage pool of a corresponding type according to the status of each storage block in the storage device includes: If the current storage block is in a used state, the current storage block is divided into a used storage block pool; If the state of the current storage block is an idle state and the number of erasures is less than a first preset threshold, the current storage block is divided into a first idle storage block pool; If the minimum erasure count 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 a second free storage block pool; If the number of erasures of the current storage block in the first free storage block pool exceeds a first preset threshold, the storage block is moved out of the first free storage block pool and allocated to the high-wear storage block pool.

4. The storage block management method according to claim 1, characterized in that: The dividing the first storage block into the used storage block pool until a garbage collection operation is performed and then the first storage block is divided into the first free storage block pool again, comprising: 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, 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 an idle state, and the cleared first storage block is reallocated to the first idle storage block pool.

5. The storage block management method according to claim 2, characterized in that: The step of applying for a preset number of new storage blocks from the second free storage block pool to be allocated to the first free storage block pool includes: Sorting the storage blocks in the second free storage block pool from small to large according to the number of erasures; According to the sorting result, the storage blocks whose erasure times meet the preset screening condition are screened out as target storage blocks; A preset number of new storage blocks are applied for from the target storage blocks, and the applied new storage blocks are divided into the first free storage block pool.

6. The storage block management method according to claim 1, characterized in that: If there is a second storage block with an erasure count exceeding a 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, comprising: detecting the number of erasures of storage blocks in the first free storage block pool in real time, and when detecting that there is a second storage block in the first free storage block pool whose number of erasures exceeds a first preset threshold, removing the second storage block from the first free storage block pool and assigning the second storage block to the high-wear storage block pool; In the high-wear storage block pool, a storage block with the smallest number of erasures is selected as a source block, a storage block with the largest number of erasures is selected as a target block, and data in the source block is migrated to the target block; After the data migration is completed, the erasure count of the source block is updated, and the first preset threshold and the second preset threshold are dynamically adjusted.

7. 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 erasure times of the storage block 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 block in the storage device.

8. A storage block management device, characterized in that: The device comprises: A storage pool division module, used to divide each storage block into a corresponding type of storage pool according to the status of each storage block in the storage device, wherein 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; A request response module, used for responding to a free storage block request, and selecting a first storage block with the highest number of erasure times from the first free storage block pool for use; a storage block partitioning module, configured to partition the first storage block into the used storage block pool if the state of the first storage block changes to a used state, and then partition the first storage block into the first free storage block pool again after a garbage collection operation is performed; The wear leveling execution module is used to divide the second storage block into the high wear storage block pool to perform a wear leveling operation if there is a second storage block with an erasure count exceeding a first preset threshold in the first free storage block pool.

9. A storage device, characterized in that: The storage device comprises a processor and a memory, the memory stores a computer program, and the processor is used to execute the computer program to implement the storage block management method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer program is stored therein, and when the computer program is executed on a processor, the storage block management method according to any one of claims 1 to 7 is implemented.

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

  • Wear leveling method and device and nonvolatile storage equipment

    CN111159058A

  • Memory system and method of controlling nonvolatile memory

    US20210064287A1