A ZNS SSD wear leveling method based on LSM tree

Through the LSM tree data heat classification and wear-aware zone allocation method, the problem of uneven wear between zones in ZNS SSDs is solved, the life span is extended and the wear is balanced, thus improving the service life of SSDs.

CN116107513BActive Publication Date: 2025-09-09CHONGQING UNIV OF POSTS & TELECOMM
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310166502.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-24
Publication Date
2025-09-09
Estimated Expiration
2043-02-24

AI Technical Summary

Technical Problem

In LSM-tree-based ZNS SSDs, the wear imbalance problem between zones leads to a shortened lifespan, and existing allocation methods fail to effectively solve the wear imbalance problem between zones.

Method used

Dynamically balance wear between zones through LSM tree data heat classification, erase range selection, and wear-aware zone allocation. Specific steps include data heat level classification, erase range selection, and cold data migration. This ensures that high-heat data is stored in zones with long lifespans, while low-heat data is stored in zones with short lifespans. Cold data migration further balances wear.

Benefits of technology

It effectively improves the service life of ZNS SSDs, has lower overhead, achieves wear balance between zones, and extends the overall service life of SSDs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116107513B_ABST
    Figure CN116107513B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of computer storage, and specifically relates to a ZNS SSD wear leveling method based on an LSM tree. The method comprises the following steps: inputting new data into a ZNS SSD, and classifying the heat level of the new data by using an LSM tree data heat classification method before input; dividing the ZNS SSD into multiple erase range intervals by using an erase range interval selection method, and determining the corresponding erase range interval according to the heat level of the new data; selecting an idle zone within the erase range interval corresponding to the new data to store the new data; and if no idle zone exists within the erase range interval, allocating an idle zone to the new data by using a wear-aware zone allocation method to further balance the wear between zones. The present invention balances the wear between zones in a ZNS SSD, effectively prolongs the service life of ZNS SSDs, and has low overhead.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer storage, and in particular relates to a ZNS SSD wear leveling method based on an LSM tree. Background Art

[0002] NVMe Zoned Namespace (ZNS) is emerging as a promising storage interface for flash-based SSDs. ZNS SSDs group multiple blocks on different flash chips into a sequentially written area, reducing the cost of on-device DRAM for mapping tables. At the same time, ZNS SSDs transfer the responsibility of data management to the host, avoiding garbage collection and over-provisioning within the device. Ideally, the host can classify application-specific data by lifespan based on access patterns and assign data with similar lifespans to a zone. In this way, all data in a zone can be invalidated at the same time, further eliminating the write amplification problem caused by data migration.

[0003] The Log-Structured Merge Tree (LSM-Tree) is a high-performance data structure for write-intensive workloads and is widely adopted by NoSQL databases such as Google's LevelDB, Facebook's RocksDB, and Alibaba's XEngine. To achieve high write throughput, the LSM-Tree converts random writes to sequential writes on the storage, sacrificing read performance. At the same time, a tiered compaction strategy is widely utilized to organize LSM-Tree data into multiple, finitely sized, and sorted levels to reduce space amplification and read amplification. The sequential writes guaranteed by the LSM-Tree can be efficiently handled by the sequential write zones of ZNS SSDs.

[0004] While SSDs offer high read and write performance, they have a limited lifespan. SSDs cannot overwrite a block and must be erased before they can be used again. The number of times a block can be erased in an SSD is limited. After a certain number of erases, performance may degrade and error rates may increase. In severe cases, the entire block may be worn through, becoming a bad block. Once this occurs, access performance and data reliability of the entire SSD are impacted. ZNS SSDs are effective at storing LSM-tree data, but block wear also needs to be considered. Many studies have focused on storing data with similar LSM-tree lifespans in the same zone of a ZNS SSD to avoid data migration caused by zone reclamation. However, these allocation methods do not consider inter-zone wear. LSM-tree data exhibits widely varying lifespans. Without proper data allocation between zones, short-lived data may often be allocated to a small number of zones, resulting in a highly unbalanced distribution of erase counts across zones. This highly unbalanced wear between zones shortens the limited lifespan of ZNS SSDs. Summary of the Invention

