A Wear-Aware Space Allocation Method Based on a Persistent Memory File System

By using multi-level linked lists and a wear-aware recycling mechanism, the performance overhead of persistent memory allocators during wear leveling is resolved, achieving efficient wear leveling and allocation and improving system performance.

CN116126743BActive Publication Date: 2026-05-26GUIZHOU UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUIZHOU UNIV
Filing Date
2023-02-17
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing persistent memory allocators suffer from significant performance overhead during wear leveling, particularly inefficient in managing multi-granularity allocation requests and wear precision.

Method used

By employing a multi-level allocation mechanism and a wear-aware recycling mechanism, the PM space is divided into multi-level linked list groups, combined with a write counter and wear record, to achieve wear leveling and efficient allocation of blocks.

Benefits of technology

It achieves low-overhead, high-precision wear leveling, reduces external debris, improves distribution and recycling efficiency, and reduces system performance loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure QLYQS_1
    Figure QLYQS_1
  • Figure BDA0004084661710000041
    Figure BDA0004084661710000041
  • Figure BDA0004084661710000091
    Figure BDA0004084661710000091
Patent Text Reader

Abstract

This invention belongs to the field of computer technology, specifically relating to a wear-aware space allocation method based on a persistent memory file system. The method includes: dividing the PM space into blocks composed of several consecutive physical pages; dividing all blocks into G groups based on block size; organizing all blocks within the same group into singly linked lists and storing the head nodes of the G linked lists in an array; setting a write counter for each page to record page write activity and storing all write counters in an array; when an I / O request arrives, allocating candidate blocks directly from the corresponding groups using a multi-level allocation mechanism based on the I / O request size, and reclaiming free blocks using a wear-aware reclamation mechanism. This invention achieves low-overhead, high-precision wear leveling by using a multi-level allocation mechanism to directly allocate candidate blocks from the corresponding groups and a wear-aware reclamation mechanism to reclaim free blocks, significantly improving system performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer technology, specifically relating to a wear-aware persistent memory file system space allocation method. Background Technology

[0002] In recent years, numerous new types of persistent memory (PM) have emerged, offering advantages such as low latency, non-volatility, byte-addressability, low power consumption, and high storage density. Examples include Phase Change Memory (PCM), Resistive RAM (ReRAM), and 3D-Xpoint. These persistent memories can be directly connected to the memory bus via DIMM slots, providing high-speed byte-addressable data access while persistently storing data like a hard disk. Furthermore, the CPU can directly access persistent memory using load / store instructions. The continuous development of high-capacity persistent memory technology has driven advancements in the field of storage system software optimization research. In recent years, numerous persistent memory file systems (PMS) using persistent memory as storage devices have also emerged, such as BPFS, SCMFS, PMFS, SIMFS, NOVA, and HiNFS. These file systems fully leverage the advanced features of new persistent memory in their software design philosophy. By optimizing the organization of file data and data consistency mechanisms, they greatly improve the performance of the file system, enabling file access throughput to reach the GB / s level.

