Storage management method and electronic equipment
By acquiring the wear rate of hard disk blocks and performing type conversion, the problem of uneven wear of different types of hard disk blocks was solved, achieving wear equalization and lifespan extension of storage devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INSPUR SUZHOU INTELLIGENT TECH CO LTD
- Filing Date
- 2025-11-28
- Publication Date
- 2026-04-17
AI Technical Summary
In existing technologies, different types of hard disk blocks support different maximum number of erase/write cycles, resulting in inconsistent wear rates. This makes it difficult to effectively balance the wear differences between different types of hard disk blocks, causing storage devices to fail prematurely due to excessive local wear.
By obtaining the wear change rate of different types of hard disk blocks, wear differences can be determined, and hard disk block type conversion can be performed when wear is mismatched to achieve wear leveling. For example, some SLC hard disk blocks can be converted to TLC hard disk blocks, and vice versa.
It achieves wear leveling between different types of hard disk blocks, avoids excessive wear on some hard disk blocks of the storage device, and extends the service life of the storage device.
Smart Images

Figure CN121879670A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of hard disk storage technology, and more specifically to storage management methods and electronic devices. Background Technology
[0002] With the continuous growth in data storage demand, some hard disk blocks in storage devices suffer from significantly higher wear and tear than other areas due to long-term high-frequency data read and write tasks. If not properly managed, storage devices are prone to premature failure due to excessive wear and tear on local hard disk blocks.
[0003] Currently, some technologies distribute data evenly across different hard drive blocks by adjusting the data write location to mitigate localized wear and extend the lifespan of storage devices. However, because different types of hard drive blocks support different maximum write / erase cycles, their wear rates vary. Therefore, the above methods are insufficient to effectively balance the wear differences between different types of hard drive blocks, leaving the overall lifespan of the storage device limited by high-wear areas. Improvements are needed. Summary of the Invention
[0004] This invention provides a storage management method and electronic device to at least solve the problem in related technologies where different types of hard disk blocks have different wear differences, causing storage devices to fail prematurely due to excessive local wear.
[0005] In a first aspect, the present invention provides a storage management method, comprising: A first wear change rate of a first type of hard disk block and a second wear change rate of a second type of hard disk block are obtained. Each storage unit of the first type of hard disk block is used to store a first number of data bits, and each storage unit of the second type of hard disk block is used to store a second number of data bits. The wear difference between the first type of hard disk block and the second type of hard disk block is determined based on the first wear change rate and the second wear change rate. If, based on wear differences, it is determined that there is a wear mismatch between the first type of hard disk blocks and the second type of hard disk blocks, then at least a portion of the first type of hard disk blocks will be converted to the second type of hard disk blocks, and at least a portion of the second type of hard disk blocks will be converted to the first type of hard disk blocks.
[0006] In a second aspect, the present invention provides a storage management device, comprising: The wear change rate acquisition module is used to acquire the first wear change rate of the first type of hard disk block and the second wear change rate of the second type of hard disk block. Each storage unit of the first type of hard disk block is used to store a first number of data bits, and each storage unit of the second type of hard disk block is used to store a second number of data bits. The wear difference calculation module is used to determine the wear difference between the first type of hard disk block and the second type of hard disk block based on the first wear change rate and the second wear change rate. The hard disk block conversion module is used to convert at least a portion of the first type hard disk blocks into second type hard disk blocks and at least a portion of the second type hard disk blocks into first type hard disk blocks if it is determined, based on wear differences, that there is a wear mismatch between the first type hard disk blocks and the second type hard disk blocks.
[0007] Thirdly, the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the memory management method of the first aspect or any corresponding embodiment described above.
[0008] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions, which are used to cause a computer to perform the storage management method of the first aspect or any corresponding embodiment described above.
[0009] Fifthly, the present invention provides a computer program product, including computer instructions for causing a computer to execute the storage management method of the first aspect or any corresponding embodiment thereof.
[0010] In some embodiments of this application, the wear change rates of the first type of hard disk blocks and the second type of hard disk blocks are obtained, and the wear difference between the first type of hard disk blocks and the second type of hard disk blocks is determined. When a wear mismatch is detected, at least a portion of the first type of hard disk blocks and the second type of hard disk blocks are converted. In this way, the storage data bits of the hard disk block storage units can be adjusted according to the wear state of different types of hard disk blocks to achieve wear balance between different types of hard disk blocks, thereby preventing some hard disk blocks of the storage device from excessively wearing out and failing prematurely, and thus extending the service life of the storage device. Attached Figure Description
[0011] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0012] Figure 1 A flowchart illustrating the storage management method provided in an embodiment of this application; Figure 2 A schematic diagram of the hard disk structure provided in the embodiments of this application; Figure 3 A schematic diagram of the module of the storage management device provided in the embodiments of this application; Figure 4 A schematic diagram of the modules of an electronic device provided in an embodiment of this application. Detailed Implementation
[0013] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0014] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0015] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0016] Currently, the storage medium of SSD (Solid State Disk) is mostly NAND flash memory. Due to the advantages of NAND flash memory such as non-volatility and high-speed read and write, SSD has been widely used as the main storage device in various storage systems.
[0017] Based on the different numbers of bits of data that can be stored in each storage cell, NAND flash memory can be divided into the following four categories: 1) SLC (Single-Level Cell): Each storage cell of an SLC stores only 1 bit of data, and each storage cell has only 2 charge states. 2) MLC (Multi-Level Cell): Each storage cell of an MLC can store 2 bits of data, and each storage cell has 4 different charge states; 3) TLC (Triple-Level Cell): Each storage cell of a TLC can store 3 bits of data, and each storage cell has 8 different charge states; 4) QLC (Quad-Level Cell). Each storage cell in a QLC can store 4 bits of data, and each storage cell has 16 different charge states.
[0018] However, due to the physical characteristics of NAND flash memory, each storage cell can only withstand a limited number of P / E (Program / Erase) operations. Furthermore, as the number of bits stored in a storage cell increases, the storage density per unit space significantly increases, reducing the voltage interval between adjacent charge states. This leads to interference between charge states, further reducing the number of P / E operations that the device can withstand, thus affecting the read / write reliability and storage lifespan of the storage device.
[0019] Based on the above description, TLC SSDs have become the mainstream storage device due to their good balance between storage density, manufacturing cost, and storage performance. In practical applications, a portion of the disk blocks in a TLC SSD are typically configured as SLC disk blocks. These SLC disk blocks can be used for cache areas or areas storing metadata. That is, a TLC SSD can include both SLC and TLC disk blocks simultaneously. Each storage unit in an SLC disk block stores 1 bit of data, while each storage unit in a TLC disk block stores 3 bits of data.
[0020] In related technologies, wear leveling is used to manage the lifespan of SSDs. By evenly distributing data write locations, it prevents some hard drive blocks from failing prematurely due to long-term, frequent read / write operations. However, for the aforementioned SLC / TLC hybrid architecture, since the SLC storage area only stores 1 bit of data, while the PLC storage area can store 3 bits of data, there is a significant difference in the P / E cycle tolerance of individual storage units. Simply put, under the same P / E operation, the wear rate of the SLC storage area is much lower than that of the TLC area. If a uniform distribution method is used for wear leveling, it may cause the TLC storage area to fail prematurely, while the SLC storage area still maintains good performance. In other words, the storage device is still limited by some hard drive blocks, resulting in a shortened overall lifespan.
[0021] In view of this, this application provides a storage management method that can solve the above problems. This storage management method can be applied to various storage devices that use NAND flash memory as the storage medium.
[0022] It should be noted that the technical solution of this application is not only applicable to the SLC / TLC hybrid architecture described above, but can also be extended to storage devices that combine multiple types of storage units such as SLC / QLC and TLC / QLC. However, since the SLC / TLC hybrid architecture is still the mainstream storage device and is widely used, the following embodiments will be described in detail using the SLC / TLC hybrid architecture as an example to facilitate understanding of the technical solution of this application.
[0023] See also Figure 1 , Figure 1 This is a flowchart illustrating the storage management method provided in an embodiment of this application, as shown below. Figure 1 As shown, the storage management method includes the following steps S101 to S103.
[0024] Step S101: Obtain the first wear change rate of the first type of hard disk block and the second wear change rate of the second type of hard disk block. Each storage unit of the first type of hard disk block is used to store a first number of data bits, and each storage unit of the second type of hard disk block is used to store a second number of data bits.
[0025] Specifically, if the storage device is an SLC / TLC hybrid architecture, the first type of hard disk block corresponds to an SLC hard disk block, and the first number of data bits is 1 bit; the second type of hard disk block corresponds to a TLC hard disk block, and the second number of data bits is 3 bits.
[0026] In this embodiment, the rate of change of the number of erase / write operations on the first type of hard disk block over time can be calculated as the first wear rate of change, and the rate of change of the number of erase / write operations on the second type of hard disk block over time can be calculated as the second wear rate of change. For example, assuming that the first type of hard disk block has 200 erase / write operations in the first second and 250 erase / write operations in the second second, and the second type of hard disk block has 180 erase / write operations in the first second and 250 erase / write operations in the second second, then the first wear rate of change can be 50, and the second wear rate of change can be 70.
[0027] Step S102: Based on the first wear change rate and the second wear change rate, determine the wear difference between the first type of hard disk block and the second type of hard disk block.
[0028] Specifically, after obtaining the first and second wear change rates, the degree of wear difference between the first and second types of hard disk blocks can be determined by comparing their magnitudes. For example, if the first wear change rate is 50 and the second wear change rate is 70, then the wear difference can be 20. A greater wear difference means a more uneven wear rate among the different hard disk blocks. In cases of uneven wear rates, some hard disk blocks may fail prematurely, rendering the entire hard drive unusable.
[0029] Alternatively, the wear difference can also be represented by the ratio of the absolute value of the difference between the first wear change rate and the second wear change rate to the smaller of the first wear change rate and the second wear change rate. This more accurately reflects the relative difference in the wear change rates of the two. The above-mentioned wear difference can be calculated as shown in expression (1): (1) in, Indicates wear differences; Indicates the first rate of change of wear; This represents the second rate of wear change.
[0030] Step S103: If, based on wear differences, it is determined that there is a wear mismatch between the first type of hard disk blocks and the second type of hard disk blocks, then at least a portion of the first type of hard disk blocks are converted to the second type of hard disk blocks, and at least a portion of the second type of hard disk blocks are converted to the first type of hard disk blocks.
[0031] Specifically, when the wear difference between type 1 and type 2 hard disk blocks exceeds a preset threshold, it can be determined as a wear mismatch. In this case, at least some type 1 and type 2 hard disk blocks will be converted to balance the wear levels of the two types. For example, suppose hard disk blocks A, B, and C are type 1 hard disk blocks, and hard disk blocks D, E, and F are type 2 hard disk blocks. When the wear change rate of type 1 hard disk blocks is greater than that of type 2 hard disk blocks, type 2 hard disk blocks D and E can be converted to type 1 hard disk blocks, and type 1 hard disk blocks A and B can be converted to type 2 hard disk blocks. After the conversion, the wear change rate of type 2 hard disk blocks D and E will increase, while the wear change rate of type 1 hard disk blocks A and B will decrease. This achieves wear balancing between different types of hard disk blocks.
[0032] It should be noted that for SLC / TLC hybrid architecture storage devices, when the wear rate of one storage area is significantly higher than that of the other, wear leveling can be achieved by swapping the hard disk blocks of the two storage areas, which have fixed storage capacity.
[0033] For example, if the first type of hard disk block corresponds to an SLC hard disk block and the second type of hard disk block corresponds to a TLC hard disk block, and the wear change rate of the SLC hard disk block is detected to be significantly lower than that of the TLC hard disk block, then some SLC hard disk blocks can be restored to TLC hard disk blocks. At the same time, TLC hard disk blocks with higher wear change rates can be converted to SLC hard disk blocks. This achieves dynamic balancing of the wear state between the two types of hard disk blocks without changing their storage capacity.
[0034] The storage management method provided in this embodiment obtains the wear change rate corresponding to the first type of hard disk blocks and the second type of hard disk blocks respectively, and determines the wear difference between the first type of hard disk blocks and the second type of hard disk blocks. When a wear mismatch is detected, at least a portion of the first type of hard disk blocks are converted to the second type of hard disk blocks. In this way, the storage data bits of the hard disk block storage unit can be adjusted according to the wear state of different types of hard disk blocks to achieve wear balance between different types of hard disk blocks, thereby avoiding premature failure of some hard disk blocks of the storage device due to excessive wear, and thus extending the service life of the storage device.
[0035] Furthermore, considering the difference in the maximum number of write cycles supported by Type 1 and Type 2 hard disk blocks, relying solely on the rate of change of write cycles over time may not objectively and accurately assess the wear rate of hard disk blocks. For example, suppose Type 1 hard disk blocks support a maximum of 1000 write cycles, while Type 2 hard disk blocks support 3000. In this case, because Type 2 hard disk blocks support more write cycles, even if the rate of change of write cycles for Type 2 hard disk blocks is slightly faster than that for Type 1 hard disk blocks, both types of hard disk blocks may fail at the same time. Therefore, when the rate of change of write cycles for Type 2 hard disk blocks is slightly faster than that for Type 1 hard disk blocks, it may not be necessary to adjust the hard disk block type.
[0036] Therefore, in some embodiments, obtaining the first wear change rate of the first type of hard disk block and the second wear change rate of the second type of hard disk block includes: At multiple time points, based on the maximum number of erase / write cycles of the first type of hard disk block and the number of erase / write cycles of the first type of hard disk block at the corresponding time points, the wear rate of the first type of hard disk block is determined, and based on the wear rate of the first type of hard disk block at multiple time points, the first wear change rate is determined; At multiple time points, based on the maximum number of erase / write cycles for the second type of hard disk block and the number of erase / write cycles for the second type of hard disk block at the corresponding time points, the wear rate of the second type of hard disk block is determined, and based on the wear rate of the second type of hard disk block at multiple time points, the second wear change rate is determined.
[0037] Specifically, the first wear change rate of the first type of hard disk block and the second wear change rate of the second type of hard disk block can be obtained by acquiring the number of erase and write operations at multiple time points, thereby calculating the wear rate at the corresponding time point, and then calculating the corresponding wear change rate based on the wear rate at multiple time points.
[0038] In this embodiment, the wear rate of any target type of hard disk block, either the first type or the second type, can be calculated as shown in expression (2): (2) in, Indicates the first Wear rate corresponding to each time point; Indicates the number of times a hard disk block has been erased and written; Indicates the number of disk blocks of the target type; Indicates the maximum number of erase / write cycles for the target type of hard disk block.
[0039] In the above embodiments, on the one hand, when calculating the wear rate, the maximum number of erase / write cycles supported by different types of hard disk blocks is considered, which can make the final wear rate change rate more accurate; on the other hand, by calculating the wear rate at multiple time points and analyzing its changing trend, the first wear rate change rate of the first type of hard disk block and the second wear rate change rate of the second type of hard disk block can be obtained, which can more accurately reflect the wear of different types of hard disk blocks, and thus provide a reliable basis for subsequent hard disk block type conversion.
[0040] In some embodiments, determining the wear rate of a target type hard disk block for any of the first type hard disk blocks and the second type hard disk blocks includes: If the target type of hard disk blocks are distributed across multiple different hard disk regions, then the wear rate of the target type of hard disk blocks should be determined separately for each hard disk region. Based on the wear rate of multiple hard drive regions, determine the maximum value of wear rate fluctuation between hard drive regions; If the maximum wear rate fluctuation is lower than the fluctuation threshold, the average wear rate of multiple hard disk areas will be used as the wear rate of the target type hard disk block.
[0041] Specifically, the aforementioned target type of hard disk block can be used to characterize either a first-type or second-type hard disk block. Since hard disks are typically divided into multiple hard disk regions, the data read / write frequencies differ across these regions, resulting in inconsistent wear levels on the hard disk blocks within each region.
[0042] For the aforementioned hard drive area, via Figure 2 Further explanation, in conjunction with reference Figure 2 , Figure 2 This is a schematic diagram of the hard disk structure provided in the embodiments of this application, such as... Figure 2 As shown, it can be understood that a hard drive includes: 1) Die: Each die is an independent NAND flash memory chip; 2) Plane: Each grain is usually divided into multiple planes, and each plane can perform read and write operations in parallel; 3) Hard disk block: Hard disk blocks with the same number are distributed in different planes. The hard disk block is the basic unit of erasure operation; 4) Page: Each hard disk block consists of multiple pages, and the page is the basic unit of read and write operations; 5) Storage cell: Each storage page consists of multiple storage cells, which are the smallest physical units of data storage; 6) Superblock: A superblock is a block of disks with the same number in different planes of the same die; a superblock can also be formed by blocks with the same number in different planes of different dies. The wear and tear of the blocks in the same superblock usually tends to be consistent.
[0043] In this embodiment, the aforementioned hard disk region is a superblock composed of hard disk blocks with the same number. The aforementioned target type of hard disk blocks may be distributed across multiple superblocks. Therefore, when calculating the wear rate of any target type of hard disk block, the wear rate of each superblock can be calculated, and the maximum wear rate can be subtracted from the minimum wear rate to determine the maximum value of the wear rate fluctuation among the superblocks.
[0044] If the maximum fluctuation value is lower than the preset fluctuation threshold, it indicates that the wear level among the superblocks is relatively balanced. In this case, the average wear rate of each superblock can be used as the final wear rate of the target type hard disk block. Then, the average wear rate of the target type hard disk block at multiple time points is obtained, and the wear change rate of the target type hard disk block is determined, thereby obtaining the wear difference of different types of hard disk blocks to determine whether hard disk block type conversion is necessary.
[0045] In the above embodiments, by performing wear rate statistics and fluctuation analysis on the superblocks distributed among the target type of hard disk blocks, the uniformity of wear distribution can be effectively identified. When the fluctuation is small, the average value is used to represent the overall wear level, thereby improving the accuracy of the wear rate of the target type of hard disk blocks.
[0046] In some embodiments, the storage management method further includes: If the maximum value of the wear rate fluctuation is not lower than the fluctuation threshold, then find the first hard disk area with a wear rate greater than the first wear rate threshold and the second hard disk area with a wear rate less than the second wear rate threshold, where the first wear rate threshold is greater than the second wear rate threshold. In at least one of the hard disk regions of the first hard disk region and the second hard disk region, at least a portion of the target type hard disk blocks are replaced with another type of hard disk blocks, wherein when the target type hard disk block is a first type hard disk block, the other type hard disk block is a second type hard disk block, and when the target type hard disk block is a second type hard disk block, the other type hard disk block is a first type hard disk block.
[0047] Specifically, the first wear rate threshold and the second wear rate threshold are used to characterize the critical points of high wear rate and low wear rate, respectively; the first hard disk area and the second hard disk area correspond to the areas with high wear and low wear, respectively.
[0048] In this embodiment, if the maximum wear rate fluctuation among the various superblocks is not lower than the fluctuation threshold, it indicates that the wear distribution among the various superblocks is uneven, with some superblocks experiencing severe wear while others have relatively light wear. In this case, the first hard disk region and the second hard disk region can be searched, and some hard disk blocks within them can be replaced to balance the overall wear.
[0049] For example, the first type of hard disk block is SLC, and the second type is TLC. SLC is distributed in superblocks 1, 2, and 3, while TLC is distributed in superblocks 4, 5, and 6. When the wear rate of superblocks 1 and 2 is detected to be higher than a first wear rate threshold, while the wear rate of superblocks 5 and 6 is lower than a second wear rate threshold, it indicates that the SLC type hard disk blocks in superblocks 1 and 2 are severely worn, while the TLC type hard disk blocks in superblocks 5 and 6 have relatively low wear. In this case, some SLC blocks in superblock 1 or 2 can be replaced with TLC, and the corresponding TLC blocks in superblock 5 or 6 can be replaced with SLC, thereby achieving wear leveling.
[0050] In the above embodiments, by determining whether the wear rate fluctuation between superblocks exceeds the threshold, the uneven wear distribution in the storage medium can be dynamically identified, and the hard disk block type can be replaced based on the wear characteristics of different hard disk areas, effectively alleviating the problem of local excessive wear.
[0051] In some embodiments, in at least one hard disk region of a first hard disk region and a second hard disk region, replacing at least a portion of target type hard disk blocks with another type of hard disk blocks includes: Replace at least a portion of the target type hard disk blocks in the first hard disk region with another type of hard disk blocks whose erase / write cycles are less than the threshold of the first write cycle; Replace at least a portion of the target type hard disk blocks in the second hard disk region with another type of hard disk blocks whose erase / write count exceeds the threshold of the second count; The threshold for the first count is less than the threshold for the second count.
[0052] Specifically, the number of write / erase cycles characterizes the usage level of hard drive blocks, i.e., the frequency of data writing and erasing, and can also reflect the hotness or coldness of the data. The first and second write / erase thresholds are used to determine whether replacement is necessary based on the wear level of the target type of hard drive blocks.
[0053] To facilitate understanding, the following example illustrates the concept: Assume that type 1 hard disk blocks are distributed in superblock 1 and superblock 2, and type 2 hard disk blocks are distributed in superblock 3 and superblock 4. Currently, superblock 1 is detected to be located in the first hard disk block region, and superblock 3 is located in the second hard disk region. If the number of erase / write cycles for superblock 1 exceeds a second erase / write cycle threshold, and the number of erase / write cycles for superblock 3 is below a first erase / write cycle threshold, then superblock 1 and superblock 3 can be type-replaced; that is, superblock 1 is changed to type 2 hard disk block, and superblock 3 is changed to type 1 hard disk block.
[0054] In the above embodiments, by setting a first write count threshold and a second write count threshold, and selecting the hard disk blocks to be converted accordingly, idle or lightly loaded hard disk blocks with low write counts can be introduced into the high wear area, while hard disk blocks with high write counts can be migrated to the low wear area, thereby slowing down the overall wear rate while ensuring storage performance.
[0055] In some embodiments, converting at least a portion of a first-type hard disk block to a second-type hard disk block, and converting at least a portion of a second-type hard disk block to a first-type hard disk block, includes: If the average wear rate of the first type of hard disk blocks at multiple time points is greater than the average wear rate of the second type of hard disk blocks at multiple time points, then at least a portion of the second type of hard disk blocks with fewer than three write cycles will be converted to the first type of hard disk blocks, and at least a portion of the first type of hard disk blocks will be converted to the second type of hard disk blocks in descending order of wear rate. If the average wear rate of the first type of hard disk blocks at multiple time points is less than the average wear rate of the second type of hard disk blocks at multiple time points, then at least a portion of the second type of hard disk blocks with more than a fourth write / erase count threshold will be converted to first type of hard disk blocks, and at least a portion of the first type of hard disk blocks will be converted to second type of hard disk blocks in order of wear rate from low to high.
[0056] Specifically, the third and fourth number thresholds are used to distinguish the number of times a hard disk block has been erased and written.
[0057] In this embodiment, if the average wear rate of the first type of hard disk block is greater than that of the second type of hard disk block at multiple time points, it indicates that the first type of hard disk block is used more frequently and has a higher risk of wear. In this case, the second type of hard disk block with fewer than three write cycles should be converted to the first type of hard disk block first. Then, the first type of hard disk block with a higher wear rate should be converted to the second type of hard disk block in descending order to balance the overall wear.
[0058] For example, suppose the first type of hard disk blocks includes A1, A2, and A3, and the second type of hard disk blocks includes B1, B2, and B3. If the average wear rate of the A type blocks is higher than that of the B type blocks, and the number of erase / write cycles of B1 is lower than the third write threshold, then B1 will be converted to the first type first. At the same time, the hard disk block with the highest wear rate among A1, A2, and A3 will be converted to the second type first.
[0059] In this embodiment, if the average wear rate of the first type of hard disk block at multiple time points is less than that of the second type of hard disk block, it indicates that the second type of hard disk block is used more frequently and has a higher risk of wear. In this case, the second type of hard disk block with more than the fourth write count threshold should be converted to the first type of hard disk block. Then, the first type of hard disk block with a lower wear rate should be converted to the second type of hard disk block in order from low to high to achieve wear leveling.
[0060] In the above embodiments, by comparing the average wear rate of the first type of hard disk blocks and the second type of hard disk blocks at multiple time points, and dynamically adjusting the hard disk block type in combination with the erase / write count threshold, and sorting and converting the wear rate, some hard disk blocks with high wear are prevented from being used continuously, thereby extending the overall lifespan of the storage device.
[0061] In some embodiments, it is determined whether the wear between the first type of hard disk block and the second type of hard disk block is matched based on one of the following conditions: The wear difference is greater than the difference threshold; The wear difference is greater than the difference threshold, and the duration has reached the preset duration; The wear difference is greater than the difference threshold, and the predicted duration reaches the preset duration.
[0062] In the above embodiments, the wear imbalance between the first type of hard disk block and the second type of hard disk block is determined through the three condition judgment mechanisms described above. When the duration of the wear difference exceeding the difference threshold / the predicted duration reaches a preset duration, a hard disk block type conversion operation is performed. This avoids the problem of frequent hard disk block replacement, which can cause unstable data read and write operations and affect storage performance.
[0063] In some embodiments, the storage management method further includes: If the wear difference is greater than the first difference threshold, then a first number of first type hard disk blocks are converted into second type hard disk blocks, and a first number of second type hard disk blocks are converted into first type hard disk blocks; If the wear difference is greater than the second difference threshold, then the second number of first type hard disk blocks are converted into second type hard disk blocks, and the second number of second type hard disk blocks are converted into first type hard disk blocks; Among them, the first difference threshold is less than the second difference threshold, and the first quantity is less than the second quantity.
[0064] For example, suppose the total number of hard disk blocks is 300, the number of type 1 hard disk blocks is 100, the number of type 2 hard disk blocks is 200, the first difference threshold is 5%, the second difference threshold is 10%, the first quantity is 50, and the second quantity is 100. If the wear difference is 7%, then 50 type 1 hard disk blocks and 50 type 2 hard disk blocks will be converted; if the wear difference is 12%, then 100 type 1 hard disk blocks and 100 type 2 hard disk blocks will be converted.
[0065] In the above embodiments, a dynamic hierarchical response is achieved by setting a linkage mechanism between multi-level difference thresholds and corresponding conversion quantities. For different degrees of wear differences, different intensity wear leveling strategies are adopted, which can not only promptly suppress the continuous deterioration of mild wear imbalance, but also quickly reconstruct the storage layout in the case of severe wear imbalance, thereby effectively extending the overall lifespan of the hard drive.
[0066] In some embodiments, the storage management method further includes: Based on the historical erase and write data of the first type of hard disk blocks, a first frequency of erasing and writing of the first type of hard disk blocks is determined, and based on the historical erase and write data of the second type of hard disk blocks, a second frequency of erasing and writing of the second type of hard disk blocks is determined. Based on the first frequency, the second frequency, and the current write / erase count of each hard disk block, the first type of hard disk blocks and the second type of hard disk blocks are reclassified.
[0067] In these embodiments, this is equivalent to reallocating the hard drive type of each hard drive block at an appropriate time (e.g., after hard drive formatting), based on the historical write / erase frequency of the first and second type hard drive blocks. For example, before hard drive formatting, hard drive blocks A, B, C, and D belong to the first type, and hard drive blocks E, F, G, and H belong to the second type. After hard drive formatting, the historical hard drive type of each hard drive block is invalidated, and hard drive blocks A, B, C, D, E, F, G, and H can be sorted in descending order of write / erase frequency, with the sorting queue being A, H, G, F, E, C, G, and H. Furthermore, based on the historical write / erase frequency of the first and second type hard drive blocks, if it is found that the historical write / erase frequency of the first type hard drive blocks is lower, then the hard drive blocks with more write / erase frequency can be designated as the first type hard drive blocks, i.e., hard drive blocks A, H, G, and F are designated as the first type hard drive blocks, and the remaining hard drive blocks E, C, G, and H are designated as the second type hard drive blocks. In this way, the hard drive block type is reallocated.
[0068] In the above embodiments, by analyzing the differences in the erase and write frequencies of different types of hard disk blocks, and dynamically adjusting the hard disk block type division in combination with the current number of erase and write operations, the wear distribution under high-frequency usage scenarios is made more balanced.
[0069] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0070] Embodiments of this application also provide a storage management device, which can be referred to in conjunction with the following: Figure 3 , Figure 3 Schematic diagrams of a storage management device provided for some embodiments of this application, such as Figure 3 As shown, the storage management device includes the following modules: Wear change rate acquisition module 301 is used to acquire the first wear change rate of the first type of hard disk block and the second wear change rate of the second type of hard disk block. Each storage unit of the first type of hard disk block is used to store a first number of data bits, and each storage unit of the second type of hard disk block is used to store a second number of data bits. Wear difference calculation module 302 is used to determine the wear difference between a first type of hard disk block and a second type of hard disk block based on a first wear change rate and a second wear change rate; The hard disk block conversion module 303 is used to convert at least a portion of the first type hard disk blocks into second type hard disk blocks and at least a portion of the second type hard disk blocks into first type hard disk blocks if it is determined, based on wear differences, that there is a wear mismatch between the first type hard disk blocks and the second type hard disk blocks.
[0071] In some embodiments, the wear rate acquisition module 301 is further configured to: obtain a first wear rate of change for a first type of hard disk block and a second wear rate of change for a second type of hard disk block; At multiple time points, based on the maximum number of erase / write cycles of the first type of hard disk block and the number of erase / write cycles of the first type of hard disk block at the corresponding time points, the wear rate of the first type of hard disk block is determined, and based on the wear rate of the first type of hard disk block at multiple time points, the first wear change rate is determined; At multiple time points, based on the maximum number of erase / write cycles for the second type of hard disk block and the number of erase / write cycles for the second type of hard disk block at the corresponding time points, the wear rate of the second type of hard disk block is determined, and based on the wear rate of the second type of hard disk block at multiple time points, the second wear change rate is determined.
[0072] In some embodiments, for any target type of hard disk block among the first type and the second type, the wear rate of the target type hard disk block is determined, and the wear rate acquisition module 301 is further configured to: If the target type of hard disk blocks are distributed across multiple different hard disk regions, then the wear rate of the target type of hard disk blocks should be determined separately for each hard disk region. Based on the wear rate of multiple hard drive regions, determine the maximum value of wear rate fluctuation between hard drive regions; If the maximum wear rate fluctuation is lower than the fluctuation threshold, the average wear rate of multiple hard disk areas will be used as the wear rate of the target type hard disk block.
[0073] In some embodiments, the hard disk block conversion module 303 is further configured to: If the maximum value of the wear rate fluctuation is not lower than the fluctuation threshold, then find the first hard disk area with a wear rate greater than the first wear rate threshold and the second hard disk area with a wear rate less than the second wear rate threshold, where the first wear rate threshold is greater than the second wear rate threshold. In at least one of the hard disk regions of the first hard disk region and the second hard disk region, at least a portion of the target type hard disk blocks are replaced with another type of hard disk blocks, wherein when the target type hard disk block is a first type hard disk block, the other type hard disk block is a second type hard disk block, and when the target type hard disk block is a second type hard disk block, the other type hard disk block is a first type hard disk block.
[0074] In some embodiments, in at least one hard disk region of the first hard disk region and the second hard disk region, at least a portion of the target type hard disk blocks are replaced with hard disk blocks of another type. The hard disk block conversion module 303 is further configured to: Replace at least a portion of the target type hard disk blocks in the first hard disk region with another type of hard disk blocks whose erase / write cycles are less than the threshold of the first write cycle; Replace at least a portion of the target type hard disk blocks in the second hard disk region with another type of hard disk blocks whose erase / write count exceeds the threshold of the second count; The threshold for the first count is less than the threshold for the second count.
[0075] In the following embodiment, at least a portion of the first type of hard disk blocks are converted to second type hard disk blocks, and at least a portion of the second type of hard disk blocks are converted to first type hard disk blocks. The hard disk block conversion module 303 is further configured to: If the average wear rate of the first type of hard disk blocks at multiple time points is greater than the average wear rate of the second type of hard disk blocks at multiple time points, then at least a portion of the second type of hard disk blocks with fewer than three write cycles will be converted to the first type of hard disk blocks, and at least a portion of the first type of hard disk blocks will be converted to the second type of hard disk blocks in descending order of wear rate. If the average wear rate of the first type of hard disk blocks at multiple time points is less than the average wear rate of the second type of hard disk blocks at multiple time points, then at least a portion of the second type of hard disk blocks with more than a fourth write / erase count threshold will be converted to first type of hard disk blocks, and at least a portion of the first type of hard disk blocks will be converted to second type of hard disk blocks in order of wear rate from low to high.
[0076] In some embodiments, the disk block conversion module 303 is further configured to determine whether the wear between the first type of disk block and the second type of disk block matches based on one of the following conditions: The wear difference is greater than the difference threshold; The wear difference is greater than the difference threshold, and the duration has reached the preset duration.
[0077] The wear difference is greater than the difference threshold, and the predicted duration reaches the preset duration.
[0078] In some embodiments, the hard disk block conversion module 303 is further configured to: If the wear difference is greater than the first difference threshold, then a first number of first type hard disk blocks are converted into second type hard disk blocks, and a first number of second type hard disk blocks are converted into first type hard disk blocks; If the wear difference is greater than the second difference threshold, then the second number of first type hard disk blocks are converted into second type hard disk blocks, and the second number of second type hard disk blocks are converted into first type hard disk blocks; Among them, the first difference threshold is less than the second difference threshold, and the first quantity is less than the second quantity.
[0079] In some embodiments, the hard disk block conversion module 303 is further configured to: Based on the historical erase and write data of the first type of hard disk blocks, a first frequency of erasing and writing of the first type of hard disk blocks is determined, and based on the historical erase and write data of the second type of hard disk blocks, a second frequency of erasing and writing of the second type of hard disk blocks is determined. Based on the first frequency, the second frequency, and the current write / erase count of each hard disk block, the first type of hard disk blocks and the second type of hard disk blocks are reclassified.
[0080] The storage management device provided in this embodiment of the invention can execute the storage management method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects for executing the method. Further functional descriptions of the various modules and units described above are the same as in the corresponding embodiments described above, and will not be repeated here.
[0081] Embodiments of this application also provide an electronic device, such as... Figure 4 As shown, it includes a memory 10 and a processor 20. The memory 10 stores a computer program, and the processor 20 is configured to run the computer program to perform the steps in any of the above-described storage management method embodiments.
[0082] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described storage management method embodiments when it is run.
[0083] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0084] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described storage management method embodiments.
[0085] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described storage management method embodiments.
[0086] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0087] The foregoing has provided a detailed description of a storage management method and electronic device provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only intended to help understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A storage management method, characterized in that, The method includes: A first wear change rate of a first type of hard disk block and a second wear change rate of a second type of hard disk block are obtained, wherein each storage unit of the first type of hard disk block is used to store a first number of data bits and each storage unit of the second type of hard disk block is used to store a second number of data bits. Based on the first wear change rate and the second wear change rate, the wear difference between the first type of hard disk block and the second type of hard disk block is determined; If, based on the wear difference, it is determined that there is a wear mismatch between the first type of hard disk block and the second type of hard disk block, then at least a portion of the first type of hard disk block is converted to the second type of hard disk block, and at least a portion of the second type of hard disk block is converted to the first type of hard disk block.
2. The method according to claim 1, characterized in that, The process of obtaining the first wear change rate of the first type of hard disk blocks and the second wear change rate of the second type of hard disk blocks includes: At multiple time points, based on the maximum number of erase / write cycles of the first type of hard disk block and the number of erase / write cycles of the first type of hard disk block at the corresponding time points, the wear rate of the first type of hard disk block is determined, and based on the wear rate of the first type of hard disk block at multiple time points, the first wear change rate is determined; At multiple time points, based on the maximum number of erase / write cycles of the second type of hard disk block and the number of erase / write cycles of the second type of hard disk block at the corresponding time points, the wear rate of the second type of hard disk block is determined, and based on the wear rate of the second type of hard disk block at multiple time points, the second wear change rate is determined.
3. The method according to claim 2, characterized in that, For any target type of hard disk block among the first type and the second type, determine the wear rate of the target type hard disk block, including: If the target type of hard disk blocks are distributed across multiple different hard disk regions, then the wear rate of the target type of hard disk blocks is determined separately for each hard disk region. Based on the wear rate of multiple hard drive regions, determine the maximum value of wear rate fluctuation between hard drive regions; If the maximum wear rate fluctuation is lower than the fluctuation threshold, the average wear rate of the multiple hard disk regions is taken as the wear rate of the target type hard disk block.
4. The method according to claim 3, characterized in that, The method further includes: If the maximum value of the wear rate fluctuation is not lower than the fluctuation threshold, then find the first hard disk region with a wear rate greater than the first wear rate threshold and the second hard disk region with a wear rate less than the second wear rate threshold, wherein the first wear rate threshold is greater than the second wear rate threshold. In at least one hard disk area of the first hard disk area and the second hard disk area, at least a portion of the target type hard disk blocks are replaced with another type of hard disk blocks, wherein when the target type hard disk block is the first type hard disk block, the other type hard disk block is the second type hard disk block, and when the target type hard disk block is the second type hard disk block, the other type hard disk block is the first type hard disk block.
5. The method according to claim 4, characterized in that, The step of replacing at least a portion of target type hard disk blocks with another type of hard disk blocks in at least one hard disk region of the first hard disk region and the second hard disk region includes: Replace at least a portion of the target type hard disk blocks in the first hard disk region with another type of hard disk blocks whose erase / write cycles are less than the threshold of the first write cycle; Replace at least a portion of the target type hard disk blocks in the second hard disk region with another type of hard disk blocks whose write / erase count exceeds the second threshold; The first number threshold is less than the second number threshold.
6. The method according to claim 2, characterized in that, The step of converting at least a portion of the first type of hard disk blocks to the second type of hard disk blocks, and converting at least a portion of the second type of hard disk blocks to the first type of hard disk blocks, includes: If the average wear rate of the first type of hard disk block at multiple time points is greater than the average wear rate of the second type of hard disk block at multiple time points, then at least a portion of the second type of hard disk blocks with fewer than three write cycles will be converted to the first type of hard disk blocks, and at least a portion of the first type of hard disk blocks will be converted to the second type of hard disk blocks in descending order of wear rate. If the average wear rate of the first type of hard disk block at multiple time points is less than the average wear rate of the second type of hard disk block at multiple time points, then at least a portion of the second type of hard disk blocks with more than a fourth write / erase count threshold will be converted to the first type of hard disk blocks, and at least a portion of the first type of hard disk blocks will be converted to the second type of hard disk blocks in order of wear rate from low to high.
7. The method according to claim 1 or 2, characterized in that, Determine whether the wear patterns between the first type of hard disk block and the second type of hard disk block match based on one of the following conditions: The wear difference is greater than the difference threshold; The wear difference is greater than the difference threshold, and the duration has reached the preset duration; The wear difference is greater than the difference threshold, and the predicted duration reaches the preset duration.
8. The method according to claim 7, characterized in that, The method further includes: If the wear difference is greater than a first difference threshold, then a first number of the first type of hard disk blocks are converted into the second type of hard disk blocks, and a first number of the second type of hard disk blocks are converted into the first type of hard disk blocks; If the wear difference is greater than the second difference threshold, then a second number of the first type of hard disk blocks are converted into the second type of hard disk blocks, and a second number of the second type of hard disk blocks are converted into the first type of hard disk blocks; Wherein, the first difference threshold is less than the second difference threshold, and the first quantity is less than the second quantity.
9. The method according to claim 1 or 2, characterized in that, The method further includes: Based on the historical erase and write data of the first type of hard disk block, a first frequency of erasing and writing of the first type of hard disk block is determined, and based on the historical erase and write data of the second type of hard disk block, a second frequency of erasing and writing of the second type of hard disk block is determined; Based on the first frequency, the second frequency, and the current write / erase count of each hard disk block, the first type of hard disk block and the second type of hard disk block are reclassified.
10. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory being used to store a computer program that, when executed by the processor, implements the method as described in any one of claims 1 to 9.