[0005] To solve the problem of uneven wear between zones on LSM-tree-based ZNS SSDs, the present invention provides a ZNS SSD wear leveling method based on LSM tree, comprising the following steps:

[0006] S1. Input a new data item into the ZNS SSD and classify the new data item's heat level using the LSM tree data heat classification method before input.

[0007] S2. Use the erase range selection method to divide the ZNS SSD into multiple erase ranges and determine the corresponding erase range based on the heat level of the newly added data;

[0008] S3. Select an idle zone within the erase range corresponding to the newly added data to store the new data. If no idle zone exists within the erase range, allocate an idle zone to the new data using the wear-aware zone allocation method to further balance wear between zones.

[0009] Furthermore, an LSM tree data heat classification method is constructed based on the data stratification characteristics and data access frequency of the LSM tree; wherein, the LSM tree is divided into multiple levels to store data, and the data stratification characteristics mainly refer to that the life cycle of the data stored in the LSM tree is related to the level it is in. The higher the level where the data is stored, the longer the life cycle of the data.

[0010] Furthermore, the specific expression of the heat level in the LSM tree data heat classification method is:

[0011]

[0012] Here, Hot(i) represents the heat level of the data stored in the Li-th layer of the LSM tree, n represents the maximum level of the LSM tree, and the heat level of the data stored in the L0 and L1 layers of the LSM tree is defined as Hot(1).

[0013] Furthermore, the process of dividing the ZNS SSD into multiple erase range intervals using the erase range interval selection method is as follows:

[0014] S21. Obtain the erase count of each zone in the ZNS SSD and filter out the maximum and minimum erase counts.

[0015] S22. The difference between the maximum and minimum erase counts is used as the total erase count range of the ZNS SSD. The total erase count range is divided into multiple erase range intervals. Each zone is added to the corresponding erase range interval according to its own erase count.

[0016] S23. The total number of erase range intervals is the same as the maximum heat level number of the data in the LSM tree, and one erase range interval corresponds to one heat level.

[0017] Furthermore, when a free zone is allocated to new data through the wear-aware zone allocation method, if the heat level of the new data is different from the heat level corresponding to the erase range interval to which the free zone belongs, the cold data migration method is used to migrate data to the zone within the erase range interval corresponding to the heat level of the new data.

[0018] Further, S31. Determine whether there is an idle zone within the erasure range corresponding to the newly added data.

[0019] If yes, then use the free zone to store the new data; if no, proceed to step S32;

[0020] S32 uses a cold data migration method to migrate the data within the erase range and determines whether there is a successful migration zone. If so, the zone is successfully migrated to store new data. If not, proceeds to step S33;

[0021] S33. In an erasure range interval greater than the heat level corresponding to the erasure range interval, obtain an idle zone with the minimum number of erasures, recorded as Z-max; in an erasure range interval less than the heat level corresponding to the erasure range interval, obtain an idle zone with the maximum number of erasures, recorded as Z-min

[0022] S34. Calculate the distance D-max and D-min between the erase range interval and Z-max and Z-min, respectively;

[0023] S35. Determine whether D-max is greater than D-min. If so, use Z-min to store the new data; if not, use Z-max to store the new data.

[0024] Furthermore, the process of migrating data in the erase range using the cold data migration method includes:

[0025] S41. Get the heat level i corresponding to the erase range and the maximum heat level n of the LSM tree;

[0026] S42. If i is less than n, proceed to step S43;

[0027] S43. Determine whether there is a zone with a heat level of n in the erase range; if so, proceed to step S44; if not, execute n = n-1 and return to step S42;

[0028] S44. If there are multiple zones with stored data of heat level n, select the zone with the least valid data for data migration; if there is only one zone with stored data of heat level n, directly migrate the data to that zone.