[0003] However, large-capacity persistent memory generally suffers from read-write asymmetry, meaning that write latency / power consumption is higher than read latency / power consumption. It also generally has low write tolerance (PCM's write tolerance is approximately 10). 8 For example, when the number of write operations to a PCM storage unit reaches 10... 8 When the wear and tear on a small number of storage units is significant, the data in the entire file system becomes unreliable, severely shortening the lifespan of persistent memory. Therefore, it is necessary to distribute the large number of write operations to a few storage units across other storage spaces, ensuring that the wear and tear on each storage unit is relatively even, thereby improving the lifespan of persistent memory.

[0004] Existing persistent memory allocators that consider write wear generally achieve a certain degree of wear leveling by prioritizing the allocation of low-wear pages, but they still cannot effectively handle the trade-off between performance and wear accuracy in persistent memory wear leveling. The following explanation uses DWARM and WMAlloc as examples.

[0005] DWARM divides all free pages in PM into several groups based on the page's write counter, such asFigure 1 As shown in (a), all free pages belonging to the same group are linked together by a singly linked list. DWARM then always allocates PM pages from the group with the least wear, or reclaims free pages to the corresponding group based on the write counter. To reduce the overhead of locating the corresponding group, DWARM constructs a linked list in the DRAM to manage all groups. Furthermore, DWARM proposes an adaptive wear range determination algorithm to dynamically adjust the wear range of all groups.

[0006] However, while DWARM achieves a certain level of wear leveling by selecting low-wear pages for each allocation request, it still has the following two problems: First, wear leveling and performance overhead are closely related to the set grouping, that is, the fewer the groups, the more unbalanced the wear of the PM, and the more groups, the greater the metadata management overhead of wear leveling; Second, DWARM is a single-granularity allocator, which can only allocate one 4KB page at a time. For multi-granularity allocation requests, multiple allocation operations are required to complete the allocation, which leads to a serious degrade in DWARM performance.

[0007] like Figure 1 As shown in (b), to provide multi-granularity allocation while achieving wear leveling, WMAlloc constructs 11 min-heap trees (numbered from 0 to 10) to manage free blocks, sorted according to the wear level of the blocks. For the i-th min-heap tree, if i is less than 10, the block node in that heap represents a block of 2... i A block consists of 512 consecutive pages; if i equals 10, the block size managed by this min-heap tree exceeds 512 consecutive pages. Therefore, each min-heap tree, except for the 10th, represents an allocation granularity. When the required block size is less than or equal to 512 pages, WMAlloc only needs to allocate the required block from the corresponding min-heap tree once. To address the problem of uneven wear between heaps, WMAlloc proposes a wear-leveling node migration mechanism, exchanging nodes in the heap tree with the least wear with nodes in the heap tree with the most wear. Furthermore, WMAlloc's wear-aware reclamation forest mechanism temporarily divides released blocks into multiple red-black tree groups based on page write counters to accelerate block merging operations. During migration, WMAlloc always migrates blocks from the red-black tree with the least wear to the min-heap tree.

[0008] WMAlloc is a multi-granularity allocator, but it still has four problems. First, maintaining the block node order in the min-heap tree is costly. Second, for merging free blocks, WMAlloc has a high time complexity of locating adjacent blocks, which is O(N), where N represents the height of the red-black tree. Furthermore, like DWRAM, WMAlloc's wear accuracy is closely related to the wear range set by its red-black tree. Finally, when the number of free blocks in the min-heap tree is less than a set threshold, larger free blocks in other min-heap trees or red-black trees will be split into multiple sub-blocks and then migrated to that min-heap tree. During splitting, the wear of each sub-block needs to be recalculated, which incurs significant performance overhead. For example, assuming a block containing 15 consecutive pages in the red-black tree will be migrated to the 3rd min-heap tree, this block will be split into four sub-blocks containing 8, 4, 2, and 1 consecutive pages respectively, and inserted into the 3rd, 2nd, 1st, and 0th min-heap trees respectively.

[0009] In summary, the problem with existing technologies is that existing persistent memory allocators incur significant performance overhead during wear leveling. Summary of the Invention

[0010] To address the aforementioned technical problems, this invention proposes a wear-aware space allocation method based on a persistent memory file system, comprising the following steps:

[0011] S1: Divide the PM space into blocks consisting of several consecutive physical pages. Based on the block size, group the blocks whose size is within the set range into groups. All blocks are divided into G groups and numbered from 0 to G-1.

[0012] S2: Organize all blocks in the same group into a singly linked list, and store the head nodes of the G singly linked lists as an array;

[0013] S3: Set a write counter for each page to record the page's write status, and store all write counters in an array in a contiguous space of PM;

[0014] S4: When an I / O request arrives, a multi-level allocation mechanism is used to directly allocate candidate blocks from the corresponding group to write to the I / O request, based on the size of the I / O request. At the same time, the write counter of the candidate block's page will be incremented by 1, and a wear-aware reclamation mechanism will be used to reclaim free blocks based on the page write status recorded by the write counter.

[0015] Preferably, blocks whose size is within a set range are grouped together, including:

[0016] For the i-th group, when i is less than G-1, the number of pages contained in each block of this group is in [2]. i ,2 i+1Within the range of [-1]; if i equals G-1, the blocks in this group contain at least 2 G-1 A series of consecutive pages.

[0017] Preferably, the singly linked list includes:

[0018] Within the non-head nodes of a singly linked list, the minimum wear level (min_write) and maximum wear level (max_write) of the page, the first page number (low_page_no) of the block, the number of pages (page_count), and the next pointer information are recorded. The head node of the singly linked list records four metadata information: the sum of the wear levels of all nodes in the singly linked list (sum_write), the number of nodes (node_count), a pointer to the first node of the list (head), and a pointer to the last node of the list (tail).

[0019] Preferably, a multi-level allocation mechanism is used to allocate candidate blocks, including:

[0020] When allocating a block containing N pages, an auxiliary array LA is constructed to quickly locate a linked list with a granularity of N or greater, and the first block in the linked list is selected as the candidate block for the allocation request.

[0021] If the first block in the linked list contains exactly N pages, remove it from the linked list and complete the allocation. If the first block contains more than N pages, split the block into two sub-blocks, each containing N pages for allocation. The remaining sub-blocks are then dynamically adjusted based on the average wear of the linked list, and after modifying the metadata, they are reinserted into the corresponding singly linked list. If the linked list has no allocatable nodes, the subsequent linked list is explored using a bitmap-based positioning method to find allocatable candidate blocks.

[0022] Furthermore, a method based on the average wear of the linked list to dynamically adjust the insertion point is used to re-insert the remaining sub-blocks back into the corresponding singly linked list after modifying the metadata information, including:

[0023] First, access LA[N] to locate the linked list to be inserted. Increment the total wear of the linked list by max_write and the number of nodes by 1, respectively. Calculate the average wear after the block is inserted into the linked list by sum_write / node_count. avg If the max_write of the block to be inserted is less than write avg If the condition is met, insert it at the head of the linked list; otherwise, insert it at the tail of the linked list.

[0024] Furthermore, the average wear rate (write) after the block is inserted into the linked list is calculated using sum_write / node_count. avg ,include:

[0025]

[0026] Where sum_write represents the sum of wear levels of all nodes in the singly linked list, max_write represents the maximum wear level of a page, and node_count represents the number of nodes in the singly linked list.

[0027] Furthermore, a bitmap-based location method is used to continue probing the successor list to find allocatable candidate blocks, including:

[0028] The availability of G linked lists is recorded in the bitmap. If the i-th linked list contains at least one block node, the i-th bit of the bitmap will be set to 1, otherwise it will be set to 0. The bitmap is recorded in a temporary variable k, and k is shifted right by LA[N]+1 bits. The first LA[N]+1 linked lists that do not meet the allocation conditions are skipped. The LA[N]+LA[k&(-k)]+1 linked list is found by the distance LA[k&(-k)] from the LA[N]+1 linked list to the nearest available linked list, and the first block of the linked list is selected for allocation.

[0029] Preferably, a wear-aware recycling mechanism is used to reclaim idle blocks, including:

[0030] Construct a recycling linked list to temporarily manage recently recycled blocks. The head node of the recycling linked list records four metadata information: the sum of wear of successor nodes (sum_write), the number of nodes (node_count), and pointers to the first / last node of the linked list (head / tail). Use a free block node locator to recycle free blocks into the constructed singly linked list.

[0031] Furthermore, free blocks are reclaimed into the constructed singly linked list via a free block node locator, including:

[0032] When reclaiming a new free block, first check if there is already an adjacent block in the reclamation list. Check if the two elements FBNL[low_page_no-1] and FBNL[low_page_no+page_count] are empty using the free block node locator. Set the page wear difference threshold Maxgap within the block to 5. Calculate the page wear difference max_write-min_write of the merging blocks by traversing the write counter records corresponding to the pages in the free block. If the wear difference max_write-min_write is less than the threshold Maxgap, merge the two blocks and complete the reclamation process. If the wear difference max_write-min_write is greater than or equal to the threshold Maxgap, dynamically adjust the insertion point based on the average wear of the linked list, inserting low-wear blocks at the front of the reclamation list and high-wear blocks at the back of the reclamation list.

[0033] The beneficial effects of this invention are as follows: First, this invention achieves low-overhead and high-precision wear equalization by dynamically adjusting the insertion point strategy based on the average wear of the linked list and the wear difference threshold method within the block node. Second, the free block node locator FBNL accelerates the merging process of the reclaimed blocks. Third, based on the multi-level linked list grouped by the allocation granularity range, it achieves O(1) complexity allocation while avoiding large blocks being split into small blocks, reducing external fragmentation, and improving the efficiency of inserting free and remaining blocks in the reclaimed linked list back into the allocator. Fourth, the method of finding allocable blocks based on the auxiliary array and the linked list availability bitmap avoids inefficient traversal operations. Finally, the bold idea that the max_write and min_write values ​​inside the remaining block node generated by allocation inherit from the max_write and min_write of the original free block node avoids the huge overhead of traversing free blocks to recalculate max_write and min_write, greatly improving system performance by sacrificing minor wear accuracy. Attached Figure Description

[0034] Figure 1 A schematic diagram of an existing wear-leveling-aware persistent memory file system allocator;

[0035] Figure 2 This is a schematic diagram of a wear-aware space allocation method based on a persistent memory file system according to the present invention.

[0036] Figure 3 This is a schematic diagram illustrating various scenarios of recycling blocks by changing the wear degree of the blocks according to the present invention;

[0037] Attached image description: Figure 1 (a) is a schematic diagram of the single-granularity distributor DWARM; Figure 1 (b) is a schematic diagram of the multi-granularity stack distributor WMAlloc; Figure 3 (a) is the unrecovered block B of the present invention. 10 The initial recycling chain represents the intended meaning; Figure 3 (b) is block B 10 Recycling block B with a wear level of 3 10 A schematic diagram; Figure 3 (c) is block B 10 Recycling block B with a wear level of 18 10 A schematic diagram; Figure 3 (d) is block B 10 Recycling block B with a wear level of 10 10 A schematic diagram; Figure 3 (e) is block B 10 Recycling block B with a wear level of 15 10 A schematic diagram; Figure 3 (f) is block B10 Recycle block B when wear degree is 10 and block B1 wear degree is 16. 10 A schematic diagram. Detailed Implementation

[0038] 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, and 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.

[0039] A wear-aware space allocation method based on a persistent memory file system, such as Figure 2 As shown, it includes the following steps:

[0040] S1: Divide the PM space into blocks consisting of several consecutive physical pages. Based on the block size, group the blocks whose size is within the set range into groups. All blocks are divided into G groups and numbered from 0 to G-1.

[0041] S2: Organize all blocks in the same group into a singly linked list, and store the head nodes of the G singly linked lists as an array;

[0042] S3: Set a write counter for each page to record the page's write status, and store all write counters in an array in a contiguous space of PM;

[0043] S4: When an I / O request arrives, a multi-level allocation mechanism is used to directly allocate candidate blocks from the corresponding group to write to the I / O request, based on the size of the I / O request. At the same time, the write counter of the candidate block's page will be incremented by 1, and a wear-aware reclamation mechanism will be used to reclaim free blocks based on the page write status recorded by the write counter.

[0044] Group blocks whose size is within a specified range into a group, including:

[0045] For the i-th group, when i is less than G-1, the number of pages contained in each block of this group is in [2]. i ,2 i+1 Within the range of [-1]; if i equals G-1, the blocks in this group contain at least 2 G-1 A series of consecutive pages.

[0046] The singly linked list includes:

[0047] Within the non-head nodes of a singly linked list, the minimum wear level (min_write) and maximum wear level (max_write) of the page, the first page number (low_page_no) of the block, the number of pages (page_count), and the next pointer information are recorded. The head node of the singly linked list records four metadata information: the sum of the wear levels of all nodes in the singly linked list (sum_write), the number of nodes (node_count), a pointer to the first node of the list (head), and a pointer to the last node of the list (tail).

[0048] Saving the head nodes of G singly linked lists as an array can help with fast location; for example, if we need to allocate from the 3rd linked list, we only need multi_list[3], instead of traversing from the beginning.

[0049] A write counter is used to record the number of times a page is written, with the aim of achieving wear leveling. When allocating, knowing the number of times a page is written, we can prioritize allocating pages with fewer writes. For multi-level allocation mechanisms, the method of dynamically adjusting the insertion point based on the average wear of the linked list can ensure that blocks with less wear are stored at the beginning of the linked list, thus allowing them to be allocated first.

[0050] A multi-level allocation mechanism is used to allocate candidate blocks, including:

[0051] When allocating a block containing N pages, it is necessary to quickly locate a linked list with a granularity of exactly N, i.e., exactly satisfying 2N. i To find the i-th linked list with a granularity of N or greater, an auxiliary array LA is constructed to quickly locate a linked list with a granularity of exactly N. For an allocator containing G singly linked lists, LA contains 2 G-1 +1 integer elements, and the value of LA[j] is set to i if and only if j∈[2 i ,2 i+1 -1]; Specifically, the value of LA[0] is set to -1, indicating that allocating less than 1 page is illegal, LA[2] G-1 Setting the value of +1] to G-1 means that MLAM allocation exceeds 2 G-1 When accessing a page, the system will locate the last linked list and select the first block in the linked list as the candidate block for the allocation request.

