A request processing method, device, equipment, system, medium and product
By converting IO requests into NVMe commands at the virtual file system layer and writing them directly into the NVMe device queue, bypassing the block layer operations, the performance bottleneck of the traditional Linux IO stack on NVMe devices is solved, and IO performance is improved.
Patent Information
- Application Number
- CN202510713887.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2045-05-30
AI Technical Summary
The traditional Linux IO stack increases the data transmission path and time when processing NVMe devices, which cannot fully utilize its high-performance advantages and leads to increased performance overhead.
At the virtual file system layer, data input and output requests are converted into non-volatile memory host controller interface specification commands and written directly to the submission queue of the NVMe device, bypassing the block layer. The execution results are obtained through the input and output ring queue mechanism, reducing memory copy operations.
It achieves IO performance acceleration in NVMe device scenarios, reduces unnecessary overhead, and improves data input and output performance.
Smart Images

Figure CN120256405B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer file system IO, and in particular to a request processing method, apparatus, device, system, medium and product. Background Art
[0002] In computer systems, file system I / O (input / output) performance is a key factor affecting overall system performance. The traditional Linux I / O stack uses a layered architecture. During I / O operations, data must pass through the VFS (Virtual File System) layer, the FS layer, the block layer, and finally the device driver layer.
[0003] NVMe (Non-Volatile Memory Express) is a high-performance interface protocol designed specifically for non-volatile storage devices, with the characteristics of low latency and high concurrency.
[0004] However, although the above architecture of the Linux IO stack has good versatility and scalability, when processing high-performance NVMe devices, it will increase the data transmission path and time, introduce unnecessary overhead, and fail to fully utilize the performance advantages of NVMe devices.
[0005] It can be seen that how to reduce the overhead of NVMe devices when processing IO requests is a problem that needs to be solved by those skilled in the art. Summary of the Invention
[0006] The present invention aims to provide a request processing method, apparatus, device, system, medium and product that can reduce the overhead of NVMe devices when processing IO requests.
[0007] In a first aspect, a request processing method is provided, comprising: when an application sends a data input / output request, transmitting the data input / output request to a virtual file system layer; in the virtual file system layer, converting the data input / output request into a non-volatile memory host controller interface specification command, and writing the non-volatile memory host controller interface specification command into a submission queue of a target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command, so that the target non-volatile memory host controller interface specification device executes the non-volatile memory host controller interface specification command and writes the execution result into a completion queue of the target non-volatile memory host controller interface specification device; obtaining the execution result in the completion queue of the target non-volatile memory host controller interface specification device, and sending the execution result to the application.
[0008] In a preferred example, the present invention can be further configured as follows: at the virtual file system layer, the data input and output request is converted into a non-volatile memory host controller interface specification command, including: at the virtual file system layer, determining the request type of the data input and output request; if the request type is a regular request, then at the virtual file system layer, according to a first predefined mapping table, converting the data input and output request into a non-volatile memory host controller interface specification command; if the request type is a complex request, then at the virtual file system layer, according to a second predefined mapping table, converting the data input and output request into a non-volatile memory host controller interface specification command.
[0009] In a preferred example, the present invention can be further configured as follows: at the virtual file system layer, according to the second predefined mapping table, the data input and output request is converted into a non-volatile memory host controller interface specification command, including: at the virtual file system layer, semantically parsing the data input and output request to obtain a special operation identifier and key parameters; constructing a non-volatile memory host controller interface specification command based on the special operation identifier, key parameters and the second predefined mapping table; mapping the file system logical address to the physical address of the target non-volatile memory host controller interface specification device according to the file offset in the key parameters, and performing data block alignment.
[0010] In a preferred example, the present invention can be further configured as follows: in the virtual file system layer, after converting the data input and output request into a non-volatile memory host controller interface specification command, it also includes at least one of the following: performing a validity check on the non-volatile memory host controller interface specification command; determining whether the submission of the non-volatile memory host controller interface specification command has timed out, and if so, resubmitting the non-volatile memory host controller interface specification command.
[0011] In a preferred example, the present invention can be further configured as follows: at the virtual file system layer, the data input and output request is converted into a non-volatile memory host controller interface specification command, including: at the virtual file system layer, determining whether the device corresponding to the request location of the data input and output request is a non-volatile memory host controller interface specification device; if it is a non-volatile memory host controller interface specification device, converting the data input and output request into a non-volatile memory host controller interface specification command.
[0012] In a preferred example, the present invention can be further configured as follows: further comprising: if it is not a non-volatile memory host controller interface specification device, processing the request in sequence through the virtual file system layer, the block layer, and the device driver layer.
[0013] In a preferred example, the present invention can be further configured as follows: before writing the non-volatile memory host controller interface specification command into the submission queue of the target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command, it also includes: obtaining the physical memory address of the target non-volatile memory host controller interface specification device; using the memory mapping function provided by the operating system to map the physical memory address to the virtual address of the user space, so as to directly access the submission queue of the target non-volatile memory host controller interface specification device, thereby facilitating writing the non-volatile memory host controller interface specification command into the submission queue of the target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command.
[0014] In a preferred example, the present invention can be further configured to: obtain the execution result in the completion queue of the target non-volatile memory host controller interface specification device, including: obtaining the execution result in the completion queue of the target non-volatile memory host controller interface specification device through the input and output ring queue mechanism in the virtual file system layer; and / or obtaining the execution result in the completion queue of the target non-volatile memory host controller interface specification device through event polling notification.
[0015] In a preferred example, the present invention can be further configured as follows: at the virtual file system layer, the execution result in the completion queue of the target non-volatile memory host controller interface specification device is obtained through the input and output ring queue mechanism, including: polling the completion queue of the target non-volatile memory host controller interface specification device through the input and output ring queue mechanism, obtaining the execution result of the target non-volatile memory host controller interface specification device, and transmitting it to the virtual file system layer.
[0016] In a preferred example, the present invention can be further configured as follows: at the virtual file system layer, before polling the completion queue of the target non-volatile memory host controller interface specification device through the input / output ring queue mechanism to obtain the execution result of the target non-volatile memory host controller interface specification device, it also includes: initializing an input / output ring queue instance to create a submission queue and a completion queue of the input / output ring queue; associating the input / output ring queue instance with the respective completion queues of multiple associated non-volatile memory host controller interface specification devices, so as to monitor the execution results of multiple associated non-volatile memory host controller interface specification devices through the input / output ring queue mechanism; the multiple associated non-volatile memory host controller interface specification devices at least include the target non-volatile memory host controller interface specification device.
[0017] In a preferred example, the present invention can be further configured as follows: polling the completion queue of the target non-volatile memory host controller interface specification device through an input / output ring queue mechanism to obtain the execution result of the target non-volatile memory host controller interface specification device, including: determining whether there is a new execution result entry in the completion queue of the target non-volatile memory host controller interface specification device through the input / output ring queue mechanism; if so, parsing the new execution result entry to obtain the current execution result, and determining whether the current execution result is the execution result corresponding to the data input / output request; if so, determining to obtain the execution result of the target non-volatile memory host controller interface specification device.
[0018] In a preferred example, the present invention can be further configured as follows: if it exists, parsing the new execution result entry to obtain the current execution result, including: if it exists, when the number of existing new execution result entries reaches a preset number, parsing each of the new execution result entries to obtain each current execution result; accordingly, determining whether the current execution result is the execution result corresponding to the data input and output request, including: determining whether each of the current execution results has an execution result corresponding to the data input and output request.
[0019] In a preferred example, the present invention can be further configured as follows: before transmitting the data input and output request to the virtual file system layer, it also includes: obtaining multiple test cases; testing the request handler according to each test case to obtain a test result; the request handler is a pre-set program that can implement the request processing method; if the test result does not meet the expected test result, optimizing the parameters of the request handler according to the test result, the parameters including: the queue depth of the completion queue and the submission queue of the target non-volatile memory host controller interface specification device, and the queue size of the submission queue and the completion queue of the input and output ring queue.
[0020] In a preferred example, the present invention can be further configured as follows: testing the request handler according to each test case to obtain test results, including at least one of the following: performing functional testing on the request handler according to the test case of functional testing to obtain functional test results; performing performance testing on the request handler according to the test case of performance benchmark testing to obtain performance test results; performing fault tolerance testing on the request handler according to the test case of fault tolerance testing to obtain fault tolerance test results.
[0021] In a preferred example, the present invention can be further configured as follows: writing the non-volatile memory host controller interface specification command into the submission queue of the target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command, including: determining whether the actual queue depth of the submission queue of the target non-volatile memory host controller interface specification device is less than a preset queue depth; if so, writing the non-volatile memory host controller interface specification command into the submission queue of the target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command; if not, continuously monitoring the actual queue depth of the submission queue of the target non-volatile memory host controller interface specification device until the actual queue depth of the submission queue of the target non-volatile memory host controller interface specification device is less than the preset queue depth, and writing the non-volatile memory host controller interface specification command into the submission queue of the target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command.
[0022] In a second aspect, a request processing device is provided, comprising: a request transmission module, for transmitting a data input / output request to a virtual file system layer when an application sends a data input / output request; a command conversion module, for converting the data input / output request into a non-volatile memory host controller interface specification command at the virtual file system layer, and writing the non-volatile memory host controller interface specification command into a submission queue of a target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command, so that the target non-volatile memory host controller interface specification device executes the non-volatile memory host controller interface specification command and writes the execution result into a completion queue of the target non-volatile memory host controller interface specification device; a result return module, for obtaining the execution result in the completion queue of the target non-volatile memory host controller interface specification device and sending the execution result to the application.
[0023] According to a third aspect, an electronic device is provided, comprising a memory and a processor, wherein a computer program is stored in the memory, and the processor executes the request processing method according to any one of the first aspects when running the computer program.
[0024] In a fourth aspect, a request processing system is provided, comprising: the electronic device as described in the third aspect, and a target non-volatile memory host controller interface specification device.
[0025] In a fifth aspect, a computer-readable storage medium is provided, wherein at least one program code is stored in the computer-readable storage medium, and the program code is loaded and executed by a processor to implement the request processing method as described in any one of the first aspects.
[0026] In a sixth aspect, a computer program product is provided, comprising a computer program or instructions, which, when executed by a processor, implements the request processing method as described in any one of the first aspects.
[0027] In summary, the request processing method provided by the present invention includes the following beneficial technical effects: when an application sends a data input / output request, the data input / output request is transmitted to the virtual file system layer; in the virtual file system layer, the data input / output request is converted into a non-volatile memory host controller interface specification command, and the non-volatile memory host controller interface specification command is written into the submission queue of the target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command, so that the target non-volatile memory host controller interface specification device executes the non-volatile memory host controller interface specification command and writes the execution result into the completion queue of the target non-volatile memory host controller interface specification device; the execution result in the completion queue of the target non-volatile memory host controller interface specification device is obtained, and the execution result is sent to the application.
[0028] The present invention introduces special processing logic for non-volatile memory host controller interface specification devices in the virtual file system layer, converts IO requests into non-volatile memory host controller interface specification commands, and transmits them to the submission queue of the target non-volatile memory host controller interface specification device. After the non-volatile memory host controller interface specification device executes the command, it puts the result into the completion queue and feeds it back to the host. This bypasses the block layer and avoids the overhead caused by multiple memory copies in the traditional process, thereby accelerating file system data input and output requests and improving data input and output performance in the non-volatile memory host controller interface specification device scenario.
[0029] In addition, the present invention also provides a request processing device, equipment and medium, all of which have the above-mentioned beneficial technical effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0031] Figure 1 A schematic diagram of a request processing flow provided by an embodiment of the present invention.
[0032] Figure 2 A flowchart of another request processing method provided by an embodiment of the present invention.
[0033] Figure 3 A flowchart of another request processing method provided by an embodiment of the present invention.
[0034] Figure 4 An embodiment of the present invention provides a method for demonstrating the traditional IO process and the improved process of the present invention.
[0035] Figure 5 A schematic diagram illustrating the processing after an application initiates a request is provided in an embodiment of the present invention.
[0036] Figure 6 A schematic diagram of the structure of a request processing device provided by an embodiment of the present invention.
[0037] Figure 7 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0038] 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 them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.
[0039] The terms "including" and "having," as used in the present description and accompanying drawings, and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or elements is not limited to the listed steps or elements and may include steps or elements that are not listed.
[0040] In order to better understand and illustrate the solutions of the embodiments of the present invention, some technical terms involved in the embodiments of the present invention are briefly explained below.
[0041] IO: Data input / output (IO) of a computer system; VFS: Virtual File System (VFS in this invention already includes FS); NVMe: Non-Volatile Memory Express (NVMe) host controller interface specification; RQ: Submission Queue (RQ) is the channel through which the host sends commands to the NVMe device; CQ: Completion Queue (CQ) is the channel through which the NVMe device returns command execution results to the host. Physical Address: The physical memory or register address exposed by a hardware device (such as an NVMe controller or graphics card) via a bus (such as PCIe or DMA). Virtual Address: The virtual memory address assigned to a process by the host operating system, mapped to a physical address through a page table. The essence of memory mapping is to establish a mapping relationship between virtual addresses and device physical addresses, allowing host programs to access device resources as if they were ordinary memory.
[0042] Currently, the traditional Linux I / O stack architecture uses a unified process for handling various storage devices, lacking optimizations for the specific characteristics of NVMe devices. Specifically, the VFS layer unifies I / O read and write formats across various instantiated I / O formats, such as ext3, ext4, and xfs. Compatibility with these various instantiated file systems can be cumbersome and require unnecessary checks and adaptations. The FS layer, which handles instantiated I / O read and write formats, converts virtual offset addresses to physical storage offset addresses based on the instantiated FS metadata. The block layer, used for traditional HDDs or SSDs, suffers from poor performance and requires I / O merging, queuing, and sector addressing. However, NVMe eliminates sector addressing, allowing for consistent random access to any location, eliminating the need for special scheduling and enabling direct I / O access, resulting in high speed. The device driver layer converts physical offset addresses into a command set directly understood by NVMe devices. This architecture can lead to I / O performance bottlenecks when handling NVMe devices and fails to meet the high-performance storage requirements of modern computer systems.
[0043] It can be seen that how to further improve the IO request concurrency of NVMe devices under the Linux system, improve the overall IO performance of the operating system, and give full play to the performance of NVMe devices is an urgent problem to be solved by those skilled in the art.
[0044] To address the technical issues mentioned above, the present invention provides a file system IO acceleration solution, which belongs to the field of computer file system IO technology. This solution converts some IO requests (data plane read and write) directly at the VFS layer into non-volatile memory host controller interface specification commands, namely NVMecmd, and writes them directly to the hardware RQ / CQ. Furthermore, the input and output ring queue mechanism, namely the io_uring mechanism, is used to poll the request results, thereby shortening the IO stack and improving IO performance in NVMe device scenarios.
[0045] like Figure 1 As shown, the flowchart clearly shows the workflow of the present invention. The application initiates a data input and output request, i.e., a read and write request, on the data plane. The request first reaches the VFS layer; the VFS layer converts the request into an NVMe command and writes it into the RQ of the NVMe device; the NVMe device obtains the command from the RQ and executes it, placing the result into the CQ; the io_uring mechanism polls the CQ, obtains the command execution result, and returns the result to the VFS layer; finally, the VFS layer returns the result to the application. In this way, the present invention achieves acceleration of file system IO and improves IO performance in the NVMe device scenario.
[0046] Specifically, in order to enable those skilled in the art to better understand the solutions of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0047] Next, a request processing method provided by an embodiment of the present invention is described in detail. Figure 2 A request processing method provided in an embodiment of the present invention includes:
[0048] S101. When an application sends a data input / output request, the data input / output request is transmitted to the virtual file system layer.
[0049] S102. At the virtual file system layer, convert the data input / output request into a non-volatile memory host controller interface specification command, and write the non-volatile memory host controller interface specification command into a submission queue of a target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command.
[0050] The target non-volatile memory host controller interface specification device executes the non-volatile memory host controller interface specification command and writes the execution result into a completion queue of the target non-volatile memory host controller interface specification device.
[0051] The application initiates an IO request through a standard file operation interface, and then, after receiving the IO request, calls a processing function to forward the request to the virtual file system layer VFS layer.
[0052] In the traditional Linux I / O stack, the VFS layer plays a crucial role. It serves as an abstraction layer for file system operations, providing user programs with a unified file operation interface, enabling consistent access to different file systems. This traditional solution must accommodate HDDs, SSDs, and NVMe devices. Therefore, in the traditional I / O process, when an application initiates a read or write request, it undergoes multiple layers of processing before ultimately reaching the device driver layer, which then sends the request to the storage device. Specifically, after receiving a read or write request from the user, the VFS layer passes it to the block layer for processing. The block layer performs a series of conversions and dispatches the request, such as converting logical block addresses to physical block addresses and performing I / O scheduling. This process involves extensive software-level dispatching and data transfers. While these operations are necessary for traditional mechanical hard drives or SATA solid-state drives, they add unnecessary overhead and latency for NVMe devices. This universal design has become a performance barrier.
[0053] NVMe devices have extremely low access latency and extremely high concurrent processing capabilities to meet the needs of modern data centers for high-performance storage. Therefore, the present invention introduces special processing logic for NVMe devices in the VFS layer, converting them into non-volatile memory host controller interface specification commands. NVMe commands are an instruction set designed specifically for NVMe devices. They contain detailed information about device operations, such as read and write data addresses, data lengths, operation types, etc. This conversion process requires accurately mapping the semantics of user requests to the format of NVMe commands to ensure that the commands can be correctly understood and executed by NVMe devices.
[0054] In addition, in the traditional IO process, data needs to go through multiple memory copies, which greatly reduces the IO performance. Therefore, the present invention adopts a more direct method to write the converted NVMe commands directly into the hardware submission queue RQ of the NVMe device. The hardware queue of the NVMe device is an important interface for it to communicate with the host. By directly operating the hardware queue, the software scheduling of the middle layer can be bypassed, reducing unnecessary overhead. Figure 3, when writing NVMe commands to RQ, it is necessary to follow a certain format and order. Each NVMe command has a fixed format, which contains the command's opcode, data address, data length and other information. When writing a command, this information needs to be filled into the command entry in the correct format, and the command entry is placed in RQ in sequence. At the same time, the tail pointer of RQ needs to be updated to notify the NVMe device that a new command has arrived. The NVMe device will continuously monitor the tail pointer of RQ, and when a new command is found, it will take the command out of RQ and execute it. After the execution is completed, the result is placed in the completion queue (CQ). The completion queue is the channel for the NVMe device to return the command execution result to the host. The host can obtain the command execution result by polling CQ. The Figure 3 This shows the process of NVMe commands being written from the host VFS layer to the NVMe device RQ through memory mapping, and the NVMe device executing the command, placing the result into the CQ, and feeding it back to the host.
[0055] S103. Obtain the execution result in the CQ of the target NVMe device and send the execution result to the application.
[0056] See also Figure 4 , showing the traditional IO process and the improved process of the present invention. In the traditional process, the read and write requests of the application are processed from the VFS layer to the block layer and then to the NVMe device; in the present invention, the VFS layer directly converts the request into an NVMe command and passes it to the NVMe device, bypassing the block layer and avoiding the overhead caused by multiple memory copies in the traditional process. Each time the memory is copied, the CPU needs to send a control instruction, including the source address, destination address, and length; because the NVMe device itself has efficient data transmission capabilities, in the embodiment of the present invention, no memory copy is made, and the CPU does not need to send control instructions. Reducing memory copies can make the performance of the NVMe device more fully utilized. At the same time, the CPU's participation in the memory copy process is reduced, so that the CPU can use more resources to process other tasks, thereby improving the overall performance of the system.
[0057] It can be seen that in an embodiment of the present invention, when an application sends a data input / output request, the data input / output request is transmitted to the virtual file system layer; in the virtual file system layer, the data input / output request is converted into a non-volatile memory host controller interface specification command, and the non-volatile memory host controller interface specification command is written into the submission queue of the target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command, so that the target non-volatile memory host controller interface specification device executes the non-volatile memory host controller interface specification command and writes the execution result into the completion queue of the target non-volatile memory host controller interface specification device; the execution result in the completion queue of the target non-volatile memory host controller interface specification device is obtained, and the execution result is sent to the application.
[0058] The present invention introduces special processing logic for non-volatile memory host controller interface specification devices in the virtual file system layer, converts IO requests into non-volatile memory host controller interface specification commands, and transmits them to the submission queue of the target non-volatile memory host controller interface specification device. After the non-volatile memory host controller interface specification device executes the command, it puts the result into the completion queue and feeds it back to the host. This bypasses the block layer and avoids the overhead caused by multiple memory copies in the traditional process, thereby accelerating file system data input and output requests and improving data input and output performance in the non-volatile memory host controller interface specification device scenario.
[0059] A possible implementation of an embodiment of the present invention is to convert a data input / output request into a non-volatile memory host controller interface specification command at a virtual file system layer, including: determining a request type of the data input / output request at the virtual file system layer; if the request type is a regular request, converting the data input / output request into a non-volatile memory host controller interface specification command at the virtual file system layer according to a first predefined mapping table; if the request type is a complex request, converting the data input / output request into a non-volatile memory host controller interface specification command at the virtual file system layer according to a second predefined mapping table.
[0060] To achieve efficient conversion, a predefined first and second mapping tables are used. The first predefined mapping table stores the correspondence between common user requests and NVMe commands. By searching the first predefined mapping table, the conversion of most requests can be completed quickly. For some complex requests, an algorithm combined with the second predefined mapping table can be used for dynamic conversion. At the same time, to ensure the correctness and stability of the conversion, strict error handling and verification are also required during the conversion process.
[0061] For conventional requests, refer to the first predefined mapping table, such as Table 1.
[0062] Table 1 NVMe protocol instruction set
[0063]
[0064] Among them, some definitions of NVMe command operation codes (opcodes): Flush (refresh command) corresponds to 0b00000b00b, Write corresponds to 0b00000b01b, and Read corresponds to 0b00000b10b.
[0065] For complex file system requests (such as read and write operations with special flags, atomic operations, or operations involving file metadata), the first predefined mapping table cannot be processed directly and needs to be converted through a dynamic algorithm. This dynamic conversion mechanism requires precise analysis of the request semantics and mapping it to the corresponding NVMe command set, namely the second predefined mapping table.
[0066] Furthermore, for complex requests, at the virtual file system layer, data input and output requests are converted into non-volatile memory host controller interface specification commands according to a second predefined mapping table, including: at the virtual file system layer, semantically parsing the data input and output requests to obtain special operation identifiers and key parameters; constructing non-volatile memory host controller interface specification commands based on the special operation identifiers, key parameters and the second predefined mapping table; mapping the file system logical address to the physical address of the target non-volatile memory host controller interface specification device according to the file offset in the key parameters, and performing data block alignment.
[0067] Specifically, the semantic parsing of data input and output requests is performed: (1) Analyzing the special operation identifiers in the VFS request (such as the O_DIRECT and O_SYNC flags); (2) Extracting key parameters such as file offset, length, and access mode; (3) Identifying special operations with special operation identifiers (such as atomic writes and sparse file processing). NVMe command construction: (1) Selecting the appropriate NVMe command type (such as NVM_WRITE and NVM_READ) based on the operation type in the parsed result; (2) Setting the command-specific fields (such as the FUA flag corresponding to the O_SYNC request). 3. Address translation: (1) Mapping the file system logical address to the NVMe physical address; (2) Processing data block alignment (which must comply with the LBA size requirements of the NVMe device).
[0068] It can be seen that in the embodiment of the present invention, in order to achieve efficient conversion, the predefined first mapping table and the second predefined mapping table are used, which can classify and convert commands, thereby improving conversion efficiency.
[0069] A possible implementation of an embodiment of the present invention, at the virtual file system layer, after converting a data input / output request into a non-volatile memory host controller interface specification command, further includes at least one of the following: performing a validity check on the non-volatile memory host controller interface specification command; determining whether submission of the non-volatile memory host controller interface specification command has timed out, and if so, resubmitting the non-volatile memory host controller interface specification command.
[0070] Specifically, to ensure the correctness and stability of the conversion process, strict error handling and verification must be implemented in multiple links:
[0071] 1. Parameter validity check, (1) check whether the request length meets the device limit; (2) verify whether the file offset is aligned. Specifically, the request length must meet the block limit size of the target nvme device. Generally, the request length is usually an integer multiple of the block size. If the request length does not meet the device limit, the IO operation may fail and return an error. When performing IO operations, the file offset (i.e., the offset set by lseek()) usually needs to be aligned to the block size of the device. For example, if the block size is 4096 bytes, the offset should be an integer multiple of 4096 (such as 0, 4096, 8192, etc.); if the offset is not aligned, the IO operation may fail or cause data corruption. Therefore, before the IO operation, calculate whether the file offset is an integer multiple of the block size; if the offset is not aligned, you can adjust the offset or report an error to the user.
[0072] 2. Error handling during the conversion process: (1) Memory allocation failure handling; (2) Address mapping error handling; (3) Command construction exception capture. During the conversion process, the memory address must be aligned with the device block size. Continuously check the return value of the memory allocation function to ensure that the memory allocation is successful. Ensure that the mmap call is successful and check whether the returned address is MAP_FAILED. Continuously check the command construction result to see if a failure indicator is returned.
[0073] 3.NVMe command submission and execution verification, (1) integrity check before command submission; (2) status code verification based on completion queue (CQ); (3) timeout handling and retry mechanism.
[0074] Specifically, it verifies that each field in the NVMe command complies with the protocol specification, that the parameters in the command are within the range supported by the device, and that the queue and buffer resources required to submit the command are available. Submission is made using the completion queue, and based on the completion queue's status code, it verifies that the command was successfully retrieved from the completion queue and written to the NVMe device's RQ. High system load may prevent a timely response, so a timer is started when the command is submitted, triggering a callback after the timeout.
[0075] It can be seen that in the embodiment of the present invention, verification and validation can be performed, which ensures the correct issuance of commands and improves the reliability of the system.
[0076] One possible implementation of an embodiment of the present invention converts a data input / output request into a non-volatile memory host controller interface specification command at a virtual file system layer, including: determining at the virtual file system layer whether the device corresponding to the requested location of the data input / output request is a non-volatile memory host controller interface specification device; if so, converting the data input / output request into a non-volatile memory host controller interface specification command; and if not, processing the request sequentially through the virtual file system layer, the block layer, and the device driver layer.
[0077] In an embodiment of the present invention, when the VFS layer receives a data plane read or write request for an NVMe device, it first analyzes and determines whether the request is for a supported NVMe device by checking the request location within the IO request. Once the request is determined to be for an NVMe device, the VFS layer calls a dedicated conversion function to convert the user's read or write request into an NVMe command. If the device is not an NVMe device, the request is processed sequentially through the VFS layer, the block layer, and the device driver layer.
[0078] It can be seen that in the embodiment of the present invention, the request is first analyzed and judged. Once it is determined that the request is for the NVMe device, the user's read and write request is converted into an NVMe command.
[0079] A possible implementation method of an embodiment of the present invention, before writing a non-volatile memory host controller interface specification command into a submission queue of a target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command, also includes: obtaining a physical memory address of the target non-volatile memory host controller interface specification device; using a memory mapping function provided by an operating system to map the physical memory address to a virtual address in a user space, so as to directly access the submission queue of the target non-volatile memory host controller interface specification device, thereby facilitating writing the non-volatile memory host controller interface specification command into the submission queue of the target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command.
[0080] In order to write commands directly to the submission queue of the target Non-Volatile Memory Host Controller Interface Specification device, it is necessary to access the registers and queues of the NVMe device through memory mapping. Memory mapping is a technology that maps physical memory addresses to user space. In this way, user programs can directly access the memory area of the hardware device without the need for data transfer through system calls.
[0081] When performing memory mapping, you need to first obtain the physical memory address of the NVMe device, and then use the memory mapping function provided by the operating system to map it to the virtual address of the user space. After the mapping is completed, the user program can access the registers and queues of the NVMe device just like accessing ordinary memory. Specifically, the process of the Linux system obtaining the physical address of the NVMe device can be summarized as follows: (1) PCI bus enumeration: The kernel discovers the NVMe device and reads its configuration space. (2) BAR parsing: Get the BAR value from the configuration space and calculate the actual physical address range. (3) Kernel mapping: Map the BAR physical address to the kernel virtual address through pci_iomap().
[0082] It can be seen that in the embodiment of the present invention, a mapping relationship is pre-constructed so that a user program can directly access the memory area of a hardware device without performing data transmission through a system call.
[0083] A possible implementation of an embodiment of the present invention is to obtain the execution result in the completion queue of the target non-volatile memory host controller interface specification device, including: at the virtual file system layer, obtaining the execution result in the completion queue of the target non-volatile memory host controller interface specification device through an input and output ring queue mechanism.
[0084] The completion queue represents the queue used by NVMe devices to return command execution results. When the host submits a command to the NVMe device, the NVMe device writes the command execution result (including success or failure status) to the completion queue for the host to read. The execution result refers to the information returned to the host via the completion queue after the NVMe device completes the command. It includes the command execution status (such as success or failure), error code (if any), and other relevant data. For example, at the virtual file system layer, when an application initiates a file read or write request, the VFS layer converts the request into an NVMe command and submits it to the NVMe device's RQ. After executing the command, the NVMe device writes the result to the completion queue (CQ). The VFS layer retrieves the execution result from the completion queue and returns it to the application. By promptly obtaining the execution result, the virtual file system layer can promptly detect and process the command result, thereby improving system reliability.
[0085] A possible implementation of an embodiment of the present invention is to obtain the execution result in the completion queue of the target non-volatile memory host controller interface specification device, including: obtaining the execution result in the completion queue of the target non-volatile memory host controller interface specification device through event polling notification.
[0086] Event polling notification refers to a mechanism that periodically checks or polls for specific event status and triggers notifications when an event occurs. Create an epoll instance using epoll_create(), add or delete file descriptors and their events of interest (new execution results in the completion queue) using epoll_ctl(). Block and wait for I / O events using epoll_wait(), and return a list of ready file descriptors when an event occurs. The corresponding I / O events are processed based on the returned list of file descriptors. This shows that in this embodiment of the present invention, event notification is highly efficient, which can improve the efficiency of obtaining execution results.
[0087] A possible implementation of an embodiment of the present invention is to obtain, at the virtual file system layer, the execution result in the completion queue of the target non-volatile memory host controller interface specification device through an input and output ring queue mechanism, including: polling the completion queue of the target non-volatile memory host controller interface specification device through the input and output ring queue mechanism, obtaining the execution result of the target non-volatile memory host controller interface specification device, and transmitting it to the virtual file system layer.
[0088] In traditional IO operations, the host typically waits for the completion of IO requests in either a synchronous or asynchronous manner. The synchronous method causes the host to be blocked during the waiting process, preventing it from performing other operations and reducing the system's concurrent processing capabilities. While the asynchronous method allows the host to continue executing other tasks during the waiting process, it requires callback functions or signals to handle IO completion events, increasing programming complexity. To address these issues, the present invention utilizes the io_uring mechanism to poll the completion queue (CQ) of the NVMe device. io_uring is a high-performance asynchronous IO mechanism provided by the Linux kernel that implements efficient IO operations through a shared memory ring queue and zero-copy technology.
[0089] A possible implementation of an embodiment of the present invention includes, at a virtual file system layer, polling the completion queue of a target non-volatile memory host controller interface specification device through an input / output ring queue mechanism to obtain an execution result of the target non-volatile memory host controller interface specification device, and further comprising: initializing an input / output ring queue instance to create a submission queue and a completion queue of the input / output ring queue; associating the input / output ring queue instance with the respective completion queues of a plurality of associated non-volatile memory host controller interface specification devices, so as to facilitate monitoring of the execution results of the plurality of associated non-volatile memory host controller interface specification devices through the input / output ring queue mechanism; the plurality of associated non-volatile memory host controller interface specification devices at least includes the target non-volatile memory host controller interface specification device.
[0090] When using the io_uring mechanism, you first need to initialize an io_uring instance and associate it with the CQ of the NVMe device to determine which NVMe devices to monitor. If only a certain NVMe device is currently in use, then you can monitor the results of this NVMe device. The initialization process includes creating the io's own RQ submission queue and CQ completion queue, setting the queue size and parameters, etc. Specifically, the submission queue records the producer (user application) and consumer (kernel); the completion queue records: producer (kernel); consumer (user application). The submission queue records which io requests have been issued and serves as the io_uring entry; the completion queue stores which io has been completed and serves as the io_uring exit. After converting ordinary io read and write instructions into NVMe commands, the NVMe commands are first placed in the submission queue to record which io have been issued. The completion queue is where the NMVe device places the results after processing the io. After the association is completed, io_uring will automatically monitor changes in the CQ.
[0091] When the NVMe device completes command execution, it encapsulates the result into a CompletionEntry and places it sequentially into the CQ. The io_uring mechanism detects new completion entries in the CQ through polling or event notifications. Once a new completion entry is detected, io_uring removes it from the CQ and parses the completion entry's contents to obtain the command execution result.
[0092] See also Figure 5 , Figure 5 The entire process is shown: the application initiates a request, the VFS layer sends an NVMe command to the NVMe device, the io_uring instance polls the NVMe device CQ to obtain the result and feeds it back to the VFS layer, and finally the VFS layer returns the result to the application.
[0093] A possible implementation of an embodiment of the present invention is to poll the completion queue of a target non-volatile memory host controller interface specification device through an input / output ring queue mechanism to obtain an execution result of the target non-volatile memory host controller interface specification device, including: determining whether a new execution result entry exists in the completion queue of the target non-volatile memory host controller interface specification device through the input / output ring queue mechanism; if so, parsing the new execution result entry to obtain the current execution result, and determining whether the current execution result corresponds to the execution result corresponding to the data input / output request; if so, determining to obtain the execution result of the target non-volatile memory host controller interface specification device. It can be seen that in this embodiment of the present invention, it is possible to monitor whether a new execution result entry exists in the completion queue of the target non-volatile memory host controller interface specification device, so as to obtain the execution result in a timely manner and return it to the host.
[0094] A possible implementation method of an embodiment of the present invention is to parse the new execution result entry to obtain the current execution result if it exists, including: if it exists, when the number of existing new execution result entries reaches a preset number, parse each new execution result entry to obtain each current execution result; accordingly, determine whether the current execution result is the execution result corresponding to the data input and output request, including: determine whether each current execution result has an execution result corresponding to the data input and output request.
[0095] To improve polling efficiency, io_uring employs batch processing. It can process multiple completion entries simultaneously, reducing the number of system calls and increasing processing speed. io_uring also supports asynchronous notifications. When a new completion entry appears in the CQ, the host is notified via event notifications, avoiding unnecessary polling overhead. After obtaining the command execution results, io_uring passes them to the VFS layer, which returns them to the application. Throughout this process, the host can continue executing other tasks while waiting for I / O completion, improving the system's concurrent processing capabilities and resource utilization.
[0096] A possible implementation of an embodiment of the present invention, before transmitting a data input / output request to a virtual file system layer, further includes: obtaining a plurality of test cases; testing a request handler according to each test case to obtain a test result; the request handler is a pre-set program capable of implementing a request processing method; if the test result does not meet the expected test result, optimizing parameters of the request handler according to the test result, the parameters including: queue depths of a completion queue and a submission queue of a target non-volatile memory host controller interface specification device, and queue sizes of a submission queue and a completion queue of an input / output ring queue.
[0097] After developing the request handler, the entire system undergoes comprehensive testing, including functional and performance testing. Functional testing primarily verifies that the system can correctly handle various types of IO requests, such as reads, writes, and random accesses. A series of test cases can be developed to simulate different application scenarios to verify that the system's responses and outputs meet expectations. The IO read and write performance of the validation solution is identical to that of the traditional solution, and the user will not notice it. For example, writing data to a specified location on an NVMe storage device successfully completes the write, and when read back, the data is the original data. Performance testing focuses on the system's IO performance metrics, such as throughput and latency. Professional performance testing tools, such as fio, can be used to stress test the system and record performance data under different loads. Based on the test results, optimization and parameter adjustments can be performed to further improve system performance and stability. For example, parameters such as the queue depth of the NVMe device and the queue size of io_uring can be adjusted to find the optimal performance configuration. At the same time, code optimization can be performed to reduce unnecessary overhead and improve system execution efficiency. Through continuous testing and optimization, the present file system IO acceleration solution can achieve optimal performance in practical applications.
[0098] A possible implementation method of an embodiment of the present invention is to test the request handler according to each test case to obtain a test result, including at least one of the following: performing a functional test on the request handler according to a test case of a functional test to obtain a functional test result; performing a performance test on the request handler according to a test case of a performance benchmark test to obtain a performance test result; performing a fault tolerance test on the request handler according to a test case of a fault tolerance test to obtain a fault tolerance test result.
[0099] For functional testing, various types of IO requests are designed, such as read, write, random access, etc.; then, the request is processed through the request handler to obtain the processing result, and the processing result is compared with the expected test result to determine the test result. If the execution results of all test cases are consistent with the expected results, the functional test of the request handler is considered to have passed. If the execution results of a test case are inconsistent with the expected result, the functional test of the request handler is considered to have failed and needs to be optimized. When optimizing parameters, it can be adjusted by technicians or automatically based on the results. For example, when the read and write latency exceeds the standard or the throughput is insufficient, the queue depth of the NVMe device is gradually increased / reduced to determine the optimal queue depth; when the IO request is blocked or the memory utilization is abnormal, the input and output ring queue size is gradually increased / reduced.
[0100] For performance benchmarking, design test cases covering different load scenarios (such as low load, high load, and peak load). Ensure that the hardware and software configurations of the test environment are largely consistent with those of the production environment. Execute the test cases and record performance metrics (such as throughput, latency, and resource utilization). Compare the test results with the expected performance targets to determine whether the request handler passes the performance test. If all performance metrics meet or exceed the expected targets, the performance test is considered passed. If any performance metric falls short of the target, optimization is required. Specifically, if the test results show performance degradation in high-concurrency scenarios, this may be due to insufficient queue depth on the NVMe device. Based on the test results, gradually increase or decrease the queue depth and observe the performance changes. After adjusting the queue depth, perform stress testing to verify performance under high concurrency. Furthermore, if I / O performance falls short of expectations, it may be due to an improperly set io_uring ring queue size. An undersized queue size may cause I / O requests to be blocked, while an oversized queue size may waste memory. Similarly, dynamically adjust the queue size based on the I / O load, gradually increasing or decreasing the queue depth and observing the performance changes. After adjusting the queue depth, perform stress testing to verify performance under high concurrency.
[0101] For fault-tolerant testing, pre-designed fault-tolerant test cases simulate various abnormal and boundary conditions; record test results, including error handling, system stability, and performance; compare and analyze actual test results with expected test results; and then adjust parameters based on the results.
[0102] It can be seen that in the embodiment of the present invention, various types of tests can be performed, so that the request processing program finally determined has excellent performance.
[0103] A possible implementation of an embodiment of the present invention is to write a non-volatile memory host controller interface specification command into a submission queue of a target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command, including: determining whether the actual queue depth of the submission queue of the target non-volatile memory host controller interface specification device is less than a preset queue depth; if so, writing the non-volatile memory host controller interface specification command into the submission queue of the target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command; if not, continuously monitoring the actual queue depth of the submission queue of the target non-volatile memory host controller interface specification device until the actual queue depth of the submission queue of the target non-volatile memory host controller interface specification device is less than the preset queue depth, and writing the non-volatile memory host controller interface specification command into the submission queue of the target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command.
[0104] In an embodiment of the present invention, a non-volatile memory host controller interface specification command is written into a submission queue of a target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command only if the actual queue depth is less than a preset queue depth, thereby ensuring that the NVMe command is written only when there is sufficient space in the queue, thereby avoiding overflow errors.
[0105] Based on any of the above embodiments, an embodiment of the present invention provides a specific file system IO acceleration solution that can implement a request processing method, including:
[0106] Step 1: Modify the VFS layer code.
[0107] Adding support for NVMe devices in the VFS layer code of the Linux kernel is the basis for implementing the present invention. As an abstract interface of the file system, the VFS layer needs to identify and process complex requests for NVMe devices.
[0108] First, the VFS layer adds identifiers and information related to the NVMe device to its data structure. A new structure can be created to store specific properties of the NVMe device, such as the device model, supported NVMe command sets, and queue depth. During system initialization, the NVMe device is identified through the device detection mechanism, and its related information is populated into the newly created structure. When the VFS layer receives a read or write request from the file system, it needs to determine whether the request is for an NVMe device. This can be done by examining the device information recorded when the file system was mounted or by using the device information associated with the file descriptor. Once the request is determined to be for a supported NVMe device, a dedicated conversion function is called to convert the request into an NVMe command. The conversion function generates the corresponding NVMe command structure based on the request type (e.g., read, write) and parameters (e.g., data address, length).
[0109] Step 2: Implement NVMe command write to RQ.
[0110] Writing code to write the converted NVMe commands directly to the hardware submission queue (RQ) of the NVMe device requires the use of memory mapping technology to access the registers and queues of the NVMe device.
[0111] First, you need to obtain the physical memory address of the NVMe device through the interface provided by the operating system. In the Linux kernel, you can use the pci_iomap function to map the configuration space and queue memory of the NVMe device. When the NVMe device is inserted into the server and the operating system recognizes the NVMe device (initialization), it is mapped once. After mapping is complete, the NVMe device's registers and queues can be accessed just like accessing ordinary memory. When writing NVMe commands, they must follow the format and sequence specified by the NVMe protocol. Each NVMe command has a fixed length and structure, and the various command fields (such as opcode, data address, length, etc.) must be filled in the corresponding positions.
[0112] Step 3: Integrate the io_uring mechanism.
[0113] Integrate the io_uring mechanism in the VFS layer and use the io_uring interface to poll the completion queue (CQ) of the NVMe device.
[0114] First, you need to initialize an io_uring instance. In the Linux kernel, you can use the io_uring_queue_init function to create an io_uring context and set the queue size and parameters. Associate the io_uring instance with the completion queue of the NVMe device. You can set the io_uring file descriptor and event mask to let io_uring monitor changes in the completion queue. When there is a new completion entry in the CQ, io_uring will notify the VFS layer through event notification. The VFS layer can use the io_uring_wait_cqe function to wait for the completion event and the io_uring_cqe_get_data function to obtain the data of the completion entry.
[0115] Step 4: Test and optimize.
[0116] After development is completed, the entire system is comprehensively tested, including functional testing, performance testing, etc.
[0117] Functional testing mainly verifies whether the system can correctly handle various types of IO requests, such as read, write, random access, etc. A series of test cases can be written to simulate different application scenarios to check whether the system's response and output meet expectations. Performance testing focuses on the system's IO performance indicators, such as throughput, latency, etc. Professional performance testing tools, such as fio, can be used to stress test the system and record performance data under different loads. Optimize and adjust parameters based on the test results to further improve the performance and stability of the system. For example, parameters such as the queue depth of the NVMe device and the queue size of io_uring can be adjusted to find the optimal performance configuration. At the same time, the code can also be optimized to reduce unnecessary overhead and improve the execution efficiency of the system. Through continuous testing and optimization, it is ensured that the file system IO acceleration solution of the present invention can achieve optimal performance in actual applications.
[0118] This paper provides a file system IO acceleration solution that directly converts some IO requests into NVMe commands at the VFS layer, bypassing the block layer and shortening the IO path. It also directly writes NVMe commands to the hardware RQ / CQ, reducing scheduling and processing overhead at the software level. Furthermore, it uses the io_uring mechanism to poll request results, improving the system's concurrent processing capabilities. Compared to existing solutions, this file system IO acceleration solution significantly improves IO performance in NVMe device scenarios by shortening the IO stack and eliminating unnecessary intermediate processing steps. It is specifically reflected in the following aspects: (1) Reduce latency: By bypassing the block layer, IO requests are directly converted into NVMe commands and written into the hardware queue, which reduces the data transmission path and time, and reduces the latency of IO operations; (2) Reduce memory copy loss: Open up the data link from the VFS layer to the NVMe device, greatly reducing the memory copy loss between user mode and kernel mode; (3) Improve throughput: By directly interacting with the hardware queue and referencing the io_uring mechanism, the system's concurrent processing capability is improved, thereby increasing the throughput of IO operations; (4) Give full play to the performance of NVMe devices: Optimize according to the characteristics of NVMe devices, avoid the limitations of traditional IO stacks on NVMe device performance, and give full play to the high performance advantages of NVMe devices.
[0119] The following is an introduction to a device provided by an embodiment of the present invention. The device described below and the method described above can be referenced to each other. Figure 6 , Figure 6This is a structural block diagram of an apparatus according to one embodiment of the present invention, comprising: a request transmission module 210, configured to transmit a data input / output request to a virtual file system layer when an application sends a data input / output request; a command conversion module 220, configured to convert the data input / output request into a non-volatile memory host controller interface specification command at the virtual file system layer, and write the non-volatile memory host controller interface specification command into a submission queue of a target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command, so that the target non-volatile memory host controller interface specification device executes the non-volatile memory host controller interface specification command and writes the execution result into a completion queue of the target non-volatile memory host controller interface specification device; and a result return module 230, configured to obtain the execution result in the completion queue of the target non-volatile memory host controller interface specification device and send the execution result to the application.
[0120] In a preferred example, the present invention can be further configured as follows: a command conversion module 220 is used to: determine the request type of the data input / output request at the virtual file system layer; if the request type is a regular request, then at the virtual file system layer, according to a first predefined mapping table, convert the data input / output request into a non-volatile memory host controller interface specification command; if the request type is a complex request, then at the virtual file system layer, according to a second predefined mapping table, convert the data input / output request into a non-volatile memory host controller interface specification command.
[0121] In a preferred example, the present invention can be further configured as: a command conversion module 220 is used to: perform semantic analysis on the data input and output request at the virtual file system layer to obtain special operation identifiers and key parameters; construct a non-volatile memory host controller interface specification command based on the special operation identifier, key parameters and a second predefined mapping table; map the file system logical address to the physical address of the target non-volatile memory host controller interface specification device according to the file offset in the key parameters, and perform data block alignment.
[0122] In a preferred example, the present invention can be further configured as follows: the command conversion module 220 is also used to: perform a validity check on the non-volatile memory host controller interface specification command; determine whether the submission of the non-volatile memory host controller interface specification command has timed out, and if so, resubmit the non-volatile memory host controller interface specification command.
[0123] In a preferred example, the present invention can be further configured as: a command conversion module 220 is used to: determine at the virtual file system layer whether the device corresponding to the request location of the data input / output request is a non-volatile memory host controller interface specification device; if it is a non-volatile memory host controller interface specification device, convert the data input / output request into a non-volatile memory host controller interface specification command.
[0124] In a preferred example, the present invention can be further configured as follows: the command conversion module 220 is further configured to: if it is not a non-volatile memory host controller interface specification device, process the request in sequence through the virtual file system layer, block layer, and device driver layer.
[0125] In a preferred example, the present invention can be further configured as follows: it also includes: a mapping module, which is used to obtain the physical memory address of the target non-volatile memory host controller interface specification device; use the memory mapping function provided by the operating system to map the physical memory address to the virtual address of the user space, so as to directly access the submission queue of the target non-volatile memory host controller interface specification device, thereby facilitating the writing of the non-volatile memory host controller interface specification command into the submission queue of the target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command.
[0126] In a preferred example, the present invention can be further configured as follows: a result return module 230 is used to obtain the execution result in the completion queue of the target non-volatile memory host controller interface specification device through the input and output ring queue mechanism at the virtual file system layer; and obtain the execution result in the completion queue of the target non-volatile memory host controller interface specification device through event polling notification.
[0127] In a preferred example, the present invention can be further configured as: a result return module 230 is used to poll the completion queue of the target non-volatile memory host controller interface specification device through an input and output ring queue mechanism, obtain the execution result of the target non-volatile memory host controller interface specification device, and transmit it to the virtual file system layer.
[0128] In a preferred example, the present invention can be further configured as follows: it also includes: an association module, which is used to initialize an input / output ring queue instance to create a submission queue and a completion queue of the input / output ring queue; associating the input / output ring queue instance with the completion queues of multiple associated non-volatile memory host controller interface specification devices, so as to monitor the execution results of multiple associated non-volatile memory host controller interface specification devices through the input / output ring queue mechanism; the multiple associated non-volatile memory host controller interface specification devices at least include the target non-volatile memory host controller interface specification device.
[0129] In a preferred example, the present invention can be further configured as follows: a result return module 230 is used to determine whether there is a new execution result entry in the completion queue of the target non-volatile memory host controller interface specification device through an input and output ring queue mechanism; if so, the new execution result entry is parsed to obtain the current execution result, and it is determined whether the current execution result is the execution result corresponding to the data input and output request. If so, it is determined to obtain the execution result of the target non-volatile memory host controller interface specification device.
[0130] In a preferred example, the present invention can be further configured as: a result return module 230, which is used to parse each of the new execution result entries to obtain each current execution result, if any, when the number of existing new execution result entries reaches a preset number; a result return module 230, which is used to determine whether each current execution result has an execution result corresponding to the data input and output request.
[0131] In a preferred example, the present invention can be further configured as follows: it also includes: a test module for obtaining multiple test cases; testing the request handler according to each test case to obtain a test result; the request handler is a pre-set program that can implement the request processing method; if the test result does not meet the expected test result, the parameters of the request handler are optimized according to the test result, and the parameters include: the queue depth of the completion queue and the submission queue of the target non-volatile memory host controller interface specification device, and the queue size of the submission queue and the completion queue of the input and output ring queue.
[0132] In a preferred example, the present invention can be further configured as: a testing module, used to: perform functional testing on the request handler according to the test cases of functional testing to obtain functional testing results; perform performance testing on the request handler according to the test cases of performance benchmark testing to obtain performance testing results; perform fault tolerance testing on the request handler according to the test cases of fault tolerance testing to obtain fault tolerance testing results.
[0133] In a preferred example, the present invention can be further configured as follows: a command conversion module 220 is used to: determine whether the actual queue depth of the submission queue of the target non-volatile memory host controller interface specification device is less than a preset queue depth; if so, write the non-volatile memory host controller interface specification command into the submission queue of the target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command; if not, continuously monitor the actual queue depth of the submission queue of the target non-volatile memory host controller interface specification device until the actual queue depth of the submission queue of the target non-volatile memory host controller interface specification device is less than the preset queue depth, and write the non-volatile memory host controller interface specification command into the submission queue of the target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command.
[0134] Figure 6 The description of the features in the corresponding embodiment can be found in Figure 2 The relevant descriptions of the corresponding embodiments will not be repeated here one by one.
[0135] Figure 7 A structural diagram of an electronic device provided by an embodiment of the present invention, such as Figure 7 As shown, the electronic device includes: a memory 60 for storing computer programs; and a processor 61 for implementing the steps of the request processing method described in the above embodiment when executing the computer program. The processor 61 may include one or more processing cores, such as a quad-core processor or an octal-core processor. The processor 61 may be implemented in at least one hardware form: a digital signal processing (DSP), a field-programmable gate array (FPGA), or a programmable logic array (PLA). The processor 61 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 61 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing content displayed on the display screen. In some embodiments, the processor 61 may also include an artificial intelligence (AI) processor for processing computational operations related to machine learning.
[0136] The memory 60 may include one or more computer-readable storage media, which may be non-transitory. The memory 60 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 60 is at least used to store the following computer program 601, wherein, after the computer program is loaded and executed by the processor 61, it can implement the relevant steps of the method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 60 may also include an operating system 602 and data 603, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 602 may include Windows, Unix, Linux, etc.
[0137] In some embodiments, the electronic device may further include a display screen 62 , an input / output interface 63 , a communication interface 64 , a power supply 65 , and a communication bus 66 .
[0138] Those skilled in the art will understand that Figure 7 The structure shown in the figure does not constitute a limitation of the electronic device, and may include more or fewer components than shown in the figure.
[0139] It is understood that if the request processing method in the above embodiment is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the current technology, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and performs all or part of the steps of the various embodiments of the present invention. The aforementioned storage medium includes: USB flash drives, mobile hard drives, read-only memories (ROM), random access memories (RAM), electrically erasable programmable ROMs, registers, hard drives, removable disks, CD-ROMs, magnetic disks, or optical disks, and other media that can store program code.
[0140] Based on this, an embodiment of the present invention further provides a request processing system, including: an electronic device and a target non-volatile memory host controller interface specification device.
[0141] Based on this, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method are implemented.
[0142] Based on this, an embodiment of the present invention further provides a computer program product, including a computer program / instruction, which implements the steps of the above method when executed by a processor.
[0143] The above describes in detail the request processing method, apparatus, device, system, medium, and product provided by the embodiments of the present invention. The various embodiments are described in a progressive manner throughout this specification, with each embodiment focusing on its differences from other embodiments. For similar or identical parts between the various embodiments, reference can be made to each other. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; for relevant details, refer to the method description.
[0144] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0145] The above is a detailed introduction to the request processing method, device, equipment, system, medium and product provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core ideas. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, the present invention can also be improved and modified in a number of ways, and these improvements and modifications also fall within the scope of protection of the present invention.
Claims
1. A request processing method, characterized in that: include: Get a variety of test cases; Test cases are used for functional testing and performance testing; Test the request handler according to each test case and get the test results; The request processing program is a pre-set program that can implement the request processing method; If the test result does not meet the expected test result, optimizing parameters of the request processing program according to the test result, the parameters including: queue depths of a completion queue and a submission queue of a target non-volatile memory host controller interface specification device, and queue sizes of a submission queue and a completion queue of an input / output ring queue; When the application sends a data input / output request, the data input / output request is transmitted to the virtual file system layer; At the virtual file system layer, converting the data input / output request into a non-volatile memory host controller interface specification command, and writing the non-volatile memory host controller interface specification command into a submission queue of a target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command, so that the target non-volatile memory host controller interface specification device executes the non-volatile memory host controller interface specification command and writes the execution result into a completion queue of the target non-volatile memory host controller interface specification device; Before writing the non-volatile memory host controller interface specification command into a submission queue of a target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command, the method further includes: Get the physical memory address of the target non-volatile memory host controller interface specification device; Mapping the physical memory address to a virtual address in a user space using a memory mapping function provided by an operating system, so as to directly access a submission queue of the target non-volatile memory host controller interface specification device; Polling the completion queue of the target non-volatile memory host controller interface specification device through an input and output ring queue mechanism, obtaining an execution result of the target non-volatile memory host controller interface specification device, transmitting the result to the virtual file system layer, and sending the execution result to the application; Before polling the completion queue of the target non-volatile memory host controller interface specification device through the input and output ring queue mechanism at the virtual file system layer to obtain the execution result of the target non-volatile memory host controller interface specification device, the method further includes: Initialize an input / output ring queue instance to create the submission queue and completion queue of the input / output ring queue; The input / output ring queue instance is associated with respective completion queues of a plurality of associated non-volatile memory host controller interface specification devices.
2. The request processing method according to claim 1, wherein: At the virtual file system layer, converting the data input / output request into a non-volatile memory host controller interface specification command includes: At the virtual file system layer, determining a request type of the data input / output request; If the request type is a regular request, converting the data input / output request into a non-volatile memory host controller interface specification command at the virtual file system layer according to a first predefined mapping table; If the request type is a complex request, then at the virtual file system layer, the data input / output request is converted into a non-volatile memory host controller interface specification command according to a second predefined mapping table.
3. The request processing method according to claim 2, wherein: At the virtual file system layer, converting the data input / output request into a non-volatile memory host controller interface specification command according to a second predefined mapping table includes: At the virtual file system layer, semantically analyzing the data input and output requests to obtain special operation identifiers and key parameters; Constructing a non-volatile memory host controller interface specification command based on the special operation identifier, key parameters and the second predefined mapping table; According to the file offset in the key parameter, the file system logical address is mapped to the physical address of the target non-volatile memory host controller interface specification device, and data block alignment is performed.
4. The request processing method according to claim 2, wherein: After the virtual file system layer converts the data input / output request into a non-volatile memory host controller interface specification command, the method further includes at least one of the following: Performing a validity check on the non-volatile memory host controller interface specification command; Determine whether submission of the non-volatile memory host controller interface specification command has timed out, and if so, resubmit the non-volatile memory host controller interface specification command.
5. The request processing method according to claim 1, wherein: At the virtual file system layer, converting the data input / output request into a non-volatile memory host controller interface specification command includes: At the virtual file system layer, determining whether the device corresponding to the request location of the data input / output request is a non-volatile memory host controller interface specification device; If it is a non-volatile memory host controller interface specification device, the data input and output request is converted into a non-volatile memory host controller interface specification command.
6. The request processing method according to claim 5, characterized in that: Also includes: If it is not a non-volatile memory host controller interface specification device, the request is processed in sequence through the virtual file system layer, block layer, and device driver layer.
7. The request processing method according to claim 1, wherein: Polling the completion queue of the target non-volatile memory host controller interface specification device through an input and output ring queue mechanism to obtain an execution result of the target non-volatile memory host controller interface specification device, including: Determining whether there is a new execution result entry in the completion queue of the target non-volatile memory host controller interface specification device through an input and output ring queue mechanism; If so, the new execution result entry is parsed to obtain the current execution result, and it is determined whether the current execution result is the execution result corresponding to the data input and output request. If so, it is determined to obtain the execution result of the target non-volatile memory host controller interface specification device.
8. The request processing method according to claim 7, characterized in that: If it exists, the new execution result entry is parsed to obtain the current execution result, including: If so, when the number of existing new execution result entries reaches a preset number, each of the new execution result entries is parsed to obtain each current execution result; Accordingly, determining whether the current execution result is the execution result corresponding to the data input / output request includes: Determine whether among the current execution results there is an execution result corresponding to the data input / output request.
9. The request processing method according to claim 1, wherein: Test the request handler according to each test case and obtain test results, including at least one of the following: Perform functional testing on the request handler according to the functional test case and obtain the functional test results; Perform performance testing on the request handler according to the test cases of the performance benchmark test and obtain the performance test results; According to the test cases of the fault-tolerance test, the request processing program is subjected to a fault-tolerance test to obtain the fault-tolerance test result.
10. The request processing method according to any one of claims 1 to 8, characterized in that: Writing the non-volatile memory host controller interface specification command into a submission queue of a target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command comprises: determining whether an actual queue depth of a submission queue of the target non-volatile memory host controller interface specification device is less than a preset queue depth; If so, writing the non-volatile memory host controller interface specification command into a submission queue of a target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command; If not, continuously monitor the actual queue depth of the submission queue of the target non-volatile memory host controller interface specification device until the actual queue depth of the submission queue of the target non-volatile memory host controller interface specification device is less than the preset queue depth, and write the non-volatile memory host controller interface specification command into the submission queue of the target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command.
11. A request processing device, characterized in that: include: A request transmission module, configured to transmit a data input / output request to the virtual file system layer when the application sends the data input / output request; a command conversion module configured to convert, at the virtual file system layer, the data input / output request into a non-volatile memory host controller interface specification command, and write the non-volatile memory host controller interface specification command into a submission queue of a target non-volatile memory host controller interface specification device corresponding to the non-volatile memory host controller interface specification command, so that the target non-volatile memory host controller interface specification device executes the non-volatile memory host controller interface specification command, and write an execution result into a completion queue of the target non-volatile memory host controller interface specification device; a result returning module, configured to poll the completion queue of the target non-volatile memory host controller interface specification device through an input / output ring queue mechanism, obtain an execution result of the target non-volatile memory host controller interface specification device, transmit the result to the virtual file system layer, and send the execution result to the application; Test module, used to obtain various test cases; Test cases are used for functional testing and performance testing; Test the request handler according to each test case and get the test results; The request processing program is a pre-set program that can implement the request processing method; If the test result does not meet the expected test result, optimizing parameters of the request processing program according to the test result, the parameters including: queue depths of a completion queue and a submission queue of a target non-volatile memory host controller interface specification device, and queue sizes of a submission queue and a completion queue of an input / output ring queue; A mapping module for obtaining a physical memory address of a target non-volatile memory host controller interface specification device; Mapping the physical memory address to a virtual address in a user space using a memory mapping function provided by an operating system, so as to directly access a submission queue of the target non-volatile memory host controller interface specification device; The associated module is used to initialize an input and output ring queue instance to create the submission queue and completion queue of the input and output ring queue; The input / output ring queue instance is associated with respective completion queues of a plurality of associated non-volatile memory host controller interface specification devices.
12. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to execute the computer program to implement the steps of the request processing method according to any one of claims 1 to 10.
13. A request processing system, characterized in that: include: The electronic device and target non-volatile memory host controller interface specification device as claimed in claim 12.
14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the request processing method according to any one of claims 1 to 10 are implemented.
15. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the request processing method according to any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Data processing method and device, electronic device and medium
CN114238358A
Data read-write method, system and device, computing equipment and storage medium
CN119376656A