[0029] Beneficial effects of the present invention:

[0030] The present invention proposes a ZNS SSD wear leveling method based on LSM tree. Through dynamic and static wear leveling methods, the wear between zones in ZNS SSDs is balanced, effectively improving the service life of ZNS SSDs with low overhead.

[0031] Firstly, for the data heat classification problem of LSM tree, an LSM tree data heat classification method is constructed according to the data layering characteristics and data access frequency; the LSM tree data heat classification method divides data heat in a way that conforms to the data access characteristics.

[0032] The present invention designs an erase range selection method based on the wear information of the zone, divides the ZNS SSD into multiple erase range intervals, and determines the corresponding erase range interval according to the heat level of the newly added data; so that high-heat data can be placed in the zone with a long life, and low-heat data can be placed in the zone with a short life, making zone allocation more intelligent.

[0033] The present invention also proposes a cold data migration method to address the problem of cold data occupying zones for a long time, further balancing the wear between zones in a low-overhead manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 is a flow chart of the method of the present invention;

[0035] Figure 2 A flowchart of allocating free zones to newly added data in the method of the present invention;

[0036] Figure 3 This is a flow chart of the cold data migration method in the present invention;

[0037] Figure 4 This is a schematic diagram of the heat level division of the LSM tree of the present invention;

[0038] Figure 5 This is a model diagram corresponding to the data and free Zone partitions of the LSM tree of the present invention. DETAILED DESCRIPTION

[0039] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0040] The present invention provides a ZNS SSD wear leveling method based on LSM tree, which mainly designs an LSM tree data heat classification method, an erase range interval selection method and a wear-aware zone allocation method to perform ZNS SSD wear leveling.

[0041] A ZNS SSD wear leveling method based on LSM tree, such as Figure 1 As shown, the following steps are included:

[0042] S1. Input a new data item into the ZNS SSD and classify the new data item's heat level using the LSM tree data heat classification method before input.

[0043] S2. Use the erase range selection method to divide the ZNS SSD into multiple erase ranges and determine the corresponding erase range based on the heat level of the newly added data;

[0044] S3. Select an idle zone within the erase range to store the new data; if there is no idle zone within the erase range, allocate an idle zone to the new data using the wear-aware zone allocation method to further balance the wear between zones.

[0045] Specifically, we construct an LSM tree data heat classification method based on the data stratification characteristics of the LSM tree and the frequency of data access. This method is used to classify data heat levels before data is stored. The LSM tree is divided into multiple levels to store data. The data stratification characteristics include two aspects:

[0046] The first aspect is that the lifecycle of data stored in an LSM tree is related to the level it is stored in. Data stored at the same level has the same lifecycle. In addition, the higher the level in the LSM tree, the longer the lifecycle of the data stored there.

[0047] The second aspect is that the lifecycles of the data stored in the L0 and L1 layers of the LSM tree are similar.

[0048] The data lifecycle refers to the hotness or coldness of the data, that is, the data freshness. The higher the level of data stored, the lower the freshness, that is, the colder the data. Conversely, the higher the freshness of the data, the hotter the data.

[0049] The specific expression of heat level in the LSM tree data heat classification method is:

[0050]

[0051] Among them, Hot(i) represents the heat level of the data stored in the Li-th layer of the LSM tree, n represents the maximum level of the LSM tree, and the heat level division diagram of the LSM tree is as follows Figure 4 As shown, the heat level of the data stored in the L0 layer and the L1 layer of the LSM tree is defined as Hot(1).

[0052] In order to place the data of LSM tree according to the wear of ZNS SSDs and realize wear balancing between zones. Figure 5 As shown in the figure, we propose an erase range selection method to balance wear between zones. The core idea is to divide all zones into n erase ranges (n is the maximum heat level of the data in the LSM tree) based on the wear of the zones. Each erase range is sorted from low to high based on the wear level of the zones contained within it. Different heat levels of the LSM tree correspond to different ranges of zone erase ranges. The data file calculates the corresponding zone erase range based on the heat level and then selects a free zone.