[0052] If the first block in the linked list contains exactly N pages, it is removed from the linked list and the allocation is completed. If the first block contains more than N pages, the block is split into two sub-blocks, each containing N pages for allocation. The remaining sub-blocks are dynamically adjusted based on the average wear of the linked list, and after the metadata information is modified, they are reinserted into the singly linked list corresponding to their size. When updating the max_write and min_write of the remaining sub-blocks, to avoid the overhead of traversing the write counters of the remaining sub-block pages, the remaining sub-blocks inherit the max_write and min_write of the original block.

[0053] Multilevel linked lists are grouped by block size, and the i-th linked list manages blocks whose size is in the range [2]. i ,2 i+1 The remaining blocks are within the range of [-1], so they also need to be inserted back into the corresponding singly linked list according to their size; for example, if the size of the remaining block is 12, it is within the range of [2]. 3 ,2 4 The remaining block is inserted back into the linked list numbered 3 within the range of -1].

[0054] When the block size represented by the first node in the LA[N]th linked list is less than N, continuing to explore the successor node of the linked list and traversing the successor linked list to find an allocatable block will incur certain performance overhead. To solve this problem, a bitmap-based positioning method is used to prevent inefficient traversal operations: if the linked list has no allocatable node, the successor linked list is explored using a bitmap-based positioning method to find an allocatable candidate block.

