Wear balance processing method, device, equipment and medium
By scanning the erase count and shutdown time in the SSD, determining the target block and idle block, and migrating data in the idle mode, the problem of the static loss equalization process occupying IO bandwidth is solved, and the read and write performance of the SSD is improved.
Patent Information
- Application Number
- CN202412000158.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-12-30
AI Technical Summary
The current static loss equalization process of SSD is carried out during the IO process, occupying the bandwidth speed of the normal IO process, affecting the read and write performance and processing efficiency of the SSD.
By scanning the erase count and closing time of each block, the erase count threshold and closing time threshold are obtained, the target block and the idle block are determined, and after the SSD enters the idle mode, the data is migrated to the idle block according to the migration priority of the target block.
Wear equalization is completed before the SSD is officially run, avoiding the bandwidth speed of the IO process, improving the read and write performance of the SSD, and reducing the impact of wear equalization on the overall read and write performance of the SSD.
Smart Images

Figure CN119718212A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and in particular to a wear leveling processing method, device, equipment and medium. Background Art
[0002] In a solid state drive (SSD), each flash memory cell has a limited write lifespan. When a cell is filled with data, it will be marked as a "bad block" and will no longer be used for data storage, which causes the SSD performance to degrade or even fail. To address this problem, wear leveling technology was introduced. Among them, static wear leveling technology not only considers the new and old states of the flash memory cell, but also pays attention to the frequency of data access. When erasing and writing data, the system prioritizes migrating long-unused cold data from new cells to old cells, and writing new data to new cells to achieve wear leveling.
[0003] Static wear leveling technology is designed to optimize static data. It can run continuously in the background, monitor the usage of each flash memory unit, actively migrate data from units with low wear to other units, and put the original units into the free pool, improving the security and durability of static data. However, static wear leveling is usually performed during the normal input / output (IO) process of the SSD, which will occupy the bandwidth speed of the normal IO process, affect the read and write performance and processing efficiency of the SSD, and also have a certain impact on the overall performance of the system.
[0004] In view of the above, how to solve the problem that the static wear leveling process of the current SSD is performed during the IO process, affecting the read and write performance and processing efficiency of the SSD, is an urgent problem to be solved by technicians in this field. Summary of the invention
[0005] The purpose of the present invention is to provide a wear leveling processing method, device, equipment and medium to solve the problem that the current static wear leveling process of the SSD is performed during the IO process, affecting the read and write performance and processing efficiency of the SSD.
[0006] In order to solve the above technical problems, the present invention provides a wear leveling processing method, which is applied to a solid state drive; the method comprises:
[0007] Scan each block and calculate the erase count and shutdown time of each block;
[0008] Get the erase count threshold and shutdown time threshold;
[0009] Determine a target block and a free block in each block according to the erase count, the close time, the erase count threshold and the close time threshold; wherein the target block is a block containing cold data;
[0010] After entering the idle mode, data in each target block is migrated to a corresponding idle block according to the migration priority corresponding to each target block.
[0011] On the one hand, obtaining the erase count threshold includes:
[0012] Get the total erase count and total number of blocks;
[0013] determining a quotient of the total erase count and the total number of blocks to determine an average erase count;
[0014] generating a first erase count threshold, a second erase count threshold, and a third erase count threshold respectively according to the average erase count;
[0015] The first erase count threshold is smaller than the second erase count threshold, and the second erase count threshold is smaller than the third erase count threshold.
[0016] On the other hand, get the closing time threshold, including:
[0017] Get the total closing time and the number of valid blocks; where valid blocks are readable and writable blocks;
[0018] Determining a quotient of the total closing time and the number of valid blocks to determine an average closing time;
[0019] Generate a first closing time threshold, a second closing time threshold and a third closing time threshold respectively according to the average closing time;
[0020] The first closing time threshold is smaller than the second closing time threshold, and the second closing time threshold is smaller than the third closing time threshold.
[0021] On the other hand, a target block is determined in each block according to the erase count, the close time, the erase count threshold, and the close time threshold, including:
[0022] Determine the block to be selected that has reached the capacity limit in each block;
[0023] Determine the erase count and shutdown time of the block to be selected;
[0024] When the erase count of the block to be selected is not greater than the first erase count threshold, and the closing time of the block to be selected is not less than the first closing time threshold and less than the second closing time threshold, determining the block to be selected as the first target block;
[0025] Put the first target block into the first queue;
[0026] When the erase count of the block to be selected is greater than the first erase count threshold and is not greater than the second erase count threshold, and the closing time of the block to be selected is not less than the second closing time threshold and is less than the third closing time threshold, determining the block to be selected as the second target block;
[0027] placing the second target block into the second queue;
[0028] When the erase count of the block to be selected is greater than the second erase count threshold and is not greater than the third erase count threshold, and the closing time of the block to be selected is not less than the third closing time threshold, determining the block to be selected as the third target block;
[0029] The third target block is placed into the third queue.
[0030] On the other hand, according to the erase count, the shutdown time, the erase count threshold and the shutdown time threshold, a free block is determined in each block, including:
[0031] Iterate through the erase count and shutdown time of each block;
[0032] A block whose corresponding erase count is greater than a third erase count threshold and whose corresponding shutdown time is less than a first shutdown time threshold is determined as a free block.
[0033] On the other hand, according to the migration priority corresponding to each target block, the data in each target block is migrated to the corresponding free block, including:
[0034] Set the power consumption value for performing wear leveling in idle mode;
[0035] Determine the priority order of the first queue, the second queue, and the third queue; wherein the priority of the first queue is lower than the priority of the second queue, and the priority of the second queue is lower than the priority of the third queue;
[0036] According to the priority order and the power consumption value, the data of the third target block in the third queue, the data of the second target block in the second queue and the data of the first target block in the first queue are written into the free blocks in sequence.
[0037] On the other hand, the data in each target block is migrated to the corresponding free block, including:
[0038] Obtaining a preset first bandwidth speed, a second bandwidth speed, and a third bandwidth speed;
[0039] Migrating data of a first target block in a first queue to a corresponding idle block at a first bandwidth speed;
[0040] Migrating the data of the second target block in the second queue to the corresponding idle block at the second bandwidth speed;
[0041] Migrating data of a third target block in a third queue to a corresponding idle block at a third bandwidth speed;
[0042] The first bandwidth speed is smaller than the second bandwidth speed, and the second bandwidth speed is smaller than the third bandwidth speed.
[0043] On the other hand, it also includes:
[0044] When a read / write command is received, determining whether data migration of the target block is currently being performed;
[0045] If it is confirmed that data migration of the target block is being performed, the bandwidth speed for performing the data migration of the target block is reduced;
[0046] Determine whether the data migration of the target block is completed;
[0047] If it is confirmed that the data migration of the target block is completed, the data migration process is stopped.
[0048] In order to solve the above technical problems, the present invention also provides a wear leveling processing device, which is applied to a solid state hard disk; the device comprises:
[0049] A scanning and calculating module, used for scanning each block and calculating the erase count and closing time of each block;
[0050] An acquisition module, used for acquiring an erase count threshold and a shutdown time threshold;
[0051] A determination module, used to determine a target block and a free block in each block according to an erase count, a shutdown time, an erase count threshold, and a shutdown time threshold; wherein the target block is a block containing cold data;
[0052] The migration module is used to migrate the data in each target block to the corresponding idle block according to the migration priority corresponding to each target block after entering the idle mode.
[0053] In order to solve the above technical problems, the present invention further provides a wear leveling processing device, comprising:
[0054] Memory for storing computer programs;
[0055] The processor is used to implement the steps of the above-mentioned wear leveling processing method when executing a computer program.
[0056] In order to solve the above technical problem, the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above wear leveling processing method are implemented.
[0057] The wear leveling processing method provided by the present invention is applied to a solid-state hard disk; specifically, each block is scanned, and the erase count and shutdown time of each block are calculated; an erase count threshold and a shutdown time threshold are obtained; a target block and a free block are determined in all blocks according to the erase count, the shutdown time, the erase count threshold and the shutdown time threshold; wherein the target block is a block containing cold data; after entering the idle mode, the data in each target block is migrated to the corresponding free block according to the migration priority corresponding to each target block.
[0058] The beneficial effects of the present invention are that, by calculating the erase count and shutdown time of each block, the target block and the free block are determined in all blocks according to the erase count, the shutdown time, the erase count threshold and the shutdown time threshold; when the SSD enters the idle mode, the data in each target block is migrated to the corresponding free block according to the migration priority corresponding to each target block, thereby completing the wear leveling before the SSD is officially operated, avoiding occupying the bandwidth speed of the IO process of the SSD, and improving the read and write performance of the SSD; at the same time, the scheme takes into account the different wear degrees of different target blocks, and migrates the data of the target blocks according to the migration priority of each target block, so that the block data migration order is more reasonable, and the influence of wear leveling on the overall read and write performance of the SSD is reduced.
[0059] On the other hand, the present invention specifically obtains the total erase count and the total number of blocks, determines the quotient of the total erase count and the total number of blocks to determine the average erase count, and generates the first erase count threshold, the second erase count threshold and the third erase count threshold according to the average erase count, thereby obtaining the erase count threshold; obtains the total shutdown time and the number of valid blocks, determines the quotient of the total shutdown time and the number of valid blocks to determine the average shutdown time, and generates the first shutdown time threshold, the second shutdown time threshold and the third shutdown time threshold according to the average shutdown time, thereby obtaining the shutdown time threshold, so as to accurately determine the free block of the target block using the two thresholds. By executing wear leveling algorithms of different priorities on the SSD in idle mode, the target block can be moved in advance, thereby reducing the performance loss caused by traditional wear leveling during the reading and writing process.
[0060] In addition, the present invention also provides a wear leveling processing device, equipment and medium, with the same effect as above. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0062] Figure 1A flowchart of a wear leveling processing method provided by an embodiment of the present invention;
[0063] Figure 2 A schematic diagram of a wear leveling processing device provided by an embodiment of the present invention;
[0064] Figure 3 A schematic diagram of a wear leveling processing device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0065] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0066] The core of the present invention is to provide a wear leveling processing method, device, equipment and medium to solve the problem that the current static wear leveling process of the SSD is performed during the IO process, affecting the read and write performance and processing efficiency of the SSD.
[0067] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0068] In an SSD, each flash memory cell has a limited write lifespan. When a cell is filled with data, it will be marked as a "bad block" and will no longer be used for data storage, which causes the SSD to degrade in performance or even fail. To address this issue, WearLeveling technology was introduced. The static wear leveling technology not only considers the new and old states of the flash memory cells, but also focuses on the frequency of data access. When erasing and writing data, the system prioritizes migrating long-unused cold data from new cells to old cells, and writing new data to new cells to achieve wear leveling. Among them, the static wear leveling technology is designed specifically for optimizing static data. It can run continuously in the background, monitor the usage of each flash memory cell, actively migrate data from cells with low wear levels to other cells, and classify the original cells into the free pool, thereby improving the security and durability of static data.
[0069] However, static wear leveling is usually performed during the normal IO process of the SSD, which will occupy the bandwidth speed of the normal IO process, affect the read and write performance and processing efficiency of the SSD, and also have a certain impact on the overall performance of the system. Therefore, in order to solve the above problems, the present invention provides a wear leveling processing method. It is understandable that the method is applied to solid-state drives.
[0070] Figure 1A flowchart of a wear leveling processing method provided by an embodiment of the present invention. Figure 1 As shown, the method includes:
[0071] S10: Scan each block and calculate the erase count and shutdown time of each block.
[0072] First, scan each block in the SSD and calculate the erase count and close time of each block. It should be noted that in the SSD, a Block is a storage unit composed of several pages, and is the smallest unit for the SSD to perform an erase operation. Each Block contains multiple pages, and the size of a Page is usually 4KB. Due to the characteristics of flash memory, once data is written, it cannot be directly overwritten and needs to be erased first. The smallest unit of erase is the Block. In the garbage collection mechanism of the SSD, the Block is used to store valid data and perform data migration and block erasure to generate new available Blocks.
[0073] Furthermore, the erase count refers to the number of times a block is erased. Since the flash memory in the SSD has a limited erase life, each block can only be erased a certain number of times (usually between thousands and tens of thousands of times). After exceeding this number, the block may fail or performance may degrade. The erase count is an important indicator for measuring the life of the block, and is usually obtained from the Self-Monitoring Analysis and Reporting Technology (SMART) information of the SSD.
[0074] Close time refers to the time required for a block to switch from the used state to the idle state. Close time is an important indicator in SSD performance optimization because it directly affects the throughput and latency of the SSD. In this embodiment, the erase count will be combined with the close time to determine whether the corresponding block needs to be wear-leveled.
[0075] S11: Obtaining an erase count threshold and a shutdown time threshold.
[0076] S12: Determine a target block and a free block in each block according to the erase count, the shutdown time, the erase count threshold and the shutdown time threshold.
[0077] The target block is a block containing cold data.
[0078] Further obtaining the erase count threshold and the shutdown time threshold. It should be noted that the specific method for obtaining the erase count threshold and the shutdown time threshold is not limited in this embodiment and depends on the specific implementation situation.
[0079] It is worth noting that, in this embodiment, the erase count threshold and the close time threshold are used as the thresholds of the erase count and the close time, respectively, to determine the blocks that need to be wear-leveled in the SSD. Specifically, according to the erase count, the close time, the erase count threshold and the close time threshold, the target block and the free block are determined in each block. It should be noted that the target block is a block containing cold data. In layman's terms, cold data is data with a low access frequency and is not very important to business and applications. The free block is a block in an idle state that does not contain data.
[0080] In this embodiment, there is no limitation on the method of determining the target block and the free block, which depends on the specific implementation situation.
[0081] S13: After entering the idle mode, data in each target block is migrated to a corresponding idle block according to the migration priority corresponding to each target block.
[0082] Finally, in order to prevent wear leveling from affecting the normal IO of the SSD, after the SSD enters idle mode, the data in each target block is migrated to the corresponding free block according to the migration priority corresponding to each target block, thereby realizing wear leveling processing of the SSD.
[0083] It should be noted that in this embodiment, there is no limitation on the specific method for determining the migration priority corresponding to each target block, which depends on the specific implementation situation.
[0084] In this embodiment, by calculating the erase count and shutdown time of each block, the target block and the free block are determined in all the blocks according to the erase count, the shutdown time, the erase count threshold and the shutdown time threshold; when the SSD enters the idle mode, the data in each target block is migrated to the corresponding free block according to the migration priority corresponding to each target block, thereby completing the wear leveling before the SSD is officially put into operation, avoiding occupying the bandwidth speed of the SSD's IO process, and improving the read and write performance of the SSD; at the same time, the scheme takes into account the different wear degrees of different target blocks, and migrates the data of the target blocks according to the migration priority of each target block, so that the block data migration order is more reasonable, reducing the influence of wear leveling on the overall read and write performance of the SSD.
[0085] Based on the above embodiments, in some embodiments, obtaining the erase count threshold includes:
[0086] S111: Obtain the total erase count and the total number of blocks;
[0087] S112: Determine a quotient of a total erase count and a total number of blocks to determine an average erase count;
[0088] S113: Generate a first erase count threshold, a second erase count threshold, and a third erase count threshold respectively according to the average erase count;
[0089] The first erase count threshold is smaller than the second erase count threshold, and the second erase count threshold is smaller than the third erase count threshold.
[0090] Specifically, first obtain the total erase count Total EraseCnt and the total number of blocks. Further determine the quotient of the total erase count Total EraseCnt and the total number of blocks to determine the average erase count Ave_erase count. Finally, generate the first erase count threshold EraseCntLow, the second erase count threshold EraseCntMiddle and the third erase count threshold EraseCntHigh according to the average erase count Ave_erase count.
[0091] It should be noted that in this embodiment, there is no restriction on the specific sizes of the three erase count thresholds, and it is necessary to ensure that the first erase count threshold EraseCntLow is less than the second erase count threshold EraseCntMiddle, and the second erase count threshold EraseCntMiddle is less than the third erase count threshold EraseCntHigh. For example, the first erase count threshold EraseCntLow = Ave_erase count-30, the second erase count threshold EraseCntMiddle = Ave_erasecount-20, and the third erase count threshold EraseCntHigh = Ave_erase count-10.
[0092] In addition, because each block in the SSD performs read, write and erase operations continuously, each erase count threshold actually changes dynamically in this embodiment.
[0093] Based on the above embodiment, in some embodiments, obtaining the closing time threshold includes:
[0094] S114: Obtain the total closing time and the number of valid blocks; wherein the valid blocks are readable and writable blocks;
[0095] S115: Determine the quotient of the total closing time and the number of valid blocks to determine the average closing time;
[0096] S116: Generate a first closing time threshold, a second closing time threshold and a third closing time threshold respectively according to the average closing time.
[0097] The first closing time threshold is smaller than the second closing time threshold, and the second closing time threshold is smaller than the third closing time threshold.
[0098] Specifically, first obtain the total closing time Total Time and the number of valid blocks. Among them, the valid block is a readable and writable block, that is, a block that can be used normally. Further determine the quotient of the total closing time Total Time and the number of valid blocks to determine the average closing time CloseTimeTH. Finally, according to the average closing time CloseTimeTH, generate the first closing time threshold CloseTimeLow, the second closing time threshold CloseTimeMiddle and the third closing time threshold CloseTimeHigh respectively.
[0099] It should be noted that in this embodiment, there is no restriction on the specific sizes of the three closing time thresholds, and it is necessary to ensure that the first closing time threshold CloseTimeLow is smaller than the second closing time threshold CloseTimeMiddle, and the second closing time threshold CloseTimeMiddle is smaller than the third closing time threshold CloseTimeHigh. For example, the first closing time threshold CloseTimeLow = CloseTimeTH-30, the second closing time threshold CloseTimeMiddle = CloseTimeTH-20, and the third closing time threshold CloseTimeHigh = CloseTimeTH-10.
[0100] In addition, because each block in the SSD performs read, write and erase operations continuously, each shutdown time threshold actually changes dynamically in this embodiment.
[0101] In summary, by obtaining the total erase count and the total number of blocks, the quotient of the total erase count and the total number of blocks is determined to determine the average erase count, and the first erase count threshold, the second erase count threshold and the third erase count threshold are generated according to the average erase count, thereby achieving the acquisition of the erase count threshold; by obtaining the total shutdown time and the number of valid blocks, the quotient of the total shutdown time and the number of valid blocks is determined to determine the average shutdown time, and the first shutdown time threshold, the second shutdown time threshold and the third shutdown time threshold are generated according to the average shutdown time, thereby achieving the acquisition of the shutdown time threshold, so as to accurately determine the free block of the target block by using the two thresholds.
[0102] Based on the above embodiments, in some embodiments, determining a target block in each block according to the erase count, the shutdown time, the erase count threshold and the shutdown time threshold includes:
[0103] S121: Determine a block to be selected that has reached the capacity limit in each block;
[0104] S122: Determine the erase count and shutdown time of the block to be selected;
[0105] S123: when the erase count of the block to be selected is not greater than the first erase count threshold, and the closing time of the block to be selected is not less than the first closing time threshold and less than the second closing time threshold, determine that the block to be selected is the first target block;
[0106] S124: putting the first target block into the first queue;
[0107] S125: when the erase count of the block to be selected is greater than the first erase count threshold and is not greater than the second erase count threshold, and the close time of the block to be selected is not less than the second close time threshold and is less than the third close time threshold, determine that the block to be selected is the second target block;
[0108] S126: putting the second target block into the second queue;
[0109] S127: when the erase count of the block to be selected is greater than the second erase count threshold and not greater than the third erase count threshold, and the close time of the block to be selected is not less than the third close time threshold, determining the block to be selected as the third target block;
[0110] S128: Put the third target block into the third queue.
[0111] In order to determine the target block, it is first necessary to determine the candidate block that has reached the capacity limit in each block, and determine the erase count and close time of the candidate block.
[0112] Further, when the erase count Erase count of the selected block is not greater than the first erase count threshold EraseCntLow, the close time Close time of the selected block is not less than the first close time threshold CloseTimeLow, and is less than the second close time threshold CloseTimeMiddle, the selected block is determined to be the first target block, and the first target block is placed in the first queue.
[0113] When the erase count Erase count of the selected block is greater than the first erase count threshold EraseCntLow and not greater than the second erase count threshold EraseCntMiddle, and the close time Close time of the selected block is not less than the second close time threshold CloseTimeMiddle and less than the third close time threshold CloseTimeHigh, the selected block is determined to be the second target block, and the second target block is placed in the second queue.
[0114] When the erase count of the selected block is greater than the second erase count threshold EraseCntMiddle and not greater than the third erase count threshold EraseCntHigh, and the closing time of the selected block is not less than the third closing time threshold CloseTimeHigh, the selected block is determined to be the third target block, and the third target block is placed in the third queue.
[0115] It is worth noting that in this embodiment, three queues are set up to store different types of target blocks, and the urgency of data migration for the target blocks in each queue is different, that is, the migration priority is different. The target blocks in each queue perform data migration in different orders, so that wear leveling of the SSD can be performed more reasonably. In this embodiment, there is no restriction on the migration priority of the target blocks in each queue, which depends on the specific implementation situation.
[0116] Based on the above embodiments, in some embodiments, determining a free block in each block according to the erase count, the shutdown time, the erase count threshold and the shutdown time threshold includes:
[0117] S129: traverse the erase count and shutdown time of each block;
[0118] S130: Determine a block whose corresponding erase count is greater than a third erase count threshold and whose corresponding shutdown time is less than a first shutdown time threshold as an idle block.
[0119] In order to determine the free blocks, first traverse the erase count Erase count and close time Closetime of each block, and determine the blocks whose corresponding erase count Erase count is greater than the third erase count threshold EraseCntHigh and whose corresponding close time Close time is less than the first close time threshold CloseTimeLow as free blocks.
[0120] In summary, the target block and the free block are determined respectively, so as to migrate the data in the target block to the free block later.
[0121] Based on the above embodiments, in some embodiments, according to the migration priority corresponding to each target block, data in each target block is migrated to the corresponding free block, including:
[0122] S131: Setting the power consumption value for performing wear leveling in idle mode;
[0123] S132: Determine the priority order of the first queue, the second queue, and the third queue;
[0124] The priority of the first queue is lower than the priority of the second queue, and the priority of the second queue is lower than the priority of the third queue;
[0125] S133: According to the priority order and the power consumption value, the data of the third target block in the third queue, the data of the second target block in the second queue, and the data of the first target block in the first queue are sequentially written into the free blocks accordingly.
[0126] In order to achieve data migration of the target block, the power consumption value for performing wear leveling in idle mode is specifically set, which is required not to be higher than the power consumption value specified by the manufacturer. The priority order of the first queue, the second queue, and the third queue is further determined. Among them, the priority of the first queue is lower than the priority of the second queue, and the priority of the second queue is lower than the priority of the third queue.
[0127] It should be noted that the priority order of the queue refers to the order in which the data of the target block is migrated. Therefore, for the target block, the priority order of the queue where the target block is located is its own migration priority. For example, if the priority of the first queue is lower than that of the second queue, the migration priority of the target block in the first queue is lower than that of the target block in the second queue.
[0128] Furthermore, since the priority of the first queue is lower than that of the second queue, and the priority of the second queue is lower than that of the third queue, the data of the third target block in the third queue, the data of the second target block in the second queue, and the data of the first target block in the first queue are written into each free block in turn according to the priority order and the power consumption value, thereby performing garbage collection on each target block.
[0129] It should also be noted that the starting condition of the garbage collection process is: at least one of the three queues has a target block and there is a free block. The ending condition of the garbage collection process is: there is no target block in any of the three queues and / or no free block.
[0130] In summary, in this embodiment, by executing wear leveling algorithms of different priorities on the SSD in idle mode, the target block can be moved in advance, thereby reducing the performance loss caused by traditional wear leveling during the reading and writing process.
[0131] In addition, in order to improve the wear leveling efficiency, the data in the target block can be transmitted in segments during the garbage collection process of the target block: during the data migration process, the data set to be migrated is divided into multiple smaller data segments, and then these data segments are transmitted in parallel. This method can improve the parallelism of data migration, thereby improving the overall migration efficiency. Specifically, by splitting the data set into multiple small segments, multiple transmission tasks can be started at the same time, and each task is responsible for transmitting a data segment. Since multiple transmission tasks can be executed concurrently, network bandwidth and system resources are fully utilized, the total migration time can be significantly reduced. In addition, segmented transmission can also improve the flexibility and fault tolerance of data transmission, because even if a transmission task fails, only the data segment corresponding to the task needs to be retransmitted, without retransmitting the entire data set. It is suitable for large-scale data migration scenarios and can effectively improve migration efficiency and reduce resource waste.
[0132] Taking into account the migration speed of target block data migration under different priorities, based on the above embodiments, in some embodiments, data in each target block is migrated to a corresponding free block, including:
[0133] S134: Acquire a preset first bandwidth speed, a second bandwidth speed, and a third bandwidth speed;
[0134] S135: Migrating the data of the first target block in the first queue to the corresponding idle block at the first bandwidth speed;
[0135] S136: Migrating the data of the second target block in the second queue to the corresponding idle block at the second bandwidth speed;
[0136] S137: Migrate the data of the third target block in the third queue to the corresponding idle block at a third bandwidth speed;
[0137] The first bandwidth speed is smaller than the second bandwidth speed, and the second bandwidth speed is smaller than the third bandwidth speed.
[0138] In this embodiment, the bandwidth speeds for wear-leveling garbage collection of different priorities are different; while meeting the power consumption requirements, the bandwidth occupied by high-priority wear leveling is relatively high. Specifically, the pre-set first bandwidth speed LowSpeed, second bandwidth speed MiddleSpeed, and third bandwidth speed HighSpeed are obtained. It should be noted that the first bandwidth speed LowSpeed corresponds to the first queue, the second bandwidth speed MiddleSpeed corresponds to the second queue, and the third bandwidth speed HighSpeed corresponds to the third queue. The first bandwidth speed LowSpeed is less than the second bandwidth speed MiddleSpeed, and the second bandwidth speed MiddleSpeed is less than the third bandwidth speed HighSpeed.
[0139] When performing garbage collection, the data of the first target block in the first queue is migrated to the corresponding free block through the first bandwidth speed LowSpeed, the data of the second target block in the second queue is migrated to the corresponding free block through the second bandwidth speed MiddleSpeed, and the data of the third target block in the third queue is migrated to the corresponding free block through the third bandwidth speed HighSpeed, so as to use the appropriate bandwidth speed to complete the garbage collection of target blocks of different priorities. It should also be noted that the above three bandwidth speeds are the maximum bandwidths for the SSD to enter the read-write mode from the idle mode. The bandwidth in the idle mode is IdleSpeed, and IdleSpeed is greater than the above bandwidth speeds.
[0140] In a specific implementation, if the SSD that is performing wear leveling in idle mode receives a read / write command at this time, in order not to affect normal IO performance, based on the above embodiment, in some embodiments, the method further includes:
[0141] S14: when a read / write command is received, it is determined whether data migration of the target block is currently being performed; if so, the process proceeds to step S15;
[0142] S15: reducing the bandwidth speed of executing data migration of the target block;
[0143] S16: Determine whether the data migration of the target block is completed; if so, stop the data migration process.
[0144] Specifically, when the SSD that is performing wear leveling in idle mode receives a read / write command, it determines whether data migration of the target block is currently being performed. If not, the read / write command is executed. If so, in order not to affect the SSD's IO processing and to complete the currently performed garbage collection at the same time, the bandwidth speed of performing data migration of the target block is specifically reduced.
[0145] It should be noted that in this embodiment, there is no restriction on the method of reducing the bandwidth speed. For example, the speed reduction measures can be directly taken on the current bandwidth speed, or the bandwidth speed corresponding to the priority of the target block can be first determined, and then the bandwidth speed can be reduced to the bandwidth speed corresponding to the next priority. For example, garbage collection of the second target block of the second queue is currently being performed, and the bandwidth speed at this time is the second bandwidth speed MiddleSpeed; in order to achieve bandwidth speed reduction, the current bandwidth speed is specifically reduced from the second bandwidth speed MiddleSpeed to the first bandwidth speed LowSpeed.
[0146] Furthermore, in order to prevent continuous garbage collection from affecting the read and write process of the SSD, it is necessary to determine whether the data migration of the target block is completed; if so, the data migration process is stopped. In other words, after the data migration of the current target block is completed, the next data migration is stopped. Even if there are still target blocks in the queue that have not been garbage collected, they cannot be further executed. Migration can only be continued when the SSD enters idle mode next time, so as to avoid affecting the read and write performance of the SSD to the greatest extent.
[0147] In the above embodiments, the wear leveling processing method is described in detail. The present invention also provides a corresponding embodiment of the wear leveling processing device.
[0148] Figure 2 A schematic diagram of a wear leveling processing device provided by an embodiment of the present invention. The device is applied to a solid state hard disk; Figure 2 As shown, the device comprises:
[0149] A scanning and calculating module 10 is used to scan each block and calculate the erase count and closing time of each block;
[0150] An acquisition module 11 is used to acquire an erase count threshold and a shutdown time threshold;
[0151] A determination module 12, configured to determine a target block and a free block in each block according to the erase count, the shutdown time, the erase count threshold, and the shutdown time threshold; wherein the target block is a block containing cold data;
[0152] The migration module 13 is used to migrate the data in each target block to the corresponding idle block according to the migration priority corresponding to each target block after entering the idle mode.
[0153] In some embodiments, the acquisition module 11 includes:
[0154] A first acquisition submodule, used for acquiring a total erase count and a total number of blocks;
[0155] A first determination submodule, used to determine a quotient of a total erase count and a total number of blocks to determine an average erase count;
[0156] A first generating submodule, used to generate a first erase count threshold, a second erase count threshold and a third erase count threshold respectively according to the average erase count;
[0157] The first erase count threshold is smaller than the second erase count threshold, and the second erase count threshold is smaller than the third erase count threshold.
[0158] In some embodiments, the acquisition module 11 includes:
[0159] The second acquisition submodule is used to acquire the total closing time and the number of valid blocks; wherein the valid blocks are readable and writable blocks;
[0160] A second determination submodule is used to determine a quotient of the total closing time and the number of valid blocks to determine an average closing time;
[0161] A second generating submodule, used to generate a first closing time threshold, a second closing time threshold and a third closing time threshold respectively according to the average closing time;
[0162] The first closing time threshold is smaller than the second closing time threshold, and the second closing time threshold is smaller than the third closing time threshold.
[0163] In some embodiments, the determination module 12 includes:
[0164] A third determination submodule is used to determine a block to be selected that has reached a capacity limit among the blocks;
[0165] The fourth determination submodule is used to determine the erase count and shutdown time of the block to be selected;
[0166] a fifth determination submodule, configured to determine that the block to be selected is the first target block when the erase count of the block to be selected is not greater than the first erase count threshold, and the close time of the block to be selected is not less than the first close time threshold and less than the second close time threshold;
[0167] A first storage submodule, used for placing a first target block into a first queue;
[0168] a sixth determination submodule, configured to determine that the block to be selected is the second target block when the erase count of the block to be selected is greater than the first erase count threshold and is not greater than the second erase count threshold, and the close time of the block to be selected is not less than the second close time threshold and is less than the third close time threshold;
[0169] A second storage submodule is used to put the second target block into the second queue;
[0170] A seventh determination submodule, configured to determine that the block to be selected is a third target block when the erase count of the block to be selected is greater than the second erase count threshold and not greater than the third erase count threshold, and the close time of the block to be selected is not less than the third close time threshold;
[0171] The third storage submodule is used to put the third target block into the third queue.
[0172] In some embodiments, the determination module 12 includes:
[0173] The traversal submodule is used to traverse the erase count and shutdown time of each block;
[0174] The eighth determination submodule is used to determine a block whose corresponding erase count is greater than a third erase count threshold and whose corresponding shutdown time is less than a first shutdown time threshold as an idle block.
[0175] In some embodiments, the migration module 13 includes:
[0176] A setting submodule is used to set the power consumption value for performing wear leveling in idle mode;
[0177] A ninth determination submodule, used to determine the priority order of the first queue, the second queue and the third queue; wherein the priority of the first queue is lower than the priority of the second queue, and the priority of the second queue is lower than the priority of the third queue;
[0178] The writing module is used to write the data of the third target block in the third queue, the data of the second target block in the second queue and the data of the first target block in the first queue into each idle block in sequence according to the priority order and the power consumption value.
[0179] In some embodiments, the migration module 13 includes:
[0180] A third acquisition submodule is used to acquire a preset first bandwidth speed, a second bandwidth speed and a third bandwidth speed;
[0181] A first migration submodule, configured to migrate data of a first target block in a first queue to a corresponding idle block at a first bandwidth speed;
[0182] A second migration submodule, configured to migrate the data of the second target block in the second queue to the corresponding idle block at a second bandwidth speed;
[0183] A third migration submodule, configured to migrate data of a third target block in a third queue to a corresponding idle block at a third bandwidth speed;
[0184] The first bandwidth speed is smaller than the second bandwidth speed, and the second bandwidth speed is smaller than the third bandwidth speed.
[0185] In some embodiments, it also includes:
[0186] The first judgment module is used to judge whether data migration of the target block is currently being executed when receiving the read / write command; if it is confirmed that data migration of the target block is being executed, then reduce the bandwidth speed of executing the data migration of the target block;
[0187] The second judgment module is used to judge whether the data migration of the target block is completed; if it is confirmed that the data migration of the target block is completed, the data migration process is stopped.
[0188] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.
[0189] In addition, the present invention also provides a computer program product, including a computer program / instruction, which implements the steps of the above-mentioned wear leveling processing method when executed by a processor.
[0190] Figure 3 A schematic diagram of a wear leveling processing device provided by an embodiment of the present invention. Figure 3 As shown, the wear leveling processing device includes:
[0191] A memory 20, for storing computer programs;
[0192] The processor 21 is used to implement the steps of the wear leveling processing method mentioned in the above embodiment when executing the computer program.
[0193] The wear leveling processing device provided in this embodiment may include but is not limited to a smart phone, a tablet computer, a laptop computer, or a desktop computer.
[0194] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of a digital signal processor (DSP), a field programmable gate array (FPGA), and a programmable logic array. The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in an awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 21 may be integrated with a graphics processing unit (GPU), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0195] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 20 is at least used to store the following computer program 201, wherein, after the computer program is loaded and executed by the processor 21, it can implement the relevant steps of the wear leveling processing method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 202 may include Windows, Unix, Linux, etc. Data 203 may include but is not limited to data related to the wear leveling processing method.
[0196] In some embodiments, the wear leveling processing device may further include a display screen 22 , an input and output interface 23 , a communication interface 24 , a power supply 25 , and a communication bus 26 .
[0197] Those skilled in the art will understand that Figure 3 The structure shown in the figure does not constitute a limitation of the wear leveling processing device, and may include more or less components than shown in the figure.
[0198] Finally, the present invention also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps recorded in the above method embodiment are implemented.
[0199] It is understandable that if the method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc. Various media that can store program codes.
[0200] The above is a detailed introduction to a wear leveling processing method, device, equipment and medium provided by the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can be referenced to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the present invention.
[0201] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. A wear leveling method, characterized in that: Applied to a solid state hard disk; the method comprises: Scan each block and calculate the erase count and shutdown time of each block; Get the erase count threshold and shutdown time threshold; Determine a target block and a free block in each block according to the erase count, the shutdown time, the erase count threshold and the shutdown time threshold; wherein the target block is a block containing cold data; After entering the idle mode, the data in each of the target blocks is migrated to the corresponding idle block according to the migration priority corresponding to each of the target blocks.
2. The wear leveling method according to claim 1, characterized in that: Obtaining the erase count threshold includes: Get the total erase count and total number of blocks; determining a quotient of the total erase count and a total number of blocks to determine an average erase count; generating a first erase count threshold, a second erase count threshold and a third erase count threshold respectively according to the average erase count; The first erase count threshold is smaller than the second erase count threshold, and the second erase count threshold is smaller than the third erase count threshold.
3. The wear leveling method according to claim 2, characterized in that: The closing time threshold is obtained, including: Obtain the total closing time and the number of valid blocks; wherein the valid blocks are readable and writable blocks; determining a quotient of the total closing time and the number of valid blocks to determine an average closing time; Generate a first closing time threshold, a second closing time threshold and a third closing time threshold respectively according to the average closing time; The first closing time threshold is smaller than the second closing time threshold, and the second closing time threshold is smaller than the third closing time threshold.
4. The wear leveling method according to claim 3, characterized in that: Determining the target block in each block according to the erase count, the turn-off time, the erase count threshold, and the turn-off time threshold includes: Determine the block to be selected that has reached the capacity limit in each block; Determining the erase count and the shutdown time of the block to be selected; When the erase count of the block to be selected is not greater than the first erase count threshold, and the closing time of the block to be selected is not less than the first closing time threshold and less than the second closing time threshold, determining the block to be selected as the first target block; Putting the first target block into a first queue; When the erase count of the block to be selected is greater than the first erase count threshold and is not greater than the second erase count threshold, and the close time of the block to be selected is not less than the second close time threshold and is less than the third close time threshold, determining that the block to be selected is the second target block; placing the second target block into a second queue; When the erase count of the block to be selected is greater than the second erase count threshold and is not greater than the third erase count threshold, and the shutdown time of the block to be selected is not less than the third shutdown time threshold, determining the block to be selected as the third target block; The third target block is placed in a third queue.
5. The wear leveling method according to claim 4, characterized in that: Determining the free block in each block according to the erase count, the shutdown time, the erase count threshold, and the shutdown time threshold includes: Traversing the erase count and the shutdown time in each block; A block whose corresponding erase count is greater than the third erase count threshold and whose corresponding shutdown time is less than the first shutdown time threshold is determined as the free block.
6. The wear leveling method according to claim 4, characterized in that: Migrating the data in each of the target blocks to the corresponding free blocks according to the migration priority corresponding to each of the target blocks, including: Setting a power consumption value for performing wear leveling in the idle mode; Determine a priority order of the first queue, the second queue, and the third queue; wherein the priority of the first queue is lower than the priority of the second queue, and the priority of the second queue is lower than the priority of the third queue; According to the priority order and the power consumption value, the data of the third target block in the third queue, the data of the second target block in the second queue, and the data of the first target block in the first queue are written into each of the free blocks in sequence.
7. The wear leveling method according to claim 6, characterized in that: Migrating the data in each of the target blocks to the corresponding free blocks includes: Obtaining a preset first bandwidth speed, a second bandwidth speed, and a third bandwidth speed; Migrating the data of the first target block in the first queue to the corresponding free block at the first bandwidth speed; Migrating the data of the second target block in the second queue to the corresponding free block at the second bandwidth speed; Migrating the data of the third target block in the third queue to the corresponding free block at the third bandwidth speed; The first bandwidth speed is smaller than the second bandwidth speed, and the second bandwidth speed is smaller than the third bandwidth speed.
8. The wear leveling method according to any one of claims 1 to 7, characterized in that: Also includes: When receiving a read / write command, determining whether data migration of the target block is currently being performed; If it is confirmed that data migration of the target block is being performed, reducing the bandwidth speed for performing the data migration of the target block; Determining whether the data migration of the target block is completed; If it is confirmed that the data migration of the target block is completed, the data migration process is stopped.
9. A wear leveling processing device, characterized in that: Applied to a solid state hard disk; the device comprises: A scanning and calculating module, used for scanning each block and calculating the erase count and closing time of each block; An acquisition module, used for acquiring an erase count threshold and a shutdown time threshold; A determination module, configured to determine a target block and a free block in each block according to the erase count, the shutdown time, the erase count threshold and the shutdown time threshold; wherein the target block is a block containing cold data; The migration module is used to migrate the data in each target block to the corresponding idle block according to the migration priority corresponding to each target block after entering the idle mode.
10. A wear leveling processing device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the wear leveling processing method as claimed in any one of claims 1 to 8 when executing the computer program.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the wear leveling processing method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Flash memory wear balance method
CN102081576A
Method for realizing static abrasion balance of solid-state storage
CN106951187A
Wear balancing method and device of solid-state hard disk, equipment and storage medium
CN108681435A
Solid state disk, configuration data management method and device thereof and storage medium
CN110658995A
Flash memory wear leveling algorithm based on multiple thresholds
CN110688326A
Cited By
Flash memory management method for edge computing equipment
CN120371218A