[0053] Specifically, the process of dividing the ZNS SSD into multiple erase range intervals using the erase range interval selection method is as follows:

[0054] S21. Obtain the erase count of each zone in the ZNS SSD and filter out the maximum and minimum erase counts.

[0055] S22. The difference between the maximum and minimum erase counts is used as the total erase count range of the ZNS SSD. The total erase count range is divided into multiple erase range intervals. Each zone is added to the corresponding erase range interval according to its own erase count.

[0056] S23. The total number of erase range intervals is the same as the maximum heat level number of the data in the LSM tree, and one erase range interval corresponds to one heat level, that is, all zones in the erase range interval correspond to the same heat level.

[0057] Specifically, the total erase count range of the ZNS SSD is divided according to the maximum heat level n of the LSM tree, and n erase range intervals are obtained. The interval R of each erase range interval is the same, which is expressed as:

[0058]

[0059] Among them, EC maxis the maximum erase count of ZNS SSDs, EC min The minimum erase count of ZNS SSDs.

[0060] The present invention also balances the wear between zones through a wear-aware zone allocation method, which stores the hottest data in the zone with the least wear, while the zone with the greatest wear is used to store the coldest data. Other data can be allocated to zones with the same heat level.

[0061] Specifically, when there is no free zone in the erase range corresponding to the newly added data, a free zone is allocated to the newly added data using the wear-aware zone allocation method, such as Figure 2 As shown, specifically including:

[0062] S31 uses a cold data migration method to migrate data within the erase range and determines whether there is a successful migration zone. If so, the zone is successfully migrated to store new data. If not, proceeds to step S32;

[0063] S32. In an erasure range interval greater than the corresponding heat level of the erasure range interval, obtain an idle zone with the minimum number of erasures, denoted as Z-max; in an erasure range interval less than the corresponding heat level of the erasure range interval, obtain an idle zone with the maximum number of erasures, denoted as Z-min;

[0064] S33 calculates the distance D-max and D-min between the erase range interval and Z-max and Z-min respectively;

[0065] Specifically, the median of all erasure times within the erasure range is used and subtracted from the erasure times of Z-max and Z-min respectively to obtain the corresponding distance.

[0066] S34. Determine whether D-max is greater than D-min. If so, use Z-min to store the newly added data; if not, use Z-max to store the newly added data. The degree of wear of the zone mentioned in this embodiment is related to the number of times it is erased. The more times a zone is erased, the more serious its wear. The maximum wear mentioned in this embodiment is a relative concept. At a certain point in time, if the degree of wear of a certain zone is higher than that of other zones, then this zone is the zone with the greatest loss and will be used to store cold data. Since cold data may not be updated for a long time, other zones storing hot data are constantly erased and recycled. Over time, the zone with the greatest wear used to store cold data may become the zone with the least wear of the ZNS SSD. Therefore, the present invention proposes a cold data migration method to further balance the wear between zones.

[0067] Specifically, if Figure 3 As shown in the figure, the process of migrating data in the range to be migrated and erased using the cold data migration method includes:

[0068] S41. Get the heat level i corresponding to the range to be migrated and the maximum heat level n of the LSM tree;

[0069] S42. If i is less than n, proceed to step S43;

[0070] S43 determines whether there is a zone with a heat level of n for the data stored in the range to be migrated and erased; if so, proceeds to step S44; if not, executes n = n-1 and returns to step S43;

[0071] S44. If there are multiple zones with stored data of heat level n, select the zone with the least valid data for data migration; if there is only one zone with stored data of heat level n, directly migrate the data to that zone.

[0072] Valid data refers to data in the zone that is also stored in the LSM tree; if the data in the zone is deleted by the LSM, then this data is invalid data.