[0055] A method based on the average wear of the linked list to dynamically adjust the insertion point is used to re-insert the remaining sub-blocks back into the corresponding singly linked list after modifying their metadata information, including:

[0056] First, access LA[N] to locate the linked list to be inserted. Increment the total wear of the linked list by max_write and the number of nodes by 1, respectively. Calculate the average wear after the block is inserted into the linked list by sum_write / node_count. avg If the max_write of the block to be inserted is less than write avg If it is true, insert it at the head of the linked list; otherwise, insert it at the tail of the linked list.

[0057] The average wear level after inserting a block into the linked list is calculated using sum_write / node_count. avg ,include:

[0058]

[0059] Where sum_write represents the sum of wear levels of all nodes in the singly linked list, max_write represents the maximum wear level of a page, and node_count represents the number of nodes in the singly linked list.

[0060] The subsequent linked list is further explored using a bitmap-based location method to find allocatable candidate blocks, including:

[0061] The availability of G linked lists is recorded in the bitmap. If the i-th linked list contains at least one block node, the i-th bit of the bitmap will be set to 1, otherwise it will be set to 0. The bitmap is recorded in a temporary variable k, and k is shifted right by LA[N]+1 bits, skipping the first LA[N]+1 linked lists that do not meet the allocation conditions. Since k&(-k) represents the value corresponding to the rightmost bit of k being 1, LA[k&(-k)] is used to represent the distance from the LA[N]+1 linked list to the nearest available linked list. The LA[N]+LA[k&(-k)]+1 linked list is found by the distance LA[k&(-k)] from the LA[N]+1 linked list to the nearest available linked list, and the first block of the linked list is selected for allocation. Therefore, the complexity of finding a block that meets the allocation conditions using the LA array and the bitmap positioning method is O(1).

