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 to the hardware queue, bypassing the block layer processing, and combining the io_uring mechanism, the limitations on NVMe device performance of the traditional Linux IO stack are solved, and the IO performance is improved.
Patent Information
- Application Number
- CN202510713887.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2045-05-30
AI Technical Summary
The traditional Linux IO stack adds unnecessary overhead when handling NVMe devices, and cannot fully utilize its high-performance features, resulting in IO performance bottlenecks.
In the virtual file system layer, IO requests are directly converted into NVMe commands and written to the hardware submission queue of the NVMe device. Bypassing the block layer processing, the io_uring mechanism is used to poll the completion queue to obtain execution results, reducing memory copying and software scheduling.
It improves IO performance in NVMe device scenarios, reduces latency and memory copy overhead, and fully utilizes the high-performance advantages of NVMe devices.
Smart Images

Figure CN120256405A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer file system I / O, and particularly to a request processing method, apparatus, device, system, medium, and product. Background Art
[0002] In a computer system, file system I / O (input / output) performance is one of the key factors affecting the overall system performance. The traditional Linux I / O stack adopts a hierarchical architecture. When an I / O operation is performed, data needs to pass through the VFS (Virtual File System layer), FS layer (File System), block layer, and finally reach the device driver layer in sequence.
[0003] NVMe (Non-Volatile Memory Express) is a high-performance interface protocol specifically designed for non-volatile storage devices, featuring low latency and high concurrency.
[0004] However, although the above architecture of the Linux I / O stack has good generality and scalability, when dealing with high-performance NVMe devices, it will increase the data transmission path and time, introduce unnecessary overhead, and cannot fully utilize the performance advantages of NVMe devices.
[0005] It can be seen that how to reduce the overhead of NVMe devices when processing I / O requests is a problem that needs to be solved by those skilled in the art. Summary of the Invention
[0006] The object of the present invention is to provide a request processing method, apparatus, device, system, medium, and product, which can reduce the overhead of NVMe devices when processing I / O requests.
[0007] In a first aspect, a request processing method is provided, including: 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, 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 writing an 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 of the present invention, it can be further configured as: in the virtual file system layer, converting the data input / output request into a non-volatile memory host controller interface specification command includes: in the virtual file system layer, determining a request type of the data input / output request; if the request type is a regular request, then in the virtual file system layer, converting the data input / output request into a non-volatile memory host controller interface specification command according to a first predefined mapping table; if the request type is a complex request, then in 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.
[0009] In a preferred example of the present invention, it can be further configured as: in the virtual file system layer, converting the data input / output request into a non-volatile memory host controller interface specification command according to the second predefined mapping table includes: in the virtual file system layer, performing semantic parsing on the data input / 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 a file system logical address to a physical address of a target non-volatile memory host controller interface specification device according to a file offset in the key parameters, and performing data block alignment.
[0010] In a preferred example of the present invention, it can be further configured as: after converting the data input / output request into a non-volatile memory host controller interface specification command in the virtual file system layer, at least one of the following is further included: performing a legality check on the non-volatile memory host controller interface specification command; determining whether submission of the non-volatile memory host controller interface specification command times out, and if it times out, resubmitting the non-volatile memory host controller interface specification command.
[0011] In a preferred example, the present invention can be further configured as follows: in the virtual file system layer, convert the data input / output request into a Non-Volatile Memory Host Controller Interface (NVMe) specification command, including: in the virtual file system layer, determine whether the device corresponding to the request location of the data input / output request is an NVMe specification device; if it is an NVMe specification device, then convert the data input / output request into an NVMe specification command.
[0012] In a preferred example, the present invention can be further configured as follows: further include: if it is not an NVMe specification device, then perform request processing sequentially 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 NVMe specification command into the submission queue of the target NVMe specification device corresponding to the NVMe specification command, further include: obtain the physical memory address of the target NVMe specification device; use the memory mapping function provided by the operating system to map the physical memory address to a virtual address in the user space, so as to directly access the submission queue of the target NVMe specification device, which is convenient for writing the NVMe specification command into the submission queue of the target NVMe specification device corresponding to the NVMe specification command.
[0014] In a preferred example, the present invention can be further configured as follows: obtain the execution result in the completion queue of the target NVMe specification device, including: in the virtual file system layer, obtain the execution result in the completion queue of the target NVMe specification device through the input / output ring queue mechanism; and / or, obtain the execution result in the completion queue of the target NVMe specification device through the event polling notification method.
[0015] In a preferred example, the present invention can be further configured as follows: in the virtual file system layer, obtain the execution result in the completion queue of the target NVMe specification device through the input / output ring queue mechanism, including: poll the completion queue of the target NVMe specification device through the input / output ring queue mechanism, obtain the execution result of the target NVMe specification device, and transmit it to the virtual file system layer.
[0016] In a preferred example, the present invention can be further configured as follows: before polling the completion queue of the target Non-Volatile Memory Host Controller Interface (NVMe) device through an input-output ring queue mechanism to obtain the execution result of the target NVMe device, it further 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 NVMe devices, so as to facilitate monitoring the execution results of the multiple associated NVMe devices through the input-output ring queue mechanism; the multiple associated NVMe devices at least include the target NVMe device.
[0017] In a preferred example, the present invention can be further configured as follows: polling the completion queue of the target NVMe device through an input-output ring queue mechanism to obtain the execution result of the target NVMe device, includes: determining whether there is a new execution result entry in the completion queue of the target NVMe 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 that the execution result of the target NVMe device is obtained.
[0018] In a preferred example, the present invention can be further configured as follows: if so, parsing the new execution result entry to obtain the current execution result, includes: if so, 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; correspondingly, determining whether the current execution result is the execution result corresponding to the data input-output request, includes: determining whether there is an execution result corresponding to the data input-output request among the respective current execution results.
[0019] In a preferred example, the present invention can be further configured as follows: before transmitting the data input-output request to the virtual file system layer, it further includes: obtaining multiple 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 handling 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 include: the queue depths of the completion queue and the submission queue of the target NVMe device, and the queue sizes of the submission queue and the completion queue of the input-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 a function test on the request handler according to the test case of the function test to obtain a function test result; performing a performance test on the request handler according to the test case of the performance benchmark test to obtain a performance test result; performing a fault tolerance test on the request handler according to the test case of the fault tolerance test to obtain a fault tolerance test result.
[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 the 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, including: a request transmission module, configured to transmit the data input / output request to the virtual file system layer when an application program sends a data input / output request; a command conversion module, configured to convert the data input / output request into a non-volatile memory host controller interface specification command in the virtual file system layer, 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, so that the target non-volatile memory host controller interface specification device executes the non-volatile memory host controller interface specification command, and write the execution result into the completion queue of the target non-volatile memory host controller interface specification device; a result return module, 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 program.
[0023] In a third aspect, an electronic device is provided, which includes a memory and a processor. A computer program is stored in the memory, and when the processor runs the computer program, it executes the request processing method according to any one of the first aspect.
[0024] In a fourth aspect, a request processing system is provided, including: 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, in which at least one program code is stored, and the program code is loaded and executed by a processor to implement the request processing method according to any one of the first aspect.
[0026] In a sixth aspect, a computer program product is provided, including a computer program or instruction, and when the computer program or instruction is executed by a processor, it implements the request processing method according to any one of the first aspect.
[0027] In summary, the request processing method provided by the present invention has the following beneficial technical effects: when an application program 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 program.
[0028] The present invention introduces special processing logic for non-volatile memory host controller interface specification devices in the virtual file system layer, converts the IO request into a non-volatile memory host controller interface specification command, and passes it 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, the result is put into the completion queue and fed back to the host, bypassing the block layer and avoiding the overhead caused by multiple memory copies in the traditional process, realizing the acceleration of file system data input / output requests and improving the data input / 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, device and medium, all of which have the above beneficial technical effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] To more clearly illustrate the embodiments of the present invention, the following will briefly introduce the accompanying drawings required for use in the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.
[0031] Figure 1 It is a schematic flowchart of a request processing provided for the embodiments of the present invention.
[0032] Figure 2 It is a schematic flowchart of another request processing method provided for the embodiments of the present invention.
[0033] Figure 3 It is a schematic flowchart of another request processing method provided for the embodiments of the present invention.
[0034] Figure 4 It shows a traditional IO process and an improved process of the present invention provided for the embodiments of the present invention.
[0035] Figure 5 It is a schematic diagram of the processing after an application initiates a request provided for the embodiments of the present invention.
[0036] Figure 6 It is a schematic structural diagram of a request processing device provided for the embodiments of the present invention.
[0037] Figure 7 It is a schematic structural diagram of an electronic device provided for the embodiments of the present invention. Detailed implementation manners
[0038] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.
[0039] The terms "including" and "having" in the specification of the present invention and any deformations related to "including" and "having" are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may include unlisted steps or units.
[0040] To better understand and illustrate the solutions of the embodiments of the present invention, the following briefly explains some technical terms involved in the embodiments of the present invention.
[0041] IO: Input / Output of a computer system; VFS: Virtual File System. In the present invention, VFS already includes FS; NVMe: Non-Volatile Memory Express; RQ: Submission Queue, which is the channel for the host to send commands to the NVMe device; CQ: Completion Queue, which is the channel for the NVMe device to return the command execution results to the host. Physical Address: The physical memory or register address exposed by a hardware device (such as an NVMe controller, a graphics card, etc.) through a bus (such as PCIe, DMA). Virtual Address: The virtual memory address allocated by the host operating system for a process, which is mapped to the physical address through a page table. The essence of memory mapping: Establish a mapping relationship between the virtual address and the physical address of the device, so that the host program can operate the device resources just like accessing ordinary memory.
[0042] Currently, the traditional Linux IO stack architecture adopts a unified processing flow when dealing with various storage devices and is not optimized for the characteristics of NVMe devices. Specifically, the VFS layer is used to unify the io read / write format -> various instantiated io read / write formats, such as ext3, ext4, xfs, etc.; it is very redundant to be compatible with various instantiated file systems, adding a lot of unnecessary checks and adaptations. The FS layer is used for the instantiated io read / write format, and according to the instantiated fs metadata information, it performs the conversion of the virtual offset address -> the storage physical offset address. The block layer is used for traditional HDDs or SSDs, with poor performance, and needs to perform io merging, queuing, and sector addressing. While a single NVMe does not require sector addressing, and the performance of randomly accessing any position is the same, without the need for special scheduling, the io can be directly sent down, with high speed. The device driver layer is used to convert the physical offset address into a command set that can be directly recognized by the NVMe device. When dealing with NVMe devices, this architecture will lead to an IO performance bottleneck and cannot meet the requirements of modern computer systems for high-performance storage.
[0043] Therefore, it can be seen that how to further improve the concurrency of IO requests for NVMe devices under the Linux system, enhance 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] In order to solve the related technical problems in the above background technology, the present invention provides a file system IO acceleration solution, which belongs to the field of computer file system IO technology. By directly converting part of the IO requests (reading and writing of the data plane) into non-volatile memory host controller interface specification commands, namely NVMecmd, at the VFS layer, and directly writing them to the hardware RQ / CQ, the input and output ring queue mechanism, namely the io_uring mechanism, is further referenced to poll the request results, thereby shortening the IO stack and improving the IO performance in the NVMe device scenario.
[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, and 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, and puts 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 realizes the acceleration of the file system IO and improves the IO performance in the NVMe device scenario.
[0046] Specifically, in order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with 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 by an embodiment of the present invention includes: S101. When an application sends a data input / output request, the data input / output request is transmitted to a virtual file system layer.
[0048] S102: 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.
[0049] 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.
[0050] 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.
[0051] In the traditional Linux I / O stack system, the VFS layer plays a crucial role. It is the abstraction layer of file system operations, providing a unified file operation interface for user programs, enabling different file systems to be accessed in a consistent manner. This traditional solution needs to take into account HDD, SSD, and NVMe devices simultaneously. Therefore, in the traditional I / O process, when an application issues a read / write request, after being processed through multiple levels, it finally reaches the device driver layer, and the device driver layer sends the request to the storage device. Specifically, after receiving the user's read / write request, the VFS layer passes it to the block layer for processing. The block layer performs a series of conversions and scheduling on the request, such as converting the logical block address to the physical block address, performing I / O scheduling, etc. In this process, a large number of software-level scheduling and data transmissions are involved. These operations are necessary when dealing with traditional mechanical hard disks or SATA solid-state drives, but for NVMe devices, they increase unnecessary overhead and latency. This general-purpose design has instead become an obstacle to performance improvement.
[0052] NVMe devices have extremely low access latency and extremely high concurrent processing capabilities to meet the requirements of modern data centers for high-performance storage. Therefore, the present invention introduces special processing logic for NVMe devices in the VFS layer, converting it into Non-Volatile Memory Host Controller Interface Specification commands. NVMe commands are an instruction set specifically designed for NVMe devices, which contain detailed information about device operations, such as the data address to be read / written, data length, operation type, etc. This conversion process requires accurately mapping the semantics of the user request into the format of NVMe commands to ensure that the commands can be correctly understood and executed by NVMe devices.
[0053] In addition, in the traditional I / O process, data needs to undergo multiple memory copies, which greatly reduces I / O performance. Therefore, the present invention adopts a more direct approach, directly writing the converted NVMe commands into the hardware submission queue RQ of the NVMe device. The hardware queue of the NVMe device is an important interface for its communication with the host. By directly operating on the hardware queue, the software scheduling of the intermediate layer can be bypassed, reducing unnecessary overhead. See Figure 3, when writing an NVMe command to the RQ, it needs to be done in a certain format and order. Each NVMe command has a fixed format, which includes information such as the opcode, data address, and data length of the command. When writing the command, these information need to be filled into the command entry in the correct format, and the command entries are sequentially placed into the RQ. At the same time, the tail pointer of the RQ also needs to be updated to notify the NVMe device that a new command has arrived. The NVMe device continuously monitors the tail pointer of the RQ. When it finds a new command, it takes out the command from the RQ and executes it. After the execution is completed, the result is placed into the completion queue (CQ). The completion queue is the channel for the NVMe device to return the command execution result to the host, and the host can obtain the command execution result by polling the CQ. This Figure 3 shows the process that the NVMe command is written from the host VFS layer to the NVMe device RQ through memory mapping, and after the NVMe device executes the command, the result is placed into the CQ and fed back to the host.
[0054] S103. Obtain the execution result in the CQ of the target NVMe device and send the execution result to the application program.
[0055] See Figure 4 , which shows the traditional IO process and the improved process of the present invention. In the traditional process, the read and write requests of the application program go through the block layer and then to the NVMe device after passing through the VFS layer; while 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 also avoiding the overhead caused by multiple memory copies in the traditional process. For each memory copy, the CPU needs to issue a control instruction, including the source address, destination address, and length; since the NVMe device itself has efficient data transfer capabilities, in the embodiments of the present invention, without memory copy, there is no need for the CPU to send control instructions, and reducing memory copy can make the performance of the NVMe device be more fully utilized. At the same time, reducing the participation of the CPU in the memory copy process enables the CPU to allocate more resources to handle other tasks, improving the overall performance of the system.
[0056] It can be seen that in the embodiment of the present invention, when an application program 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 (NVMe) specification command, and the NVMe specification command is written into the submission queue of the target NVMe specification device corresponding to the NVMe specification command, so that the target NVMe specification device executes the NVMe specification command and writes the execution result into the completion queue of the target NVMe specification device; the execution result in the completion queue of the target NVMe specification device is obtained and sent to the application program.
[0057] The present invention introduces special processing logic for NVMe specification devices in the virtual file system layer, converts the I / O request into an NVMe specification command, and passes it to the submission queue of the target NVMe specification device. After the NVMe specification device executes the command, the result is placed in the completion queue and fed back to the host. This process bypasses the block layer and also avoids the overhead caused by multiple memory copies in the traditional process, realizes the acceleration of file system data input / output requests, and improves the data input / output performance in the NVMe specification device scenario.
[0058] A possible implementation manner of the embodiment of the present invention is that in the virtual file system layer, converting the data input / output request into an NVMe specification command includes: in the virtual file system layer, determining the request type of the data input / output request; if the request type is a regular request, then in the virtual file system layer, according to the first predefined mapping table, converting the data input / output request into an NVMe specification command; if the request type is a complex request, then in the virtual file system layer, according to the second predefined mapping table, converting the data input / output request into an NVMe specification command.
[0059] To achieve efficient conversion, the predefined first predefined mapping table and second predefined mapping table are adopted. The first predefined mapping table stores the corresponding relationships between common user requests and NVMe commands, and most request conversions can be quickly completed by looking up the first predefined mapping table. For some complex requests, dynamic conversion can be performed using an algorithm in combination with the second predefined mapping table. At the same time, to ensure the correctness and stability of the conversion, strict error handling and verification are also required for the conversion process.
[0060] For regular requests, refer to the first predefined mapping table, as shown in Table 1.
[0061] Table 1 NVMe Protocol Instruction Set
[0062] Among them, partial definitions of the NVMe command opcode: Flush (flush command) corresponds to 0b00000b00b, Write corresponds to 0b00000b01b, and Read corresponds to 0b00000b10b.
[0063] 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 directly handle them and needs to be converted through a dynamic algorithm. This dynamic conversion mechanism needs to precisely parse the request semantics and map them to the corresponding NVMe command set, that is, the second predefined mapping table.
[0064] Furthermore, for complex requests, at the virtual file system layer, according to the second predefined mapping table, the data input / output requests are converted into Non-Volatile Memory Host Controller Interface (NVMe) specification commands, including: at the virtual file system layer, performing semantic parsing on the data input / output requests to obtain special operation identifiers and key parameters; based on the special operation identifiers, key parameters, and the second predefined mapping table, constructing NVMe specification commands; according to the file offset in the key parameters, mapping the file system logical address to the physical address of the target NVMe specification device, and performing data block alignment.
[0065] Specifically, semantic parsing of the data input / output requests: (1) Analyze special operation identifiers (such as O_DIRECT, O_SYNC flags) in the VFS requests; (2) Extract key parameters such as file offset, length, and access mode; (3) Identify special operations of the special operation identifiers (such as atomic write, sparse file processing, etc.). NVMe command construction: (1) Select an appropriate NVMe command type (such as NVM_WRITE, NVM_READ) according to the operation type in the parsing result; (2) Set command-specific fields (such as the FUA flag corresponding to the O_SYNC request). 3. Address conversion: (1) Map the file system logical address to the NVMe physical address; (2) Process data block alignment (which needs to meet the LBA size requirements of the NVMe device).
[0066] It can be seen that in the embodiments of the present invention, in order to achieve efficient conversion, the predefined first predefined mapping table and second predefined mapping table are adopted, which can classify the command conversion and improve the conversion efficiency.
[0067] In a possible implementation manner of the embodiment of the present invention, in the virtual file system layer, after converting a data input / output request into a Non-Volatile Memory Host Controller Interface (NVMe) specification command, the following at least one operation is further included: performing a legality check on the NVMe specification command; determining whether the submission of the NVMe specification command times out, and if it times out, resubmitting the NVMe specification command.
[0068] Specifically, to ensure the correctness and stability of the conversion process, strict error handling and verification need to be implemented in multiple links: 1. Parameter legality check: (1) Check whether the request length meets the device limit; (2) Verify whether the file offset is aligned. Specifically, it is required that the length of the request 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 I / O operation may fail and return an error. When performing an I / O operation, 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 I / O operation may fail or cause data corruption. Therefore, before the I / O operation, calculate whether the file offset is an integer multiple of the block size; if the offset is not aligned, the offset can be adjusted or an error message can be reported to prompt the user.
[0069] 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 to the device block size, continuously check the return value of the memory allocation function to ensure successful memory allocation. 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 flag is returned.
[0070] 3. NVMe command submission and execution verification: (1) Integrity check before command submission; (2) Status code verification based on the Completion Queue (CQ); (3) Timeout handling and retry mechanism.
[0071] Specifically, verify whether each field of the NVMe command conforms to the protocol specification, whether the parameters in the command are within the range supported by the device, and whether the queue and buffer resources required for submitting the command are available. When submitting, use the completion queue to submit, and verify based on the status code of the completion queue whether the command can be successfully retrieved from the completion queue and written into the Request Queue (RQ) of the NVMe device. It may be that the system is overloaded and cannot respond in time. Therefore, start a timer when submitting the command, and trigger a callback after timeout.
[0072] It can be seen that in the embodiments of the present invention, checksumming and verification can be performed, ensuring the correct issuance of commands and improving the reliability of the system.
[0073] In a possible implementation manner of the embodiments of the present invention, in the virtual file system layer, converting a data input / output request into a Non-Volatile Memory Host Controller Interface (NVMe) specification command includes: in the virtual file system layer, determining whether the device corresponding to the request location of the data input / output request is an NVMe specification device; if it is an NVMe specification device, converting the data input / output request into an NVMe specification command. If it is not an NVMe specification device, the request is processed sequentially through the virtual file system layer, the block layer, and the device driver layer.
[0074] In the embodiments of the present invention, when the VFS layer receives a data plane read / write request for an NVMe device, it will first analyze and judge the request. By checking the request location in the IO request, it is determined that the request is for a supported NVMe device. Once it is determined that the request is for an NVMe device, the VFS layer will call a dedicated conversion function to convert the user's read / write request into an NVMe command. If it is not an NVMe device, the request is processed sequentially through the VFS layer, the block layer, and the device driver layer.
[0075] It can be seen that in the embodiments of the present invention, the request is first analyzed and judged. Once it is determined that the request is for an NVMe device, the user's read / write request is converted into an NVMe command.
[0076] In a possible implementation manner of the embodiments of the present invention, before writing the NVMe specification command into the submission queue of the target NVMe specification device corresponding to the NVMe specification command, it further includes: obtaining the physical memory address of the target NVMe specification device; using the memory mapping function provided by the operating system to map the physical memory address to a virtual address in the user space, so as to directly access the submission queue of the target NVMe specification device, facilitating writing the NVMe specification command into the submission queue of the target NVMe specification device corresponding to the NVMe specification command.
[0077] To directly write a command into the submission queue of the target NVMe 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 the user space. Through this method, user programs can directly access the memory areas of hardware devices without data transfer through system calls.
[0078] When performing memory mapping, it is necessary 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 in 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: Obtain 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().
[0079] It can be seen that in the embodiments of the present invention, a mapping relationship is pre-constructed, so that the user program can directly access the memory area of the hardware device without data transmission through system calls.
[0080] A possible implementation manner of the embodiments of the present invention for obtaining the execution result in the completion queue of the target Non-Volatile Memory Host Controller Interface (NVMe) device includes: obtaining the execution result in the completion queue of the target NVMe device through an input-output ring queue mechanism at the virtual file system layer.
[0081] The completion queue is used to represent the queue for the NVMe device to return the command execution result. After the host submits a command to the NVMe device, the NVMe device will write the execution result of the command (including the success or failure status) into the completion queue for the host to read. The execution result refers to the information returned by the NVMe device to the host through the completion queue after the command is completed, including the execution status of the command (such as success, failure), error code (if any), and other relevant data. Example: At the virtual file system layer, when an application initiates a file read / write request, the request will be converted into an NVMe command by the VFS layer and submitted to the RQ of the NVMe device. After the NVMe device executes the command, it writes the result into the completion queue CQ. The VFS layer obtains the execution result from the completion queue and returns it to the application. By obtaining the execution result in a timely manner, the virtual file system layer can discover and process the result of the command in a timely manner, thereby improving the reliability of the system.
[0082] A possible implementation manner of the embodiments of the present invention for obtaining the execution result in the completion queue of the target NVMe device includes: obtaining the execution result in the completion queue of the target NVMe device through the method of event polling notification.
[0083] An event polling notification represents a mechanism that triggers a notification when an event occurs by periodically checking or polling the status of a specific event. An epoll instance is created through epoll_create(), and file descriptors and the events they are interested in (new execution results in the completion queue) are added or removed through epoll_ctl(). epoll_wait() is used to block and wait for IO events, and when an event occurs, a list of ready file descriptors is returned. The corresponding IO events are processed according to the returned list of file descriptors. It can be seen that in the embodiments of the present invention, the event notification is highly efficient and can improve the efficiency of obtaining execution results.
[0084] A possible implementation manner of the embodiments of the present invention is that at the virtual file system layer, the execution results in the completion queue of the target non-volatile memory host controller interface specification device are obtained through an input / output ring buffer mechanism, including: polling the completion queue of the target non-volatile memory host controller interface specification device through the input / output ring buffer mechanism to obtain the execution results of the target non-volatile memory host controller interface specification device and transmitting them to the virtual file system layer.
[0085] In traditional IO operations, the host usually waits for the completion of an IO request in a synchronous or asynchronous manner. The synchronous method causes the host to be blocked during the waiting process and unable to perform other operations, reducing the system's concurrent processing ability; while the asynchronous method can continue to execute other tasks during the waiting process, but it requires handling IO completion events through callback functions or signals, increasing the programming complexity. To solve these problems, the present invention introduces 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, which realizes efficient IO operations through a shared memory ring buffer and zero-copy technology.
[0086] A possible implementation manner of the embodiments of the present invention is that before polling the completion queue of the target non-volatile memory host controller interface specification device through the input / output ring buffer mechanism at the virtual file system layer to obtain the execution results of the target non-volatile memory host controller interface specification device, it further includes: initializing an input / output ring buffer instance to create a submission queue and a completion queue of the input / output ring buffer; associating the input / output ring buffer instance with the respective completion queues of multiple associated non-volatile memory host controller interface specification devices to facilitate monitoring the execution results of the multiple associated non-volatile memory host controller interface specification devices through the input / output ring buffer mechanism; the multiple associated non-volatile memory host controller interface specification devices include at least the target non-volatile memory host controller interface specification device.
[0087] When using the io_uring mechanism, it is first necessary 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 one NVMe device is used currently, then just listen for the results of this NVMe device. The initialization process includes creating the RQ submission queue and CQ completion queue of io itself, setting the size and parameters of the queues, etc. Specifically, the submission queue records the producer (user application) and the consumer (kernel); the completion queue records: the producer (kernel); the consumer (user application). The submission queue records which io requests have been issued and serves as the entry of io_uring; the completion queue stores which io operations have been completed and serves as the exit of io_uring; 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 operations have been issued. For the completion queue, after the NMVe device finishes processing the io, the results are placed in this queue; after the association is completed, io_uring will automatically monitor the changes in CQ.
[0088] When the NVMe device finishes executing a command, it will encapsulate the result into a CompletionEntry and place it in the CQ in order. The io_uring mechanism will detect that there is a new completion entry in the CQ through polling or event notification. Once a new completion entry is detected, io_uring will take it out of the CQ and parse the content of the completion entry to obtain the execution result of the command.
[0089] See Figure 5 , Figure 5 It shows the entire process where 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 feedbacks it to the VFS layer, and finally the VFS layer returns the result to the application.
[0090] A possible implementation of the embodiment of the present invention is to poll 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, 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, it is determined that the execution result of the target non-volatile memory host controller interface specification device is obtained. It can be seen that in the embodiment of the present invention, it is possible to monitor whether there is a new execution result entry in the completion queue of the target non-volatile memory host controller interface specification device, so as to obtain the execution result in time and return it to the host.
[0091] In a possible implementation manner of the embodiment of the present invention, if there is any, parsing the new execution result entry to obtain the current execution result includes: if there is any, when the number of existing new execution result entries reaches a preset number, parsing each new execution result entry to obtain each current execution result; correspondingly, determining whether the current execution result is the execution result corresponding to the data input / output request includes: determining whether there is an execution result corresponding to the data input / output request in each current execution result.
[0092] To improve the efficiency of polling, io_uring adopts a batch processing method. It can process multiple completion entries at once, reducing the number of system calls and improving the processing speed. At the same time, io_uring also supports an asynchronous notification mechanism. When there are new completion entries in the CQ, the host can be notified through event notification, avoiding unnecessary polling overhead. After obtaining the command execution result, io_uring will pass the result to the VFS layer, and the VFS layer will return the result to the application program. During the whole process, the host can continue to execute other tasks while waiting for the IO to complete, improving the system's concurrent processing ability and resource utilization rate.
[0093] In a possible implementation manner of the embodiment of the present invention, before transmitting the data input / output request to the virtual file system layer, it further 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 capable of implementing 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, and the parameters include: the queue depths of the completion queue and the submission queue of the target non-volatile memory host controller interface specification device, and the queue sizes of the submission queue and the completion queue of the input / output ring queue.
[0094] After the request handler is developed, conduct comprehensive testing on the entire system, including functional testing, performance testing, etc. Functional testing mainly verifies whether the system can correctly handle various types of IO requests, such as reading, writing, random access, etc. A series of test cases can be written to simulate different application scenarios, check whether the system's response and output meet the expectations, and verify that the IO read and write effects under the verification version solution are the same as those of the traditional solution, and users are unaware. For example, when writing data to a specified location on an NVMe storage device, it can be successfully written and read again, and the data read is the original written data. Performance testing focuses on the system's IO performance metrics, such as throughput, latency, etc. Professional performance testing tools, such as fio, can be used to conduct stress testing on the system and record performance data under different loads. Optimize according to the test results, adjust parameters, and further improve the system's 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, the code can also be optimized to reduce unnecessary overhead and improve the system's execution efficiency. Through continuous testing and optimization, ensure that the file system IO acceleration solution of the present invention can achieve the best performance in actual applications.
[0095] A possible implementation manner of the embodiment of the present invention is to test the request handler according to each test case to obtain test results, including at least one of the following: perform functional testing on the request handler according to the test cases of functional testing to obtain functional test results; perform performance testing on the request handler according to the test cases of performance benchmark testing to obtain performance test results; perform fault tolerance testing on the request handler according to the test cases of fault tolerance testing to obtain fault tolerance test results.
[0096] For functional testing, design various types of IO requests, such as reading, writing, random access, etc.; furthermore, perform request processing through the request handler to obtain processing results, and compare the processing results with the expected test results to determine the test results. If the execution results of all test cases are consistent with the expected results, it is considered that the functional testing of the request handler passes. If there are execution results of test cases that are inconsistent with the expected results, it is considered that the functional testing of the request handler fails and needs to be optimized. When optimizing and adjusting parameters, it can be adjusted by technicians or automatically according to the results. Exemplarily, when the read and write latency exceeds the standard or the throughput is insufficient, gradually increase / decrease the queue depth of the NVMe device to determine the optimal queue depth; when the IO request is blocked or the memory utilization rate is abnormal, gradually increase / decrease the input / output ring queue size.
[0097] For performance benchmark testing, design test cases covering different load scenarios (such as low load, high load, peak load). Ensure that the test environment is basically consistent with the production environment in terms of hardware and software configurations. Execute the test cases and record performance metrics (such as throughput, latency, resource utilization, etc.). Compare the test results with the expected performance goals to determine whether the request handler passes the performance test. If all performance metrics meet or exceed the expected goals, the performance test is considered passed. If there are performance metrics that do not meet the expected goals, optimization is required. Specifically, if the test results show a performance degradation in high-concurrency scenarios, it may be due to insufficient queue depth of the NVMe device. According to the test results, gradually increase or decrease the queue depth and observe the performance changes. After adjusting the queue depth, conduct a stress test to verify the performance under high concurrency. At the same time, the IO performance not meeting the expectations may be related to the improper setting of the io_uring ring queue size. A too small queue size may cause IO requests to block, while a too large size may waste memory. Similarly, dynamically adjust the queue size according to the IO load, gradually increase or decrease the queue depth, and observe the performance changes. After adjusting the queue depth, conduct a stress test to verify the performance under high concurrency.
[0098] For fault tolerance testing, pre-designed fault tolerance test cases are used to simulate various exceptions and boundary conditions; record the test results, including error handling, system stability, and performance; conduct a comparative analysis of the actual test results and the expected test results; and then adjust the parameters according to the results.
[0099] It can be seen that in the embodiments of the present invention, various types of tests can be performed, so that the finally determined request handler has excellent performance.
[0100] A possible implementation manner of the embodiments of the present invention writes a Non-Volatile Memory Host Controller Interface Specification (NVMe) command into the submission queue of a target NVMe device corresponding to the NVMe command, including: determining whether the actual queue depth of the submission queue of the target NVMe device is less than a preset queue depth; if so, writing the NVMe command into the submission queue of the target NVMe device corresponding to the NVMe command; if not, continuously monitoring the actual queue depth of the submission queue of the target NVMe device until the actual queue depth of the submission queue of the target NVMe device is less than the preset queue depth, and then writing the NVMe command into the submission queue of the target NVMe device corresponding to the NVMe command.
[0101] In an embodiment of the present invention, 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 only when the actual queue depth is less than the preset queue depth, ensuring that the NVMe command is written only when there is enough space in the queue, thereby avoiding overflow errors.
[0102] Based on any of the above embodiments, an embodiment of the present invention provides a specific file system I / O acceleration solution, which can implement a request processing method, including: Step 1: Modify the VFS layer code.
[0103] Adding support for NVMe devices to the VFS layer code in the Linux kernel is the basis for implementing the present invention. As the abstract interface of the file system, the VFS layer needs to identify and process complex requests for NVMe devices.
[0104] First, add identifiers and information related to NVMe devices to the data structure of the VFS layer. A new structure can be created to store specific attributes of NVMe devices, such as the device model, supported NVMe command set, queue depth, etc. During system initialization, the NVMe device is identified through the device detection mechanism, and its related information is filled into the newly created structure. When the VFS layer receives a read / write request from the file system, it is necessary to determine whether the request is for an NVMe device. This can be judged by checking the device information recorded during file system mounting or through the device information associated with the file descriptor. Once it is determined that the request is for a supported NVMe device, a dedicated conversion function needs to be called to convert the request into an NVMe command. The conversion function needs to generate the corresponding NVMe command structure according to the type of the request (such as read, write) and parameters (such as data address, length).
[0105] Step 2: Implement writing the NVMe command into the RQ.
[0106] Write code to implement directly writing the converted NVMe command into the hardware submission queue (RQ) of the NVMe device, which requires the use of memory mapping technology to access the registers and queues of the NVMe device.
[0107] First, it is necessary to obtain the physical memory address of the NVMe device through the interface provided by the operating system. In the Linux kernel, the pci_iomap function can be used to map the configuration space and queue memory of the NVMe device. When the NVMe device is inserted into the server and recognized by the operating system (initialized), it is mapped once. After the mapping is completed, the registers and queues of the NVMe device can be accessed just like ordinary memory. When writing NVMe commands, it is necessary to follow the format and order specified by the NVMe protocol. Each NVMe command has a fixed length and structure, and the various fields of the command (such as the opcode, data address, length, etc.) need to be filled into the corresponding positions.
[0108] Step 3: Integrate the io_uring mechanism.
[0109] Integrate the io_uring mechanism at the VFS layer and use the interface of io_uring to poll the completion queue (CQ) of the NVMe device.
[0110] First, it is necessary to initialize an io_uring instance. In the Linux kernel, the io_uring_queue_init function can be used to create an io_uring context and set the size and parameters of the queue. Associate the io_uring instance with the completion queue of the NVMe device. By setting the file descriptor and event mask of io_uring, io_uring can be made to listen for 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 use the io_uring_cqe_get_data function to obtain the data of the completion entry.
[0111] Step 4: Test and optimize.
[0112] After the development is completed, conduct a comprehensive test on the entire system, including functional tests, performance tests, etc.
[0113] 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 according to the test results to further improve the performance and stability of the system. For example, the queue depth of the NVMe device, the queue size of io_uring and other parameters can be adjusted to find the best 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 play the best performance in practical applications.
[0114] The present invention provides a file system IO acceleration solution, which directly converts part of the IO requests into NVMe commands at the VFS layer, bypasses the block layer, and shortens the IO path; directly writes the NVMe commands into the hardware RQ / CQ, reducing the scheduling and processing overhead at the software level; and references the io_uring mechanism to poll the request results to improve the concurrent processing capability of the system. Compared with the existing solutions, the file system IO acceleration solution of the present invention shortens the IO stack, reduces unnecessary intermediate processing links, and significantly improves the IO performance in the NVMe device scenario. It is specifically reflected in the following aspects: (1) Reducing 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) Reducing memory copy loss: Opening up the data link from the VFS layer to the NVMe device greatly reduces the memory copy loss between user mode and kernel mode; (3) Improving 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) Fully utilizing the performance of NVMe devices: Optimizing according to the characteristics of NVMe devices, avoiding the limitations of traditional IO stacks on NVMe device performance, and fully utilizing the high performance advantages of NVMe devices.
[0115] 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 referred to in correspondence with each other. Figure 6 , Figure 6It is a structural block diagram of a device according to an embodiment of the present invention, including: a request transmission module 210, configured to transmit the data input / output request to the virtual file system layer when an application program 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 in the virtual file system layer, 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 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 program.
[0116] In a preferred example, the present invention can be further configured as follows: The command conversion module 220 is configured to: determine a request type of the data input / output request in the virtual file system layer; if the request type is a regular request, convert the data input / output request into a non-volatile memory host controller interface specification command according to a first predefined mapping table in the virtual file system layer; if the request type is a complex request, convert the data input / output request into a non-volatile memory host controller interface specification command according to a second predefined mapping table in the virtual file system layer.
[0117] In a preferred example, the present invention can be further configured as follows: The command conversion module 220 is configured to: perform semantic parsing on the data input / output request in the virtual file system layer to obtain a special operation identifier and key parameters; construct a non-volatile memory host controller interface specification command based on the special operation identifier, the key parameters, and the second predefined mapping table; map a file system logical address to a physical address of a target non-volatile memory host controller interface specification device according to a file offset in the key parameters, and perform data block alignment.
[0118] In a preferred example, the present invention can be further configured as follows: The command conversion module 220 is further configured to: perform a legality check on the non-volatile memory host controller interface specification command; determine whether submission of the non-volatile memory host controller interface specification command times out, and if so, resubmit the non-volatile memory host controller interface specification command.
[0119] In a preferred example, the present invention can be further configured as follows: a command conversion module 220, which is used to: at the virtual file system layer, determine 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.
[0120] In a preferred example, the present invention can be further configured as follows: the command conversion module 220 is further used to: if it is not a non-volatile memory host controller interface specification device, sequentially perform request processing through the virtual file system layer, the block layer, and the device driver layer.
[0121] In a preferred example, the present invention can be further configured as follows: further 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 in the user space, so as to directly access the submission queue of the target non-volatile memory host controller interface specification device, 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.
[0122] In a preferred example, the present invention can be further configured as follows: a result return module 230, which is used to: at the virtual file system layer, obtain the execution result in the completion queue of the target non-volatile memory host controller interface specification device through the input / output ring queue mechanism; obtain the execution result in the completion queue of the target non-volatile memory host controller interface specification device through the event polling notification method.
[0123] In a preferred example, the present invention can be further configured as follows: the result return module 230 is used to poll the completion queue of the target non-volatile memory host controller interface specification device through the input / 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.
[0124] In a preferred example, the present invention can be further configured to further include: an association module, which is used to initialize an input / output circular queue instance to create a submission queue and a completion queue of the input / output circular queue; associate the input / output circular queue instance with the completion queues of multiple associated non-volatile memory host controller interface specification devices respectively, so as to monitor the execution results of the multiple associated non-volatile memory host controller interface specification devices through the input / output circular 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.
[0125] In a preferred example, the present invention can be further configured to: a result return module 230, which 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 the input / output circular queue mechanism; if so, parse the new execution result entry to obtain the current execution result, and determine whether the current execution result is the execution result corresponding to the data input / output request, and if so, determine that the execution result of the target non-volatile memory host controller interface specification device is obtained.
[0126] In a preferred example, the present invention can be further configured to: a result return module 230, which is used to, if so, when the number of existing new execution result entries reaches a preset number, parse each of the new execution result entries to obtain each current execution result; the result return module 230 is used to determine whether there is an execution result corresponding to the data input / output request among each of the current execution results.
[0127] In a preferred example, the present invention can be further configured to further include: a test module, which is used to obtain a variety of test cases; test 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 handling method; if the test result does not meet the expected test result, optimize the parameters of the request handler according to the test result, and the parameters include: the queue depths of the completion queue and the submission queue of the target non-volatile memory host controller interface specification device, and the queue sizes of the submission queue and the completion queue of the input / output circular queue.
[0128] In a preferred example, the present invention can be further configured to: the test module is used to: perform a functional test on the request handler according to the test cases of the functional test to obtain a functional test result; perform a performance test on the request handler according to the test cases of the performance benchmark test to obtain a performance test result; perform a fault tolerance test on the request handler according to the test cases of the fault tolerance test to obtain a fault tolerance test result.
[0129] In a preferred example, the present invention can be further configured as follows: The 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 the 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.
[0130] Figure 6 For the description of the features in the corresponding embodiments, reference can be made to Figure 2 the relevant descriptions of the corresponding embodiments, which will not be elaborated here one by one.
[0131] Figure 7 The structural diagram of an electronic device provided by an embodiment of the present invention is shown in Figure 7 As shown, the electronic device includes: a memory 60 for storing a computer program; a processor 61 for implementing the steps of the request processing method in the above embodiment when executing the computer program. Among them, the processor 61 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 61 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and 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 wake state, also known as the 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), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 61 may further include an artificial intelligence (AI) processor, and the AI processor is used to process computational operations related to machine learning.
[0132] The memory 60 may include one or more computer-readable storage media, which may be non-transitory. The memory 60 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash storage devices. In this embodiment, the memory 60 is at least used to store the following computer program 601. 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 foregoing 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 transient storage or permanent storage. Among them, the operating system 602 may include Windows, Unix, Linux, etc.
[0133] 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.
[0134] Those skilled in the art can understand that Figure 7 the structure shown in does not constitute a limitation on the electronic device, and it may include more or fewer components than those shown in the figure.
[0135] It can be understood that if the request processing method in the above embodiments is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the current technology, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and executes all or part of the steps of the methods of the various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, magnetic disks, or optical disks that can store program codes.
[0136] Based on this, the embodiments of the present invention further provide a request processing system, including: an electronic device and a target non-volatile memory host controller interface specification device.
[0137] Based on this, the embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the method as described above.
[0138] Based on this, an embodiment of the present invention further provides a computer program product, including computer programs / instructions, which when executed by a processor implement the steps of the above method.
[0139] The above has introduced in detail a request processing method, apparatus, device, system, medium, and product provided by an embodiment of the present invention. Each embodiment in the specification is described in a progressive manner, and the key point of each embodiment is the difference from other embodiments. For the same or similar parts among the 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, and reference can be made to the description of the method part for related parts.
[0140] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this article can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described according to their functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0141] The above has introduced in detail a request processing method, apparatus, device, system, medium, and product provided by the present invention. Specific examples are used in this article to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention. It should be noted that for those of ordinary skill in the art in this technical field, without departing from the principle of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the protection scope of the present invention.
Claims
1. A request processing method, characterized in that, Including: 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 (NVMe) specification command, writing the NVMe specification command into a submission queue of a target NVMe specification device corresponding to the NVMe specification command, so that the target NVMe specification device executes the NVMe specification command, and writing an execution result into a completion queue of the target NVMe specification device; Obtaining the execution result in the completion queue of the target NVMe specification device, and sending the execution result to the application.
2. The request processing method according to claim 1, wherein In the virtual file system layer, converting the data input / output request into an NVMe specification command includes: In the virtual file system layer, determining a request type of the data input / output request; If the request type is a regular request, then in the virtual file system layer, converting the data input / output request into an NVMe specification command according to a first predefined mapping table; If the request type is a complex request, then in the virtual file system layer, converting the data input / output request into an NVMe specification command according to a second predefined mapping table.
3. The request processing method according to claim 2, wherein In the virtual file system layer, converting the data input / output request into an NVMe specification command according to the second predefined mapping table includes: In the virtual file system layer, performing semantic parsing on the data input / output request to obtain a special operation identifier and key parameters; Based on the special operation identifier, key parameters, and the second predefined mapping table, constructing an NVMe specification command; According to a file offset in the key parameters, mapping a file system logical address to a physical address of a target NVMe specification device, and performing data block alignment.
4. The request processing method according to claim 2, wherein After converting the data input / output request into an NVMe specification command in the virtual file system layer, the following at least one is further included: Performing a legality check on the NVMe specification command; Determining whether submission of the NVMe specification command times out, and if it times out, resubmitting the NVMe specification command.
5. The request processing method according to claim 1, characterized in that In the virtual file system layer, converting the data input / output request into an NVMe specification command includes: In the virtual file system layer, determining whether a device corresponding to a request location of the data input / output request is an NVMe specification device; If it is an NVMe specification device, then converting the data input / output request into an NVMe specification command.
6. The request processing method according to claim 5, characterized in that It also includes: If it is not a Non-Volatile Memory Host Controller Interface Specification device, the request is processed sequentially through the virtual file system layer, the block layer, and the device driver layer.
7. The request processing method according to claim 1, characterized in that 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 a virtual address in the user space, so as to directly access the submission queue of the target Non-Volatile Memory Host Controller Interface Specification device, 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.
8. The request processing method according to claim 1, characterized in that Obtaining the execution result in the completion queue of the target Non-Volatile Memory Host Controller Interface Specification device includes: In 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 the input / output ring buffer mechanism; And / or Obtaining the execution result in the completion queue of the target Non-Volatile Memory Host Controller Interface Specification device by means of event polling notification.
9. The request processing method according to claim 8, wherein In 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 the input / output ring buffer mechanism includes: Polling the completion queue of the target Non-Volatile Memory Host Controller Interface Specification device through the input / output ring buffer mechanism to obtain the execution result of the target Non-Volatile Memory Host Controller Interface Specification device and transmitting it to the virtual file system layer.
10. The request processing method according to claim 9, wherein Before polling the completion queue of the target Non-Volatile Memory Host Controller Interface Specification device through the input / output ring buffer mechanism to obtain the execution result of the target Non-Volatile Memory Host Controller Interface Specification device in the virtual file system layer, it also includes: Initializing an input / output ring buffer instance to create a submission queue and a completion queue of the input / output ring buffer; Associating the input / output ring buffer instance with the completion queues of multiple associated Non-Volatile Memory Host Controller Interface Specification devices respectively, so as to facilitate monitoring the execution results of multiple associated Non-Volatile Memory Host Controller Interface Specification devices through the input / output ring buffer 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.
11. The request processing method according to claim 9, characterized in that Polling the completion queue of the target Non-Volatile Memory Host Controller Interface Specification device through the input / output ring buffer mechanism to obtain the execution result of the target Non-Volatile Memory Host Controller Interface Specification device includes: 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 buffer mechanism; If it exists, parse the new execution result entry to obtain the current execution result, and determine whether the current execution result is the execution result corresponding to the data input / output request. If so, determine that the execution result of the target non-volatile memory host controller interface specification device is obtained.
12. The request processing method according to claim 11, wherein If it exists, parse 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, parse each of the new execution result entries to obtain each current execution result; Correspondingly, determining whether the current execution result is the execution result corresponding to the data input / output request includes: Determine whether there is an execution result corresponding to the data input / output request among the current execution results.
13. The request processing method according to any one of claims 9-12, characterized in that Before transmitting the data input / output request to the virtual file system layer, it further includes: Obtain multiple test cases; Test the request handler according to each test case to obtain a test result; the request handler is a pre-set program capable of implementing the request processing method; If the test result does not meet the expected test result, optimize the parameters of the request handler according to the test result. The parameters include: the queue depths of the completion queue and the submission queue of the target non-volatile memory host controller interface specification device, and the queue sizes of the submission queue and the completion queue of the input / output ring queue.
14. The request processing method according to claim 13, characterized in that, Testing the request handler according to each test case to obtain a test result includes at least one of the following: Perform a functional test on the request handler according to the test case of the functional test to obtain a functional test result; Perform a performance test on the request handler according to the test case of the performance benchmark test to obtain a performance test result; Perform a fault tolerance test on the request handler according to the test case of the fault tolerance test to obtain a fault tolerance test result.
15. The request processing method according to any one of claims 1-12, characterized in that, 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 includes: Determine whether 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; 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.
16. A request processing device, characterized in that, It includes: A request transmission module, configured to transmit the data input / output request to the virtual file system layer when an application program sends a data input / output request; A command conversion module, configured to convert the data input / output request into a Non-Volatile Memory Host Controller Interface (NVMe) specification command at the virtual file system layer, write the NVMe specification command into a submission queue of a target NVMe specification device corresponding to the NVMe specification command, so that the target NVMe specification device executes the NVMe specification command, and write an execution result into a completion queue of the target NVMe specification device; A result return module, configured to obtain the execution result in the completion queue of the target NVMe specification device and send the execution result to the application program.
17. An electronic device, characterized in that, Comprising: A memory, configured to store a computer program; 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 15.
18. A request processing system, characterized in that, Comprising: The electronic device and the target NVMe specification device according to claim 17.
19. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, 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 15 are implemented.
20. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, the steps of the request processing method according to any one of claims 1 to 15 are implemented.
Citation Information
Patent Citations
Method for improving handling capacity performance of solid-state disk
CN107479828A
Business instruction processing method and device, computer equipment and storage medium
CN110351342A
Storage device and queue management method thereof
CN110365604A
Data processing method and device, electronic device and medium
CN114238358A
Data read-write method, storage device and storage medium
CN115576863A
Cited By
Communication transmission method, product, electronic equipment and medium
CN120848811A