[0073] In the present invention, unless otherwise clearly stipulated and limited, the terms "installation", "setting", "connection", "fixation", "rotation" and the like should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium; it can be the internal connection of two elements or the interaction relationship between two elements. Unless otherwise clearly defined, ordinary technicians in this field can understand the specific meanings of the above terms in the present invention according to the specific circumstances.

[0074] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.

Claims

1. A ZNS SSD wear leveling method based on LSM tree, characterized in that: The following steps are involved: S1. Input a new data item into the ZNS SSD and classify the new data item's heat level using the LSM tree data heat classification method before input. An LSM tree data popularity classification method is constructed based on the data hierarchical characteristics of the LSM tree and the frequency of data access. The LSM tree is divided into multiple levels to store data. The data hierarchical characteristics include: the life cycle of data stored in the LSM tree is related to its level; the higher the level of data storage, the longer the data life cycle. The specific expression of heat level in the LSM tree data heat classification method is: Where Hot(i) represents the heat level of the data stored in the Lith layer of the LSM tree, n represents the maximum level of the LSM tree, and the heat level of the data stored in the L0 and L1 layers of the LSM tree is defined as Hot(1); S2. Use the erase range selection method to divide the ZNS SSD into multiple erase ranges and determine the corresponding erase range based on the heat level of the newly added data; The process of dividing the ZNS SSD into multiple erase range intervals using the erase range interval selection method is as follows: S21. Obtain the erase count of each zone in the ZNS SSD and filter out the maximum and minimum erase counts. S22. The difference between the maximum and minimum erase counts is used as the total erase count range of the ZNS SSD. The total erase count range is divided into multiple erase range intervals. Each zone is added to the corresponding erase range interval according to its own erase count. S23. The total number of erase range intervals is the same as the maximum heat level of the data in the LSM tree, and one erase range interval corresponds to one heat level; S3. Select an idle zone within the erase range to store the new data. If no idle zone exists within the erase range, allocate an idle zone to the new data using a wear-aware zone allocation method to further balance wear between zones, including: S31 determines whether there is an idle zone within the erase range corresponding to the new data. If so, the idle zone is used to store the new data. If not, the process proceeds to step S32. S32 uses a cold data migration method to migrate the data within the erase range and determines whether there is a successful migration zone. If so, the zone is successfully migrated to store new data. If not, proceeds to step S33; S33. In an erasure range interval greater than the heat level corresponding to the erasure range interval, obtain an idle zone with the minimum number of erasures, recorded as Z-max; in an erasure range interval less than the heat level corresponding to the erasure range interval, obtain an idle zone with the maximum number of erasures, recorded as Z-min S34. Calculate the distance D-max and D-min between the erase range interval and Z-max and Z-min, respectively; S35. Determine whether D-max is greater than D-min. If so, use Z-min to store the new data; if not, use Z-max to store the new data.

2. The ZNS SSD wear leveling method based on LSM tree according to claim 1, characterized in that: When allocating a free zone to new data using the wear-aware zone allocation method, if the heat level of the new data is different from the heat level corresponding to the erase range interval to which the free zone belongs, the cold data migration method is used to migrate data to the zone within the erase range interval corresponding to the heat level of the new data.

3. The ZNS SSD wear leveling method based on LSM tree according to any one of claims 1 or 2, characterized in that: The process of migrating data within the erase range using the cold data migration method includes: S41. Get the heat level i corresponding to the erase range and the maximum heat level n of the LSM tree; S42. If i is less than n, proceed to step S43; S43 determines whether there is a zone with a heat level of n for the stored data in the erase range interval; If yes, proceed to step S44; if no, execute n=n-1 and return to step S43; S44. If there are multiple zones with stored data of heat level n, select the zone with the least valid data for data migration; if there is only one zone with stored data of heat level n, directly migrate the data to that zone.

Citation Information

Patent Citations

  • LSM tree storage engine construction method and system

    CN115168317A

  • I / O scheduling method for guaranteeing ZNS-SSD access fairness

    CN115328398A