[0062] A wear-aware recycling mechanism is used to reclaim idle blocks, including:

[0063] Construct a recycling linked list to temporarily manage recently recycled blocks. The head node of the recycling linked list records four metadata information: the sum of wear of successor nodes (sum_write), the number of nodes (node_count), and pointers to the first / last node of the linked list (head / tail). Use a free block node locator to recycle free blocks into the constructed singly linked list.

[0064] However, since recycling the linked list requires merging adjacent blocks, searching for adjacent blocks by traversing them can lead to a severe performance degradation. Therefore, the Free Block Node Locator (FBNL) is proposed to reduce the overhead of merging adjacent blocks.

[0065] FBNL is an array of pointers, with the same number of elements as the number of PM pages. Each element occupies 8 bytes and is used to record the address of the corresponding node in the recycling list. Specifically, the FBNL elements corresponding to the first and last pages of the free block nodes in the recycling list are used to record the address of the corresponding node in the recycling list; other elements are set to NULL. For example, ... Figure 3 As shown in (a), the free reclamation block B0 contains four consecutive pages numbered from 2 to 5. Only the 2nd and 5th elements of FBNL store pointers to B0, while the 3rd and 4th elements will remain NULL.

[0066] The free blocks are reclaimed into the constructed singly linked list using the free block node locator, including:

