A wear leveling space management method and apparatus
By analyzing and rationally allocating write frequencies of storage space, the performance fluctuation problem caused by uneven hard drive wear was resolved, thus optimizing storage performance. Through wear leveling of storage space, storage performance was optimized, performance fluctuations were avoided, and the lifespan of the hard drive was extended.
Patent Information
- Application Number
- CN202310239825.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-13
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2043-03-13
AI Technical Summary
How can existing technologies achieve wear leveling and avoid performance fluctuations while ensuring hard drive storage performance?
By statistically analyzing storage space and rationally allocating it based on differences in write frequency, the preset storage space with the lowest relative write frequency is selected to store data, and the effective data in the space with high void rate is migrated to the free space, thereby optimizing storage space, optimizing storage performance, and avoiding performance fluctuations.
It achieves wear leveling of storage space, maintains a good performance level, avoids performance fluctuations, and extends the lifespan of hard drives.
Smart Images

Figure CN116301617B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of storage space management, in particular to a wear leveling space management method and device. BACKGROUND
[0002] At present, although the solid state disk itself has wear leveling technology, including static wear leveling and dynamic wear leveling, this technology increases the service life of the solid state disk to some extent, but if it completely relies on the wear technology of the hard disk itself, the performance of the hard disk will be reduced to some extent.
[0003] Therefore, how to realize wear leveling of hard disk storage under the premise of guaranteeing the performance of hard disk storage is a technical problem to be solved at present. SUMMARY
[0004] The present application provides a wear leveling space management method and device, which counts the write condition of the storage space, and reasonably allocates based on the difference of the write frequency, so that the wear condition of the storage space is balanced, so that the storage space maintains a good performance level, and performance fluctuations are avoided.
[0005] To achieve the above purpose, the present application provides the following scheme.
[0006] In a first aspect, the present application provides a wear leveling space management method, which comprises the following steps:
[0007] Combining the physical hard disk according to the preset space size to obtain a plurality of corresponding preset storage spaces;
[0008] Statistical write-related parameters for recording the data write condition of each preset storage space;
[0009] Based on the write-related parameters, the preset storage space with the lowest relative write frequency is selected to store the data corresponding to the next data write operation.
[0010] Specifically, the write-related parameters include the number of data writes and the variance of the number of data writes.
[0011] The statistical write-related parameters for recording the data write condition of each preset storage space include the following steps:
[0012] Statistical record the number of data writes of each preset storage space;
[0013] Based on the number of data writes of each preset storage space, the variance of the number of data writes of each preset storage space is calculated.
[0014] Specifically, the selecting the preset storage space with the lowest relative write frequency to store data corresponding to the next data write operation based on the write-related parameters comprises the following steps.
[0015] The selecting the preset storage space with the minimum data write frequency to store data corresponding to the next data write operation comprises the following steps.
[0016] If the data write frequencies of the preset storage spaces are the same, the selecting the preset storage space with the minimum data write frequency variance to store data corresponding to the next data write operation comprises the following steps.
[0017] Further, the method further comprises the following steps.
[0018] Identifying the hole rate of each of the preset storage spaces.
[0019] Transferring the effective data in the preset storage space with the hole rate exceeding the preset hole rate threshold to an idle preset storage space, and emptying the original preset storage space.
[0020] Specifically, the transferring the effective data in the preset storage space with the hole rate exceeding the preset hole rate threshold to an idle preset storage space comprises the following steps.
[0021] Transferring the effective data in the preset storage space with the hole rate exceeding the preset hole rate threshold to the idle preset storage space with the lowest relative write frequency.
[0022] Specifically, the write-related parameters are written to the fixed metadata area of the corresponding preset storage space.
[0023] Specifically, the write-related parameters include data write frequency and data write frequency variance.
[0024] The data write frequency and the data write frequency variance are respectively saved to different red-black trees in the fixed metadata area of the corresponding preset storage space.
[0025] In a second aspect, the present application provides a wear leveling space management device, which comprises:
[0026] A storage space combination module is configured to combine physical hard disks according to a preset space size to obtain a plurality of corresponding preset storage spaces.
[0027] A write operation record module is configured to count write-related parameters for recording data write conditions of each of the preset storage spaces.
[0028] a storage destination selection module configured to select, based on the write-related parameter, a preset storage space with a lowest relative write frequency to store data corresponding to a next data write operation.
[0029] Specifically, the write-related parameter includes a data write frequency and a data write frequency variance value.
[0030] The write operation recording module is further configured to count and record the data write frequency of each preset storage space.
[0031] The write operation recording module is further configured to calculate the data write frequency variance value of each preset storage space based on the data write frequency of each preset storage space.
[0032] Further, the storage destination selection module is further configured to select the preset storage space with a smallest data write frequency value to store data corresponding to a next data write operation.
[0033] The storage destination selection module is further configured to select the preset storage space with a smallest data write frequency variance value to store data corresponding to a next data write operation if the data write frequency values of each preset storage space are the same.
[0034] Further, the device further comprises:
[0035] a storage space arrangement module configured to identify the hole rate of each preset storage space.
[0036] The storage space arrangement module is further configured to transfer valid data in the preset storage space with a hole rate exceeding a preset hole rate threshold to an idle preset storage space, and empty the original preset storage space.
[0037] Further, the storage space arrangement module is further configured to transfer valid data in the preset storage space with a hole rate exceeding a preset hole rate threshold to the idle preset storage space with a lowest relative write frequency.
[0038] Specifically, the write-related parameter is written into a fixed metadata area of the corresponding preset storage space.
[0039] Specifically, the write-related parameter includes a data write frequency and a data write frequency variance value.
[0040] The data write frequency and the data write frequency variance value are respectively saved on different red-black trees in the fixed metadata area of the corresponding preset storage space.
[0041] The technical scheme provided by the present application has the following beneficial effects:
[0042] The application counts the write condition of the storage space, and reasonably allocates based on the difference of the write frequency, so that the wear condition of the storage space is balanced, so that the storage space maintains a good performance level, and performance fluctuations are avoided. BRIEF DESCRIPTION OF DRAWINGS
[0043] Term explanation:
[0044] RAID: Redundant Arrays of Independent Disks, disk array;
[0045] IO: Input / Output, input / output.
[0046] In order to more clearly illustrate the technical solutions in the embodiments of the application, the drawings needed in the embodiment description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative labor.
[0047] Fig. 1 The step flow chart of the wear-balanced space management method provided in the embodiments of the application;
[0048] Fig. 2 The space management distribution diagram of the wear-balanced space management method provided in the embodiments of the application;
[0049] Fig. 3 The write number saving principle diagram of the wear-balanced space management method provided in the embodiments of the application;
[0050] Fig. 4 The space recycling flow diagram of the wear-balanced space management method provided in the embodiments of the application;
[0051] Fig. 5 The structure block diagram of the wear-balanced space management device provided in the embodiments of the application. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical scheme and advantages of the embodiments of the application more clear, the technical scheme in the embodiments of the application will be described clearly and completely below in conjunction with the drawings in the embodiments of the application. Obviously, the described embodiments are part of the embodiments of the application, not all the embodiments. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative labor belong to the scope of protection of the application.
[0053] The embodiments of the present application are further described in detail below with reference to the accompanying drawings.
[0054] The embodiments of the present application provide a wear leveling space management method and device, which statistically records the data writing conditions of the storage spaces and reasonably allocates the storage spaces based on the differences in the writing frequencies, so that the wear conditions of the storage spaces are leveled, and thus the storage spaces maintain a good performance level and avoid performance fluctuation.
[0055] To achieve the above technical effects, the general idea of the present application is as follows:
[0056] A wear leveling space management method, which comprises the following steps:
[0057] S1, combining the physical hard disks according to a preset space size to obtain a plurality of corresponding preset storage spaces;
[0058] S2, statistically recording the writing related parameters for recording the data writing conditions of each preset storage space;
[0059] S3, based on the writing related parameters, selecting the preset storage space with the lowest relative writing frequency to store the data corresponding to the next data writing operation.
[0060] The embodiments of the present application are further described in detail below with reference to the accompanying drawings.
[0061] Referring to Figs. 1-4 The embodiments of the present application provide a wear leveling space management method, which comprises the following steps:
[0062] S1, combining the physical hard disks according to a preset space size to obtain a plurality of corresponding preset storage spaces;
[0063] S2, statistically recording the writing related parameters for recording the data writing conditions of each preset storage space;
[0064] S3, based on the writing related parameters, selecting the preset storage space with the lowest relative writing frequency to store the data corresponding to the next data writing operation.
[0065] In the embodiments of the present application, the data writing conditions of the storage spaces are statistically recorded, and the storage spaces are reasonably allocated based on the differences in the writing frequencies, so that the wear conditions of the storage spaces are leveled, and thus the storage spaces maintain a good performance level and avoid performance fluctuation.
[0066] Specifically, the writing related parameters include the data writing frequency and the data writing frequency variance value.
[0067] The writing related parameters for recording the data writing conditions of each preset storage space include the following steps:
[0068] statistically record data write times of each of the preset storage spaces;
[0069] based on the data write times of each of the preset storage spaces, calculate a data write time variance value of each of the preset storage spaces.
[0070] Specifically, the selecting of the preset storage space with the lowest relative write frequency to store data corresponding to the next data write operation based on the write-related parameters comprises the following steps:
[0071] selecting the preset storage space with the smallest data write time value to store data corresponding to the next data write operation;
[0072] If the data write time values stored in each of the preset storage spaces are the same, the preset storage space with the smallest data write time variance value is selected to store data corresponding to the next data write operation.
[0073] Further, the method further comprises the following steps:
[0074] identifying a hole rate of each of the preset storage spaces;
[0075] transferring valid data in the preset storage space with a hole rate exceeding a preset hole rate threshold to an idle preset storage space, and emptying the original preset storage space.
[0076] Specifically, the transferring of the valid data in the preset storage space with a hole rate exceeding a preset hole rate threshold to an idle preset storage space comprises the following steps:
[0077] transferring the valid data in the preset storage space with a hole rate exceeding a preset hole rate threshold to the idle preset storage space with the lowest relative write frequency.
[0078] Specifically, the write-related parameters are written to a fixed metadata area of the corresponding preset storage space.
[0079] Specifically, the write-related parameters include data write times and data write time variance values.
[0080] The data write times and the data write time variance values are respectively saved to different red-black trees in the fixed metadata area of the corresponding preset storage space.
[0081] In summary, the technical scheme of the embodiments of the present application has the following technical key points:
[0082] The first point, by mathematical statistics and calculation method as the PB Group wear leveling index, including the write times and variance value, but not limited to the write times and variance value;
[0083] The second point, in the storage software space management layer to make the write data more balanced to the hard disk, but not limited to the storage software management layer;
[0084] The third point, according to the PB Group space size unit to migrate the cold data to the idle space, but not limited to the PB Group space size;
[0085] The fourth point, the write times statistics data is saved in the PB Group header area, but not limited to the PB Group header area;
[0086] The fifth point, the write times statistics solidification to the hard disk is at the checkpoint time point, but not limited to the checkpoint time point.
[0087] It should be noted that the embodiments of the present application need a certain prefabricated environment, that is, there is a storage environment composed of multiple disks;
[0088] Based on the technical scheme of the embodiments of the present application, the operation process in actual implementation is given, which is as follows:
[0089] Step one: recombine the physical hard disk according to the specified space size, combine into new physical space according to the raid mode, called PB Group;
[0090] Specifically, first, the space of the hard disk is divided according to the specified size, such as 100GB hard disk, which can be divided into 100 pieces of the same size of physical space, and then these divided spaces are combined according to the copy or RAID, for example, a three-copy PB Group needs three divided pieces to be combined, and the effective space of the above PB Group is 1GB according to the example size calculation.
[0091] Step two: PB Group as a logical volume access physical space;
[0092] Specifically, write in the strip mode, each write will update the PB Group each strip write times and the PB Group total write times in the cache or log;
[0093] At the checkpoint point, these data are written together in the fixed metadata area of PB, generally written in the fixed position of PB Group header, and the cache also saves these data;
[0094] Total write times are saved in a red-black tree manner, the key is the write time value, and the value is the PB Group basic information. The variance value is saved in another red-black tree, which can be the write time variance value, and the value is the PB Group basic information.
[0095] Step three: If the data in this position is rewritten in the case of a full PB Group, it is generally written in a new PB Group in the ROW manner.
[0096] Step four: Data migration is performed.
[0097] Some garbage space will accumulate on the original PB Group. If the garbage space ratio is high, that is, the hole rate is high, the data will be migrated to a new PB Group at this time.
[0098] The migration method is to migrate the valid data on the original PB Group with holes to the idle PB Group. After migration, the original PB Group becomes an idle PB Group. Among them,
[0099] There are two types of idle PB Groups: one is a PB Group that has never written data, and the other is a PB Group that has written data due to data migration to other PB Groups.
[0100] The hole rate refers to the proportion of hole data in the storage space of the PB Group. Hole data can be understood as garbage data. For example, the data in the original PB Group is written from the head to the rear in sequence. Subsequent work, the user modifies part of the data, and the storage system does not rewrite the original location. The new data is written to the new location, and the original location becomes garbage data, that is, hole data.
[0101] Step five: If the user rewrites only part of the area, it will cause part of the PB Group to migrate back and forth, resulting in these areas enjoying too many write times of other areas.
[0102] Step six: Find the PB Group with fewer write times. The minimum key PB group can be directly found from the red-black tree, and it is not in the idle state. The data is migrated to the idle PB Group with a higher write time. The judgment standard is to calculate the total write times of the PB Group and the write time variance value of each block.
[0103] Step seven: At this time, the PB Group with fewer write times before will bear the write of the hot area, reducing the trigger of the hard disk itself.
[0104] in combination with the drawingsFigs. 2 to 4 The technical solutions of the embodiments of the present application are described as follows:
[0105] As shown in the accompanying drawings of the specification Fig. 2 , it is a space management distribution diagram of a block storage. The bottommost is a plurality of physical hard disks. The second layer from the bottom is a space combined by a large block space (1 GB or more) of the physical hard disks according to a RAID, which is referred to as a PB Group.
[0106] The next layer from the bottom is a stripe composed of finer granularity blocks. Small IOs of a volume are combined into large IOs to be written into a disk according to the granularity. The uppermost layer is a space of the volume, which is divided into blocks according to user requirements, generally 4 KB or more.
[0107] As shown in the accompanying drawings of the specification Fig. 3 , the PB Group write frequency statistics are stored in the first fixed space of the PB Group. The write frequency of each block is stored using 8 bytes. The statistics are written at each checkpoint time point.
[0108] Meanwhile, the PB Group write frequency value and the variance value are calculated at each time when space recycling is required, to serve as wear leveling indexes. The total write frequency is selected as the index. In the case of the same write frequency, the variance is selected as the index.
[0109] As shown in the accompanying drawings of the specification Fig. 4 , it is a space recycling process. In the scenario in which the wear leveling function is not opened, space recycling is performed according to the leftmost in the figure. If the user only rewrites part of the area, the write will always be on part of the PB Groups, such as PB Group 0, PB Group 3, PB Group 10, and PB Group 21.
[0110] PB Group 7 and PB Group 5 are rarely written, resulting in unbalanced washing of the physical space, and triggering the wear leveling operation of the internal hard disk at a higher frequency, reducing the write performance of the hard disk.
[0111] In the scenario in which the wear leveling function is opened, space recycling is performed according to the middle and right processes in the figure. The data of PB Group 7 and PB Group 5 with a small write frequency are migrated to the idle PB Groups (selecting the idle PB Groups with a large write frequency), and then the data of PB Group 0 and PB Group 3 with a high hole rate are migrated to PB Group 7 and PB Group 5.
[0112] The PB Groups with a small write frequency are made to undertake the task with a high rewriting frequency, to achieve the goal of balanced wear.
[0113] In summary, the technical scheme of the embodiment of the present application can avoid triggering the wear leveling action of the hard disk as much as possible through an algorithm, and at least has the following advantages:
[0114] First, data can be written to the disk more evenly at the storage software level.
[0115] Second, data leveling operations are performed during a relatively idle period of user business, which will not cause performance fluctuations of business data.
[0116] Third, the wear leveling operation inside the disk is avoided to the greatest extent, so that the solid state disk remains at a high performance level.
[0117] Fourth, the PB Group write count is written at the checkpoint time point, which will not affect the business data.
[0118] Referring to Fig. 5 Based on the same inventive concept as the method embodiment, the embodiment of the present application provides a wear leveling space management device, which comprises:
[0119] A storage space combination module is configured to combine physical hard disks according to a preset space size to obtain a plurality of corresponding preset storage spaces.
[0120] A write operation record module is configured to record write-related parameters for recording the data write situation of each preset storage space.
[0121] A storage destination selection module is configured to select the preset storage space with the lowest write frequency to store the data corresponding to the next data write operation based on the write-related parameters.
[0122] In the embodiment of the present application, the write situation of the storage space is counted, and reasonable allocation is made based on the difference in write frequency, so that the wear situation of the storage space is balanced, thereby keeping the storage space at a good performance level and avoiding performance fluctuations.
[0123] Specifically, the write-related parameters include the data write count and the data write count variance.
[0124] The write operation record module is further configured to record the data write count of each preset storage space.
[0125] The write operation record module is further configured to calculate the data write count variance of each preset storage space based on the data write count of each preset storage space.
[0126] Further, the storage destination selection module is further configured to select the preset storage space with the smallest data write count to store the data corresponding to the next data write operation.
[0127] The storage destination selection module is further configured to select the preset storage space storing data corresponding to a next data write operation if the data write frequency values of the preset storage spaces are the same.
[0128] Further, the device further comprises:
[0129] The storage space arrangement module is configured to identify the hole rate of each of the preset storage spaces.
[0130] The storage space arrangement module is further configured to transfer the effective data in the preset storage space with the hole rate exceeding the preset hole rate threshold to the idle preset storage space and empty the original preset storage space.
[0131] Further, the storage space arrangement module is further configured to transfer the effective data in the preset storage space with the hole rate exceeding the preset hole rate threshold to the idle preset storage space with the lowest relative write frequency.
[0132] Specifically, the write-related parameters are written into the fixed metadata area of the corresponding preset storage space.
[0133] Specifically, the write-related parameters include data write frequency and data write frequency variance.
[0134] The data write frequency and the data write frequency variance are respectively saved on different red-black trees in the fixed metadata area of the corresponding preset storage space.
[0135] It should be noted that the corresponding technical problems, technical means and technical effects of the wear leveling space management device provided by the embodiments of the present application are similar to the principles of the wear leveling space management method.
[0136] It should be noted that in the present application, the relationship terms such as "first" and "second" 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 the entities or operations. Moreover, the terms "include", "contain" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of another identical element in the process, method, article or device including the element.
[0137] The foregoing detailed description of the application has been presented for purposes of illustration and description. Various modifications and changes can be made to these embodiments without departing from the spirit and scope of the application. It is intended that the scope of the application should not be limited by the particular representative embodiments described above. Rather, the general scope of the application is to be determined by the appended claims and their equivalents.
Claims
1. A space management method for wear leveling, characterized in that, The method includes the following steps: Combine physical hard drives according to preset space sizes to obtain multiple corresponding preset storage spaces; Statistics are compiled on write-related parameters used to record the data writing status of each preset storage space; Based on the write-related parameters, the preset storage space with the lowest relative write frequency is selected to store the data corresponding to the next data write operation. The write-related parameters include the number of data writes and the variance of the number of data writes; The statistics used to record the data writing status of each preset storage space include the following steps in the write-related parameters: Record the number of times data is written to each of the preset storage spaces; Based on the number of data writes in each of the preset storage spaces, calculate the variance of the number of data writes in each of the preset storage spaces; The method further includes the following steps: Identify the void ratio of each of the preset storage spaces; Valid data in the preset storage space where the void ratio exceeds a preset void ratio threshold is transferred to an idle preset storage space, and the original preset storage space is cleared. The step of selecting the preset storage space with the lowest relative write frequency to store the data corresponding to the next data write operation based on the write-related parameters includes the following steps: The preset storage space with the smallest number of data write operations is selected to store the data corresponding to the next data write operation; If the number of data writes stored in each of the preset storage spaces is the same, then the preset storage space with the smallest variance of the number of data writes is selected to store the data corresponding to the next data write operation. The step of transferring valid data in the preset storage space where the void ratio exceeds a preset void ratio threshold to an idle preset storage space includes the following steps: Valid data in the preset storage space where the void ratio exceeds a preset void ratio threshold is transferred to the free preset storage space with the lowest relative write frequency.
2. The space management method for wear leveling as described in claim 1, characterized in that: The relevant parameters are written to the fixed metadata area of the corresponding preset storage space.
3. The space management method for wear leveling as described in claim 1, characterized in that: The write-related parameters include the number of data writes and the variance of the number of data writes; The number of data writes and the variance of the number of data writes are respectively stored in different red-black trees within the fixed metadata area of the corresponding preset storage space.
4. A wear-leveling space management device, characterized in that, The device includes: The storage space combination module is used to combine physical hard drives according to preset space sizes to obtain multiple corresponding preset storage spaces; The write operation record module is used to collect statistics on write-related parameters used to record the data write status of each preset storage space; The storage destination selection module is used to select the preset storage space with the lowest relative write frequency to store the data corresponding to the next data write operation based on the write-related parameters. The write-related parameters include the number of data writes and the variance of the number of data writes; The write operation recording module is also used to count and record the number of data writes to each of the preset storage spaces; The write operation recording module is also used to calculate the variance of the number of data writes for each of the preset storage spaces based on the number of data writes for each preset storage space. The device further includes: A storage space management module is used to identify the void ratio of each of the preset storage spaces; The storage space management module is also used to transfer valid data in the preset storage space where the void rate exceeds a preset void rate threshold to an idle preset storage space, and clear the original preset storage space. The storage destination selection module, based on the write-related parameters, selects the preset storage space with the lowest relative write frequency to store the data corresponding to the next data write operation, including: The preset storage space with the smallest number of data write operations is selected to store the data corresponding to the next data write operation; If the number of data writes stored in each of the preset storage spaces is the same, then the preset storage space with the smallest variance of the number of data writes is selected to store the data corresponding to the next data write operation. The storage space reorganization module transfers valid data in the preset storage space where the void ratio exceeds a preset void ratio threshold to an idle preset storage space, including: Valid data in the preset storage space where the void ratio exceeds a preset void ratio threshold is transferred to the free preset storage space with the lowest relative write frequency.
Citation Information
Patent Citations
Write operation method and system of memory, electronic equipment and medium
CN111651126A
Space recovery method, device and equipment
CN113687774A