# US 2021/0011652 A1 · Data storage access method, device and apparatus for persistent memory

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0011652 A1
- Document ID: US20210011652A1
- Status: Published application
- Kind: A1
- Application number: 16/553,276
- Filed: 2019-08-28
- Published: 2021-01-14
- Earliest claimed: 2019-07-12
- Assignees: Tsinghua University
- Applicants: Tsinghua University
- Inventors: Jiwu SHU; Youmin CHEN; Bohong ZHU; Youyou LU
- Web page: https://patentgrep.com/patent/US20210011652A1

## CPC

- G06F 3/0605: {by facilitating the interaction with a user or administrator}
- G06F 3/0655: {Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices}
- G06F 3/0604: {Improving or facilitating administration, e.g. storage management}
- G06F 3/0622: {in relation to access}
- G06F 3/0643: {Management of files}
- G06F 3/0661: {Format or protocol conversion arrangements}
- G06F 3/0673: {Single storage device}
- G06F 3/0679: {Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

The invention discloses a data storage access method, device and apparatus for persistent memory. The method includes: enabling a file system in device to receive, in a kernel space, an access request of a user library, where the user library operates in user mode, and the access request is initiated by third-party application through user library and carries operation type; if the operation type is read operation, enabling the file system to allow third-party application to directly access persistent memory space of device through user library; and if the operation type is not read operation, enabling the file system to allow third-party application to access persistent memory space of device through user library and kernel thread, where kernel thread operates in kernel mode. In this way, the present invention can achieve both high performance and data security of persistent memory, and provide technical support for scalability in multi-core scenario.

## Claims

### Claim 1

A data storage access method for persistent memory, comprising:
enabling a file system in a device to receive, in a kernel space, an access request of a user library, wherein the user library operates in a user mode, and the access request is initiated by a third-party application through the user library and carries an operation type;
if the operation type is read operation, enabling the file system to allow the third-party application to directly access a persistent memory space of the device through the user library; and
if the operation type is not read operation, enabling the file system to allow the third-party application to access the persistent memory space of the device through the user library and a kernel thread, wherein the kernel thread operates in a kernel mode.

### Claim 2 (depends on 1)

The method according to claim 1, wherein prior to enabling the file system in the device to receive, in the kernel space, the access request of the user library, the method comprises:
mapping the persistent memory space of the device to a user space in a read-only mode.

### Claim 3 (depends on 2)

The method according to claim 2, wherein if the operation type is read operation, the enabling the file system to allow the third-party application to directly access persistent memory space of the device through the user library comprises:
for the read operation, enabling the file system to allow the third-party application to directly index a file system image in the user space through the user library.

### Claim 4 (depends on 1)

The method according to claim 1, wherein the user library communicates with the kernel thread through a shared message pool; the shared message pool is a shared memory area for messages which is used by the user library and the kernel thread in common.

### Claim 5 (depends on 4)

The method according to claim 4, wherein the method further comprises:
enabling a plurality of the user libraries to send a plurality of different access requests to the kernel thread through the shared message pool;
enabling the kernel thread to process the plurality of different access requests in a batch, and adding a log-structured metadata modification history in a batch, wherein the log-structured metadata modification history is adapted to record information related to modified metadata and is stored in the persistent memory space; and
after processing the plurality of different access requests, enabling the kernel thread to return processing results to the user libraries through the shared message pool in a batch.

### Claim 6 (depends on 4)

The method according to claim 4, wherein the method further comprises:
enabling the user libraries to apply message areas for their processes in the shared message pool during initialization, wherein message areas for different processes are isolated from each other, and each process is only allowed to access the message area of its own;
enabling the user libraries to copy new messages to the message areas and set request status fields to validate the new messages;
enabling the kernel thread to identify the validated new messages in a polling manner;
enabling the kernel thread to copy corresponding return information to the message areas and set message return values after finishing processing of the validated new messages; and
enabling the user libraries to query the message return values in a polling manner to obtain the return information.

### Claim 7 (depends on 1)

The method according to claim 1, wherein the operation type that is not read operation is at least one of write operation and modification operation.

### Claim 8 (depends on 7)

The method according to claim 7, wherein if the operation type is not read operation, the enabling the file system to allow the third party application to access the persistent memory space of the device through the user library and the kernel thread comprises:
for the write operation, enabling the kernel thread to set a first page entry of a page table in the kernel space to make a corresponding first data page writable, wherein the first data page is a memory area of fixed size in the persistent memory space;
enabling the user library to complete the write operation on the first data page; and
enabling the kernel thread to reset the first page entry to make the first data page read-only.

### Claim 9 (depends on 7)

The method according to claim 7, wherein the method further comprises:
enabling the kernel thread to reserve a second data page for the user library in a batch and set an associated second page entry to make the second data page writable, wherein the second data page is a memory area of fixed size in the persistent memory space;
wherein, if the operation type is not read operation, the enabling the file system to allow the third party application to access the persistent memory space of the device through the user library and the kernel thread comprises:
for the write operation, enabling the user library to directly perform allocation in the reserved second data page and obtain a corresponding range lock directly in the user space;
enabling the user library to complete the write operation on the allocated second data page; and
enabling the kernel thread to reset the second page entry of the newly written second data page as read-only and release the range lock.

### Claim 10 (depends on 9)

The method according to claim 9, wherein the range lock is capable of supporting concurrent write operations in a same file;
the enabling the user library to complete the write operation on the allocated second data page comprises:
enabling the file system to allocate a lock queue to each opened file;
enabling the user library that initiates requests for writing to a same file to traverse all write operation fields in the lock queue before the write operations;
if it is determined that all the write operation fields added before are different from the write operation field of its own, adding the write operation field of its own to the lock queue, and enabling the user library to complete the write operation on the allocated second data page, wherein the write operation field is adapted to record a range of file offsets involved in the write operation; and
if it is determined that one of the write operation fields added before overlaps with the write operation field of its own, enabling the user library to complete the write operation on the allocated second data page after a previous write operation is completed.

### Claim 11 (depends on 5)

The method according to claim 5, wherein if the operation type is not read operation, the enabling the file system to allow the third party application to access the persistent memory space of the device through the user library and the kernel thread comprises:
for a modification operation, enabling the user library to send a modification request to the kernel thread, and enabling the kernel thread to perform corresponding modification according to the modification request.

### Claim 12 (depends on 11)

The method according to claim 11, wherein:
data of the file system comprises indexable structured metadata being stored in a dynamic random access memory DRAM; data of the file system further comprises a log-structured metadata modification history, wherein the log-structured metadata modification history is used to record related information of modified metadata and is stored in the persistent memory space;
the modification operation is to modify the indexable structured metadata, and the method further comprises:
enabling the kernel thread to firstly add information about modifying of the indexable structured metadata to the log-structured metadata modification history when modifying the indexable structured metadata; and
after the information about modifying of the indexable structured metadata reaches the persistent memory space, enabling the kernel thread to modify the indexable structured metadata in the DRAM.

### Claim 13 (depends on 12)

The method according to claim 12, wherein the indexable structured metadata comprises namespace metadata and data block index metadata, the namespace metadata is used to manage a namespace of the file system and forms a directory of the file system;
the method further comprises:
enabling the kernel thread to maintain entries of the directory by using a skip list; and
enabling the kernel thread to atomically modify node pointers of respective layers of the skip list by using atomic operation.

### Claim 14 (depends on 13)

The method according to claim 13, wherein the method further comprises:
mapping an area of the DRAM that stores the indexable structured metadata to the user space in a read-only mode;
before sending a modification request, enabling the user library to query, in the user mode, the nodes of respective skip lists corresponding to the entries to be updated in the namespace metadata, and carry address information of the nodes of the respective skip lists in the modification request; and
enabling the kernel thread to quickly look for nodes of the skip lists to be modified by using the address information carried in the modification request and complete the modification operation on the metadata.

### Claim 15 (depends on 1)

The method according to claim 1, wherein metadata of the file system comprises indexable structured metadata, and the indexable structured metadata is stored in a dynamic random access memory DRAM;
the method further comprises:
mapping an area of the DRAM that stores the indexable structured metadata to the user space in a read-only mode;
for the read operation, enabling the user library to look up through the indexable structured metadata in a read-only mode, and copy data read from corresponding data page to a data buffer of the third party application through a lock-free mechanism.

### Claim 16 (depends on 1)

A data storage access device for persistent memory, comprising:
a processor,
a storage, and
a communication circuit, wherein:
the processor is coupled to the storage and the communication circuit, the storage comprises a persistent memory and a dynamic random access memory, and
the processor, the memory and the communication circuit are capable of implementing steps of the method according to claim 1 while in operation.

### Claim 17 (depends on 1)

An apparatus with storage function on which program data is stored, wherein the program data, when being executed by a processor, implements steps of the method according to claim 1.