[0067] When reclaiming a new free block, first check if there is already an adjacent block in the reclamation list. Check if the two elements FBNL[low_page_no-1] and FBNL[low_page_no+page_count] are empty using the free block node locator. Set the page wear difference threshold Maxgap within the block to 5. Calculate the page wear difference max_write-min_write of the merging blocks by traversing the write counter records corresponding to the pages in the free block. If the wear difference max_write-min_write is less than the threshold Maxgap, merge the two blocks and complete the reclamation process. If the wear difference max_write-min_write is greater than or equal to the threshold Maxgap, dynamically adjust the insertion point based on the average wear of the linked list, inserting low-wear blocks at the front of the reclamation list and high-wear blocks at the back of the reclamation list.

[0068] The page wear difference threshold Maxgap within a block is an integer. When Maxgap is set to a large value, more large free blocks can be generated during merging, but the page wear difference within the large free blocks will be large. When Maxgap is set to a small value, wear leveling can be achieved within the free blocks, but the number of large free blocks available to the system will be reduced.

[0069] like Figure 3 As shown in (a), the recycling list contains 10 blocks numbered from B0 to B9, with a total wear level of 150. Furthermore, Maxgap is set to 5, and the released blocks (by B0) 10 (This indicates that it only contains page 6.) In this example, we will change block B. 10 The wear level is used to demonstrate the recycling of B. 10 Various situations.

[0070] The first case, such as Figure 3 As shown in (b), release block B 10 The write counter is 3 (i.e., both max_write and min_write are 3). First, in the head node of the reclaimed list, sum_write and node_count are incremented by 3 and 1 respectively. The average wear of the list is calculated to be 153 / 11, resulting in 13 (considering only the integer part). Then, B is calculated. 10 The wear difference between B0 and B0, i.e., the max_write and min_write of the merged block are 9 and 3 respectively, and the wear difference max_write - min_write is greater than the set threshold Maxgap. Therefore, the merge operation is abandoned. Similarly, B 10B1 and B2 cannot be merged. Therefore, due to B... 10 The maximum wear of 3 is less than the average wear of 13 for all blocks in the recycling list, so the released block will be inserted at the head of the recycling list.

[0071] In the second scenario, let's assume block B is released. 10 The write counter is 18. For example... Figure 3 As shown in (c), in the analysis of B0, B1 and B 10 After assessing the wear differences between them, it was found that release block B... 10 It still cannot be merged with B0 and B1. Furthermore, block B... 10 The maximum wear of 18 is greater than the average wear of 15 in the recycling chain. Therefore, block B is released. 10 It is inserted at the end of the recycling list.

[0072] In the third scenario, let's assume block B is released. 10 The write counter is 10. First check B0, B1, and B... 10 The wear difference between them. In the three adjacent blocks, after merging, max_write is 12 (inherited from B1), min_write is 8 (inherited from B0), and the wear difference is 4, which is less than the set threshold Maxgap. Therefore, as Figure 3 As shown in (d), the three blocks are merged into one large block by pointing the next pointer of block B0 to B2 and deleting the B1 node. The data of node B0, low_page_no, page_count, max_write and min_write, are modified to 2, 6, 12 and 8 respectively.

[0073] The fourth scenario assumes that block B is released. 10 The write counter is 15. First, verify B0, B1, and B... 10 The wear difference between them. However, the merged max_write and min_write are 15 and 8 respectively, resulting in a wear difference of 7, which is greater than the set threshold Maxgap. Furthermore, as... Figure 3 As shown in (e), it can be observed that min_write is in block B0; therefore, B0 and B are discarded. 10 The merge operation. Next, check B1 and B... 10 The wear difference between the merged blocks was found to be less than the set threshold Maxgap. Therefore, B was... 10 Merge into block B1.

[0074] The fifth scenario assumes that block B is released. 10 The write counters for B0 and B1 are 10 and 16 respectively. First, check B0, B1, and B... 10The wear difference between them. If three adjacent blocks are merged, then max_write and min_write are 16 and 8 respectively, and the wear difference between the merged blocks is 8, which is greater than the set threshold Maxgap. Figure 3 As shown in (f), abandon B. 10 Merge operations between B0 and B1, then check B0 and B1. 10 The wear difference between the blocks. Fortunately, the wear difference between the merged blocks meets the merging requirements, therefore, block B will be released. 10 Merge into B0 and modify the corresponding data.

[0075] When the number of free pages in the multi-level linked list is less than the total number of free pages in PM multiplied by the factor α, free blocks in the reclamation list will be migrated to the multi-level linked list. First, calculate the average wear of all blocks in the reclamation list. avg (i.e., sum_write / node_count). Secondly, since the reclamation process requires low-wear blocks to be placed at the front of the reclamation list and high-wear blocks at the rear, the reclamation list is traversed from the beginning to obtain sub-lists with wear less than the average wear. Finally, these blocks are inserted into the corresponding multi-level singly linked lists according to their size; no splitting is required during the migration process. Note that the insertion of remaining blocks and the migration of reclamation blocks do not require further merging, as all mergeable blocks have already been merged during the reclamation process.

[0076] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A wear-aware space allocation method based on a persistent memory file system, characterized in that, include: S1: Divide the PM space into blocks consisting of several consecutive physical pages. Based on the block size, group the blocks whose size is within the set range into groups. All blocks are divided into G groups and numbered from 0 to G-1. Group blocks whose size is within a specified range into a group, including: For the i-th group, when i is less than G-1, each block of the group contains a number of pages in the range [2 i , 2 i+1 -1]; if i is equal to G-1, the block of the group contains at least 2 G-1 consecutive pages. S2: Organize all blocks in the same group into a singly linked list, and store the head nodes of the G singly linked lists as an array; S3: Set a write counter for each page to record the page's write status, and store all write counters in an array in a contiguous space of PM; S4: When an I / O request arrives, a multi-level allocation mechanism is used to directly allocate candidate blocks from the corresponding group to write to the I / O request based on the size of the I / O request. At the same time, the write counter of the page to be written to the candidate block will be incremented by 1, and a wear-aware reclamation mechanism will be used to reclaim free blocks based on the page write status recorded by the write counter. A wear-aware recycling mechanism is used to reclaim idle blocks, including: Construct a recycling linked list to temporarily manage recently recycled blocks. The head node of the recycling linked list records four metadata information: the sum of wear of the successor nodes (sum_write), the number of nodes (node_count), and pointers to the first / last node of the linked list (head / tail). Use the free block node locator to recycle free blocks into the constructed singly linked list. The free blocks are reclaimed into the constructed singly linked list using the free block node locator, including: When reclaiming a new free block, first check if there is already an adjacent block in the reclamation list. Check if the two elements FBNL[low_page_no - 1] and FBNL[low_page_no + page_count] are empty using the free block node locator. Set the page wear difference threshold Maxgap within the block to 5. Calculate the page wear difference max_write - min_write of the merging blocks by traversing the write counter records of the pages in the free block. If the wear difference max_write - min_write is less than the threshold Maxgap, then merge the two blocks and complete the reclamation process. If the wear difference max_write - min_write is greater than or equal to the threshold Maxgap, then use a dynamic adjustment of the insertion point based on the average wear of the linked list to insert low-wear blocks at the front of the reclamation list and high-wear blocks at the back of the reclamation list.

2. The wear-aware space allocation method based on a persistent memory file system according to claim 1, characterized in that, The singly linked list includes: Within the non-head nodes of a singly linked list, the minimum wear level (min_write) and maximum wear level (max_write) of the page, the first page number (low_page_no) of the block, the number of pages (page_count), and the next pointer information are recorded. The head node of the singly linked list records four metadata information: the sum of the wear levels of all nodes in the singly linked list (sum_write), the number of nodes (node_count), a pointer to the first node of the list (head), and a pointer to the last node of the list (tail).

3. The wear-aware space allocation method based on a persistent memory file system according to claim 1, characterized in that, A multi-level allocation mechanism is used to allocate candidate blocks, including: When allocating a block containing N pages, an auxiliary array LA is constructed to quickly locate a linked list with a granularity of N or greater, and the first block in the linked list is selected as a candidate block. If the first block in the linked list contains exactly N pages, remove it from the linked list and complete the allocation. If the first block contains more than N pages, split the block into two sub-blocks, each containing N pages for allocation. The remaining sub-blocks are then dynamically adjusted based on the average wear of the linked list, and after modifying the metadata, they are reinserted into the corresponding singly linked list. If the linked list has no allocatable nodes, the subsequent linked list is explored using a bitmap-based positioning method to find allocatable candidate blocks.

4. The wear-aware space allocation method based on a persistent memory file system according to claim 3, characterized in that, A method based on the average wear of linked lists to dynamically adjust the insertion point is used to re-insert the remaining sub-blocks back into the corresponding singly linked list after modifying their metadata information, including: First, access LA[N] to locate the linked list to be inserted. Increment the total wear of the linked list by max_write and the number of nodes by 1, respectively. Calculate the average wear after the block is inserted into the linked list by sum_write / node_count. avg If the max_write of the block to be inserted is less than write avg If the condition is met, insert it at the head of the linked list; otherwise, insert it at the tail of the linked list.

5. The wear-aware space allocation method based on a persistent memory file system according to claim 3, characterized in that, The average wear level after inserting a block into the linked list is calculated using sum_write / node_count. avg ,include: in, This represents the sum of the wear levels of all nodes in a singly linked list. Indicates the highest wear level of the page. This indicates the number of nodes in a singly linked list.

6. The wear-aware space allocation method based on a persistent memory file system according to claim 3, characterized in that, The successor list is further explored using a bitmap-based location method to find allocatable candidate blocks, including: The availability of G linked lists is recorded in the bitmap. If the i-th linked list contains at least one block node, the i-th bit of the bitmap will be set to 1, otherwise it will be set to 0. The bitmap is recorded in a temporary variable k, and k is shifted right by LA[N]+1 bits. The first LA[N]+1 linked lists that do not meet the allocation conditions are skipped. The LA[N]+LA[k&(−k)]+1 linked list is found by the distance LA[k&(−k)] from the LA[N]+1 linked list to the nearest available linked list, and the first block of the linked list is selected for allocation.