Method, device and equipment for accessing file system disk

By extending the Page Cache framework in the kernel layer, establishing the address mapping of buffer blocks, and realizing direct data copying of NVMe SSD disks, solving the problems of low transmission efficiency and high resource consumption during data writing, improving data transmission efficiency and reducing the burden on CPU and RAM.

CN117009258BActive Publication Date: 2025-08-22BEIJING YOUZHUJU NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310987553.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-07
Publication Date
2025-08-22
Estimated Expiration
2043-08-07

AI Technical Summary

Technical Problem

In the prior art, when writing data to an NVMe SSD disk through a file system, two data copies are required, resulting in low transmission efficiency and increasing CPU and RAM consumption.

Method used

Add a page cache expansion module and a page cache management module in the kernel layer to extend the Page Cache framework, establish a physical address and virtual address mapping of the hardware layer buffer blocks, and register the storage medium as Page Cache to realize direct data copying and avoid secondary copying.

Benefits of technology

Improves data transmission efficiency and reduces CPU and RAM consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117009258B_ABST
    Figure CN117009258B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method, apparatus, and device for accessing a file system disk, which is applied to the kernel layer. The method includes: when a VFS module performs a disk data write operation through a first interface, a page cache management module obtains a first buffer block in the storage medium of the hardware layer disk, where the first buffer block is a free block. The page cache management module detects whether the physical address on the first buffer block has completed spatial address mapping; if not, a page cache expansion module is used to allocate a virtual address to it and establish a spatial mapping relationship between the virtual address and the physical address; the first buffer block is converted into a first page cache, and the spatial mapping relationship and virtual address are sent to the VFS module through the page cache expansion module. The VFS module adds the first page cache to an internal data structure and copies the data to the first page cache. This method reduces one data copy, thereby improving the efficiency of the entire transmission process and reducing the consumption of the host-side CPU and RAM.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of storage, and in particular to a method, apparatus, and device for accessing a file system disk. Background Art

[0002] With the rapid development of storage technology, solid-state drives (SSDs) based on NVMe (Nonvolatile Memory Express) technology are increasingly being used in enterprise data center storage. However, most applications access data on NVMe SSDs through file systems (such as ext4 and xfs), making efficient file system access to NVMe SSDs crucial.

[0003] Currently, the entire process of an application writing data to an NVMe SSD disk through the file system involves two data copies: one is to copy the data from the user-state application to the kernel state, and the other is to copy the data from the kernel state to the data storage medium of the NVMe controller. The two data copy processes will lead to low overall transmission efficiency and increase the consumption of the host-side CPU and random access memory (RAM). Summary of the Invention

[0004] In view of this, the present disclosure provides a method for accessing a file system disk to improve data copy transmission efficiency and reduce CPU and RAM consumption.

[0005] In a first aspect, the present disclosure provides a method for accessing a file system disk. The method is applied to a kernel layer, wherein the kernel layer includes a page cache expansion module and a page cache management module. The page cache expansion module is connected to a virtual file system (VFS) module and a driver module via at least one interface. The driver module is connected to a hardware layer, and the page cache management module is located within the driver module. The method includes:

[0006] When the VFS module performs a disk data write operation through the first interface, the page cache management module obtains a first buffer block in the storage medium of the hardware layer disk, the first buffer block being a free block, and the first interface being one of the at least one interface;

[0007] The page cache management module detects whether the physical address on the first buffer block completes space address mapping;

[0008] If not completed, using the page cache expansion module to allocate a virtual address for it, and establish a space mapping relationship between the virtual address and the physical address;

[0009] The page cache management module converts the first buffer block into a first page cache, and sends the space mapping relationship and the virtual address to the VFS module through the page cache expansion module. The first page cache is used to enable the VFS module to add and copy data.

[0010] In a second aspect, an embodiment of the present disclosure further provides a method for accessing a file system disk, the method being applied to a virtual file system VFS module, the VFS module being located in a kernel layer, the method comprising:

[0011] When receiving a disk data write operation from the user layer, the VFS module queries whether a file data block corresponding to the data to be written exists in a first page cache, where the first page cache is generated by converting a first buffer block in the storage medium of the hardware layer disk, and the first buffer block is a free block;

[0012] If yes, the VFS module adds the first page cache to an internal data structure and copies the data to the first page cache.

[0013] In a third aspect, an embodiment of the present disclosure provides a device for accessing a file system disk, the device comprising:

[0014] an acquisition module, configured to acquire a first buffer block in a storage medium of a hardware layer disk when a virtual file system (VFS) module performs a disk data write operation through a first interface, wherein the first buffer block is a free block, and the first interface is one of at least one interface of a page cache extension module;

[0015] A detection module, configured to detect whether the physical address on the first buffer block has completed space address mapping;

[0016] a processing module configured to, when detecting incompleteness, establish a space mapping relationship between the virtual address and the physical address using the virtual address allocated by the page cache expansion module, and convert the first buffer block into a first page cache;

[0017] The sending module is used to send the space mapping relationship and the virtual address to the VFS module through the page cache expansion module, and the first page cache is used to enable the VFS module to add and copy data.

[0018] In a fourth aspect, an embodiment of the present disclosure further provides a device for accessing a file system disk, the device comprising:

[0019] a query module configured to, upon receiving a disk data write operation from a user layer, query whether a file data block corresponding to the to-be-written data exists in a first page cache, where the first page cache is generated by converting a first buffer block in a storage medium of a hardware layer disk, where the first buffer block is a free block;

[0020] The copy module is configured to add the first page cache to an internal data structure and copy data to the first page cache.

[0021] In a fifth aspect, the present disclosure provides an electronic device comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, computer instructions being stored in the memory, and the processor executing the file system disk access method of the above-mentioned first aspect or any corresponding embodiment thereof by executing the computer instructions.

[0022] In addition, the present disclosure provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the file system disk access method of the first aspect or any corresponding embodiment thereof.

[0023] The disclosed embodiments provide a method, apparatus, and device for accessing a file system disk. These methods add a page cache expansion module and a page cache management module to the kernel layer, expanding the kernel layer's existing Page Cache framework. This allows for reuse of much of the kernel's built-in cache management mechanism, making it imperceptible to the user. Furthermore, the page cache management module establishes a mapping between the physical and virtual addresses of buffer blocks in the hardware layer, thereby registering the hardware layer's storage medium as PageCache. This enables direct data copying on the storage medium, avoiding a secondary data copy. This method reduces one data copy, improves data transmission efficiency, and reduces CPU and RAM consumption. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the specific embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0025] Figure 1 This is a structural diagram of a Linux file I / O system provided by an embodiment of the present disclosure;

[0026] Figure 2 This is a schematic diagram of a process for writing data to an NVMe SSD disk provided by an embodiment of the present disclosure;

[0027] Figure 3 This is a schematic diagram of another process of writing data to an NVMe SSD disk provided by an embodiment of the present disclosure;

[0028] Figure 4 This is a structural diagram of a page cache expansion module provided by an embodiment of the present disclosure;

[0029] Figure 5 This is a flowchart of a method for accessing a file system disk provided by an embodiment of the present disclosure;

[0030] Figure 6 This is a flowchart of releasing a CMB address space provided by an embodiment of the present disclosure;

[0031] Figure 7 is a flowchart of another method for accessing a file system disk provided by an embodiment of the present disclosure;

[0032] Figure 8 This is a structural block diagram of a file system disk access device provided by an embodiment of the present disclosure;

[0033] Figure 9 This is a structural block diagram of a VFS module provided by an embodiment of the present disclosure;

[0034] Figure 10 is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present disclosure; DETAILED DESCRIPTION

[0035] In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in combination with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments.

[0036] First, the technical fields and professional terms involved in the present disclosure are introduced.

[0037] This application applies to the field of storage technology, particularly data storage based on NVMe SSDs. NVMe (Nonvolatile Memory Express) is a communication protocol that runs on a certain interface and is used to standardize data transmission between computers and storage devices. NVMe is used to connect the host and the memory subsystem. NVMe is specifically designed for non-volatile storage such as NAND and flash memory, and the NVMe protocol is built on high-speed PCIe channels.

[0038] See also Figure 1, a schematic diagram of a Linux file I / O system provided in this embodiment, including an application layer, a kernel layer, and a hardware layer. The user layer includes at least one application. The kernel layer includes a VFS (Virtual File System) module, a Page Cache, a block I / O module, and a device driver.

[0039] Among them, Page Cache (abbreviated as Pcache, page cache memory) can be understood as a memory area managed by the Linux kernel. Files can be read into the memory space through mmap and buffered I / O, generally into the Page Cache. In addition, Page Cache is used to cache the page data of files, and buffer cache is used to cache the block data of block devices (such as disks). Page is a logical concept, so Page Cache is at the same level as the file system; block is a physical concept, so buffer cache is at the same level as the block device driver. The size of Page Cache is one page, usually 4K. When reading and writing files in Linux, it is used to cache the logical content of the file, thereby speeding up access to images and data on the disk.

[0040] Among them, mmap is a method of memory mapping files, that is, mapping a file or other object to the address space of a process, realizing a one-to-one mapping relationship between the file disk address and a virtual address in the process virtual address space.

[0041] The Linux kernel can be further divided into three layers. The top layer is the system call interface, which implements basic functions such as read and write. Below the system call interface is the kernel code, which can be more precisely defined as architecture-independent kernel code. This code is common to all processor architectures supported by Linux. Below this code is the architecture-dependent code, which constitutes what is commonly called the BSP (Board Support Package). This code is processor- and platform-specific for a given architecture.

[0042] When writing data to the NVMe SSD disk at the user layer, Figure 2As shown in the figure, two data copies are involved: one is from the user-mode application to the kernel-mode Page Cache (provided by the host RAM), and the other is from the kernel-mode Page Cache to the NVMe controller's data solid-state drive (SSD) via direct memory access (DMA). For the entire data transfer process described above, the two copies of data affect the overall transmission efficiency and increase CPU and RAM consumption on the host side.

[0043] In order to solve the above problems, this paper proposes an optimization solution based on the NVMe CMB (Controller Memory Buffer) feature. Figure 3 As shown in the figure, by extending the Linux kernel's Page Cache management framework, the NVMe driver can register device memory such as CMB as Page Cache and perform customized management to avoid secondary copying of data, thereby improving the efficiency of the entire transmission process and reducing the consumption of host-side CPU and RAM.

[0044] See also Figure 4 , is a schematic diagram of a file system provided in an embodiment of the present application. The system includes: a user layer, a kernel layer, and a hardware layer. The user layer includes at least one user app; the kernel layer (the core code of the Linux kernel) includes: a virtual file system (VFS) module, a page cache expansion module, and a device driver (Device Driver). The hardware layer includes SSD and NVMe storage media.

[0045] In the embodiment of the present application, a page cache extension module (Page Cache Extension module) and a page cache management module (Page Cache Management module) are newly added to the original kernel layer.

[0046] Among them, the page cache extension module is used to provide the Page Cache extension interface, such as Figure 4 As shown, a first interface and a second interface of the page cache are provided. The first interface and the second interface of the page cache are used to connect the VFS module and the device driver. It should be understood that the page cache expansion module may also include a third interface, a fourth interface, and other interfaces, which are not limited in this embodiment.

[0047] A new page cache management module is added to the device driver (Device Driver), which uses the extended interfaces (first interface and second interface) provided by the Page Cache extension module to implement Page Cache lifecycle management based on NVMe CMB.

[0048] In this embodiment, Figure 4 Based on the structural framework shown in the figure, a method for accessing the file system disk is provided, such as Figure 5 As shown, the method includes:

[0049] Step S101: When the VFS module performs a disk data write operation through a first interface, the page cache management module obtains a first buffer block in a storage medium of a hardware layer disk, where the first buffer block is a free block.

[0050] Specifically, the application app sends a data write request to the kernel layer. After receiving the write request, the VFS module calls the first interface of the page cache to execute the data write request operation on the lower layer.

[0051] In addition, the first interface is one of multiple interfaces established by the page cache extension module, such as a page cache allocation interface (Page Cache Allocation).

[0052] The storage medium is a solid state drive (SSD), and the SSD can be pre-divided into multiple cache resources. The first buffer block is a storage resource in the SSD, such as Figure 4 As shown, the first buffer block is the CMB buffer. It should be understood that the SSD may also include a second buffer block, a third buffer block, etc. The page cache and the page cache management module are located in the kernel layer above the SSD.

[0053] Step S102: the page cache management module detects whether the physical address on the first buffer block has completed the space address mapping.

[0054] Each buffer block corresponds to a physical address, and each physical address must establish a spatial mapping relationship with a virtual address. The function of this step is to determine whether a physical address on a current buffer block establishes a spatial mapping relationship with a virtual address.

[0055] Specifically, the first judgment method is to judge whether there is a page table entry from the virtual address to the physical address. If so, it means that the space address mapping is completed; if not, it means that the mapping is not completed.

[0056] Judgment method 2: The kernel maintains a data structure describing each NVMe device. A flag is added to this data structure to indicate whether the space address mapping is complete. For example, during initialization, the flag is set to 0. Once the page table mapping is complete, the corresponding flag is set to 1. The kernel then determines whether the space address mapping is complete by checking whether the flag is 0 or 1.

[0057] Step S103: If it is not completed, a virtual address is allocated to it by using a page cache expansion module, and a space mapping relationship between the virtual address and the physical address is established.

[0058] Specifically, the mapping relationship between the virtual address and the physical address is established. For example, reference may be made to the existing method steps for establishing the mapping relationship between the virtual address and the physical address, which is not limited in this embodiment.

[0059] Step S104: the page cache management module converts the first buffer block into a first page cache.

[0060] After the mapping relationship is established, the page cache management module converts the first buffer block (such as CMB buffer) into the first page cache (Page Cache 1), which is equivalent to registering a buffer block in the hardware layer as a PageCache to which the application layer can write data.

[0061] Step S105: the page cache management module sends the space mapping relationship and the virtual address to the VFS module through the page cache expansion module.

[0062] After receiving the space mapping relationship and the virtual address sent by the page cache expansion module, the VFS module adds the first page cache to the internal data structure and copies the data directly to the first page cache.

[0063] The above step S102 also includes, if yes, returning the virtual address to the VFS module, and the VFS module receives and executes an operation of copying the execution data to the first cache page.

[0064] Optionally, the page cache management module can be an NVMe CMB Cache module that implements NVMe CMB Page Cache lifecycle management based on the Page Cache extension interface, that is, the page cache management module is used to manage the NVMe driver. The Page Cache extension module mainly provides two interfaces: Page Cache Allocation (allocation interface) and Page Cache Deallocation (deallocation interface), namely the first interface and the second interface mentioned above.

[0065] Optionally, in a specific implementation of this embodiment, the above step S101 specifically includes: the page cache management module obtains the first cache block from the SSD in the controller based on a lock-free mechanism.

[0066] The lock-free mechanism is a lock-free Bitmap algorithm, which uses a bit to mark the value corresponding to an element, and the key is the element. Since data is stored in bits, storage space can be greatly saved.

[0067] It should be noted that in this embodiment, the buffer block and cache are different. The buffer block is a resource block in the storage medium SSD, such as the first buffer block CMB buffer. The storage medium SSD may include one or more buffer blocks, while the "cache" mainly refers to the page cache (page cache), such as the first page cache. The relationship between the two is that the first buffer block CMBbuffer is registered as the first page cache after conversion (step S104 above), thereby enabling data to be written directly to the first page cache. In addition, in some embodiments, the area composed of multiple buffer blocks of the storage medium SSD can also be called a buffer zone.

[0068] Furthermore, after the above step S102, the process further includes: if the space address mapping is completed, sending the space address mapping relationship and the virtual address to the VFS module through the page cache expansion module. For example, the virtual address is returned to the VFS module, and the VFS module performs a data write operation after receiving the virtual address.

[0069] Optionally, in a specific implementation of this embodiment, the page cache expansion module further includes a second interface of the page cache, for example, the second interface is a release interface, and the second interface is connected to the VFS module and the driver module.

[0070] like Figure 6 As shown, the above method further includes: the page cache management module obtaining a first physical address, a first mapping relationship existing between the first physical address and the first virtual address. The page cache management module detects whether the first physical address is the address of a buffer block in the storage medium; if so, it indicates that the buffer block has completed spatial address mapping and is registered as a page cache. At this time, based on the lock-free bitmap mechanism, the buffer block corresponding to the first physical address is released, the first mapping relationship is unbound, and a first message is sent to the VFS module.

[0071] The first message is used to instruct the VFS module to write back and release the page cache corresponding to the first virtual address. For example, the page cache management module determines whether the address belongs to the CMB address space. If so, the CMB buffer (i.e., the first buffer block) is released based on the lock-free bitmap mechanism. If not, that is, it does not belong to the CMB address space, it means that the address is not a buffer block in the SSD hardware disk, so the memory resources are released in the usual way, that is, through the buddy system.

[0072] The method provided in this embodiment, after data writing is completed, releases the CMB address space, that is, the first buffer block corresponding to the first page cache, to achieve CMB buffer block reuse, thereby achieving the beneficial effect of reclaiming the virtual address and the first buffer block CMBbuffer.

[0073] In another embodiment, the present disclosure further provides a method for accessing a file system disk, which is applied to the VFS module in the aforementioned kernel layer, and includes:

[0074] Step 1: When the VFS module receives a disk data write operation from the user layer, it queries whether there is a first page cache for the file data block corresponding to the data to be written. The first page cache is generated by converting the first buffer block in the hardware layer disk SSD. The first buffer block is an idle resource block in the SSD.

[0075] Step 2: If it exists, the VFS module adds the first page cache to the internal data structure and copies the data to the first page cache.

[0076] Specifically, copying the data to the first page cache includes: VFS obtaining a first virtual address, and there is a spatial address mapping relationship between the first virtual address and the first physical address; the VFS module copies the data to the first page cache according to the first virtual address, and the first virtual address is a virtual address allocated by the first interface in the page cache extension module.

[0077] If the first page cache does not exist, the VFS module first copies the data to the second page cache of the kernel layer, and then copies the data to the buffer block in the SSD through the second page cache. The second page cache is the page cache in the RAM.

[0078] Furthermore, the above method also includes releasing port resources and memory resources.

[0079] In one embodiment, the method includes: the VFS module receives a first message sent by the page cache management module; the first message is used to indicate the release of interface resources, the VFS module writes back the data, and releases the first page cache by calling a second interface, and the second interface is one of at least one interface in the page cache extension module.

[0080] In a specific embodiment, if Figure 7 As shown, the method for accessing the file system disk includes:

[0081] Step 1: The user App layer writes a file through the write system call;

[0082] Step 2: The VFS module queries the corresponding file data block and releases the existing page cache;

[0083] Step 3: If not, the page cache extension module determines whether there is a registered memory allocation and release interface;

[0084] Step 4: If yes, the VFS module calls the memory allocation interface provided by the Page Cache extension module to allocate Page Cache;

[0085] Step 5: The VFS module converts the requested memory into corresponding pages and virtual addresses and returns them to the VFS module.

[0086] Step 6: The VFS module adds the Page Cache to the data structure it maintains (such as a linked list or radix tree) for recording.

[0087] Step 7: The VFS module copies the data to the Page Cache, thereby copying the data to the NVMe SSD in one go.

[0088] In addition, the above step 2 further includes: if it does not exist, the VFS module first copies the data to the kernel state page cache, and then copies the data to the SSD in the controller for the second time through the kernel state page cache.

[0089] Finally, when the Page Cache allocated based on the CMB buffer needs to be flushed to the disk, the NVMe driver will fill in the physical address corresponding to its memory space into the SQE. The NVMe controller will identify whether the physical address belongs to the CMB area. If it does, DMA copy will not be performed. At this time, the NVMe controller directly writes the data in the CMB buffer to the SSD disk.

[0090] This embodiment extends the Linux kernel's Page Cache management framework so that the NVMe driver can register device memory such as CMB as Page Cache and perform customized management, thereby achieving direct data copying on the Page Cache. The above-mentioned secondary data copy is no longer needed, thereby improving the efficiency of the entire transmission process and reducing the consumption of the host-side CPU and RAM.

[0091] This embodiment also provides a device for accessing a file system disk. This device is used to implement the above-mentioned embodiments and preferred implementations, and details already described will not be repeated. As used below, the term "module" may refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.

[0092] This embodiment provides a file system disk access device, such as Figure 8 As shown, the device includes:

[0093] The acquisition module 801 is used to obtain a first buffer block in the storage medium of the hardware layer disk when the VFS module performs a disk data write operation through the first interface. The first buffer block is a free block, and the first interface is one of at least one interface of the page cache extension module.

[0094] The detection module 802 is used to detect whether the physical address on the first buffer block completes the space address mapping.

[0095] The processing module 803 is used to establish a space mapping relationship between the virtual address and the physical address using the virtual address allocated by the page cache expansion module when detecting incomplete space address mapping, and convert the first buffer block into a first page cache.

[0096] The sending module 804 is configured to send the space mapping relationship and the virtual address to the VFS module through the page cache expansion module. The first page cache is configured to enable the VFS module to add and copy data.

[0097] The VFS module adds the first page cache to an internal data structure and copies data to the first page cache.

[0098] In addition, the above modules are also used to implement other method steps in the above page cache expansion module.

[0099] In a specific implementation of this embodiment, the acquisition module 801 is specifically configured to acquire the first cache block from a storage medium in the controller based on a lock-free mechanism.

[0100] In a specific implementation of this embodiment, the sending module 804 is further configured to send the space address mapping relationship and the virtual address to the VFS module through the page cache expansion module when the space address mapping is completed.

[0101] In another specific implementation of this embodiment, the at least one interface includes a second interface, and the second interface is connected to the VFS module and the driver module.

[0102] The acquisition module 801 is also used to obtain a first physical address, and there is a first mapping relationship between the first physical address and the first virtual address; the detection module 802 is also used to detect whether the first physical address is the physical address of the buffer block in the storage medium; if so, the processing module 803 is used to release the buffer block corresponding to the first physical address based on a lock-free mechanism, and unbind the first mapping relationship, and the sending module 804 is used to send a first message to the VFS module, and the first message is used to instruct the VFS module to write back and release the page cache corresponding to the first virtual address.

[0103] In another embodiment, the present disclosure also provides a VFS module, such as Figure 9 As shown, the VFS module is located in the kernel layer and includes:

[0104] The query module 901 is used to query whether there is a first page cache for the file data block corresponding to the data to be written when receiving a disk data write operation from the user layer. The first page cache is generated by converting the first buffer block in the storage medium of the hardware layer disk, and the first buffer block is a free block.

[0105] The copy module 902 is configured to add the first page cache to the internal data structure and copy the data to the first page cache.

[0106] In a specific implementation of this embodiment, the kernel layer further includes a page cache expansion module, and the page cache expansion module is connected to the VFS module through at least one interface.

[0107] The device further includes: a virtual address acquisition module for acquiring a first virtual address, where a spatial address mapping relationship exists between the first virtual address and the first physical address; and a copy module 902 specifically for copying the data to the first page cache according to the first virtual address.

[0108] In another specific implementation of this embodiment, the device further includes: a receiving module and a releasing module.

[0109] The receiving module is configured to receive the first message sent by the page cache management module, and the releasing module is configured to write back the data and release the first page cache through a second interface, wherein the second interface is one of at least one interface in the page cache expansion module.

[0110] In another specific implementation of this embodiment, the copy module 902 is also used to copy the data to the second page cache of the kernel layer first, and then copy the data for a second time to the buffer block in the storage medium through the second page cache when the query module 901 detects that the first page cache does not exist.

[0111] In addition, the query module 901 and the copy module 902 are also used to implement other functions of the aforementioned VFS module, which are not described in detail in this embodiment.

[0112] The device provided by the disclosed embodiments adds a page cache expansion module and a page cache management module to the kernel layer, extending the kernel's existing Page Cache framework. This allows the kernel to reuse much of its own cache management mechanism, making it imperceptible to the user. Furthermore, the page cache management module establishes a mapping between the physical and virtual addresses of buffer blocks in the hardware layer, thereby registering the hardware layer's storage medium as Page Cache. This enables direct data copying to the storage medium, avoiding a secondary data copy. This method reduces one data copy, improves data transmission efficiency, and reduces CPU and RAM consumption.

[0113] It should be noted that the file system disk access device and VFS module in this embodiment are presented in the form of functional units, where the units refer to ASIC circuits, processors and memories that execute one or more software or fixed programs, and / or other devices that can provide the above functions.

[0114] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0115] The present disclosure also provides an electronic device having the above Figure 10 The file system shown is the disk access device.

[0116] See also Figure 10 , is a structural diagram of an electronic device provided by an optional embodiment of the present disclosure, such as Figure 10 As shown, the electronic device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components utilize different buses to communicate with each other and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of a GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 10 A processor 10 is taken as an example.

[0117] The processor 10 may be a central processing unit, a network processor, or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic, or any combination thereof.

[0118] The memory 20 stores instructions that can be executed by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.

[0119] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created based on the use of an electronic device presented by a small program landing page, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely located relative to the processor 10, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0120] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, a hard disk, or a solid-state drive; the memory 20 may also include a combination of the aforementioned types of memory. The electronic device also includes a communication interface 30 for communicating with other devices or a communication network.

[0121] In addition, the electronic device also includes an input device and an output device ( Figure 10 (not shown in the figure). The processor 10, the memory 20, and the input / output device can be connected via a bus or other means. Optionally, the input device can receive input digital or character information, and generate key signal input related to the user settings and function control of the electronic device, such as a touch screen, a keypad, a mouse, a trackpad, a touchpad, an indicator stick, one or more mouse buttons, a trackball, a joystick, etc. The output device may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device may be a touch screen.

[0122] The embodiments of the present disclosure also provide a computer-readable storage medium, and the above-mentioned method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or implemented as a computer code that can be recorded in a storage medium, or downloaded through a network and originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware.

[0123] The storage medium may be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, or a solid-state drive, etc.; further, the storage medium may include a combination of the aforementioned types of memory. It is understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the methods shown in the above embodiments are implemented.

[0124] Although the embodiments of the present disclosure have been described with reference to the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A method for accessing a file system disk, characterized in that: The method is applied to the kernel layer, which includes a page cache expansion module and a page cache management module. The page cache expansion module is connected to a virtual file system (VFS) module and a driver module via at least one interface. The driver module is connected to the hardware layer, and the page cache management module is located within the driver module. The method includes: When the VFS module performs a disk data write operation through the first interface, the page cache management module obtains a first buffer block in the storage medium of the hardware layer disk, the first buffer block being a free block, and the first interface being one of the at least one interface; The page cache management module detects whether the physical address on the first buffer block completes space address mapping; If not completed, using the page cache expansion module to allocate a virtual address for it, and establish a space mapping relationship between the virtual address and the physical address; The page cache management module converts the first buffer block into a first page cache according to the space mapping relationship, and sends the space mapping relationship and the virtual address to the VFS module through the page cache expansion module. The first page cache is used to enable the VFS module to add and copy data.

2. The method according to claim 1, characterized in that The step of obtaining a first buffer block from a storage medium of a hardware layer disk includes: The page cache management module obtains the first buffer block from a storage medium in the controller based on a lock-free mechanism.

3. The method according to claim 1, characterized in that The method further comprises: If the space address mapping is completed, the space address mapping relationship and the virtual address are sent to the VFS module through the page cache expansion module.

4. The method according to any one of claims 1 to 3, characterized in that The at least one interface includes a second interface, the second interface being connected to the VFS module and the driver module, and the method further comprising: The page cache management module obtains a first physical address, where a first mapping relationship exists between the first physical address and the first virtual address; The page cache management module detects whether the first physical address is a physical address of a buffer block in the storage medium; If so, the buffer block corresponding to the first physical address is released based on a lock-free mechanism, the first mapping relationship is unbound, and a first message is sent to the VFS module, where the first message is used to instruct the VFS module to write back and release the page cache corresponding to the first virtual address.

5. A method for accessing a file system disk, characterized in that: The method is applied to a virtual file system (VFS) module, the VFS module is located in a kernel layer, the kernel layer includes a page cache expansion module and a page cache management module, the page cache expansion module is connected to the virtual file system (VFS) module and a driver module via at least one interface, the driver module is connected to a hardware layer, and the page cache management module is located in the driver module, the method includes: When receiving a disk data write operation from the user layer, the VFS module queries whether a file data block corresponding to the to-be-written data exists in a first page cache, where the first page cache is generated by converting a first buffer block in the storage medium of the hardware layer disk according to a spatial mapping relationship, where the first buffer block is a free block; the spatial mapping relationship is a mapping relationship between a virtual address assigned to the first buffer block and a physical address of the first buffer block; If yes, the VFS module adds the first page cache to an internal data structure and copies the data to the first page cache; If the first page cache does not exist, the VFS module first copies the data to the second page cache of the kernel layer, and then copies the data to the buffer block in the storage medium through the second page cache.

6. The method according to claim 5, characterized in that The kernel layer further includes a page cache expansion module, which is connected to the VFS module via at least one interface. Copying data to the first page cache includes: The VFS module obtains a first virtual address, where a space address mapping relationship exists between the first virtual address and the first physical address; The VFS module copies the data to the first page cache according to the first virtual address.

7. The method according to claim 6, characterized in that The method further comprises: The VFS module receives a first message sent by the page cache management module; The VFS module writes back the data and releases the first page cache through a second interface, where the second interface is one of at least one interface in the page cache expansion module.

8. A device for accessing a file system disk, characterized in that: The device comprises: an acquisition module, configured to acquire a first buffer block in a storage medium of a hardware layer disk when a virtual file system VFS module performs a disk data write operation through a first interface, wherein the first buffer block is a free block, and the first interface is one of at least one interface of a page cache extension module; A detection module, configured to detect whether the physical address on the first buffer block has completed space address mapping; a processing module configured to, when detecting incompleteness, establish a space mapping relationship between the virtual address and the physical address using the virtual address allocated by the page cache expansion module, and convert the first buffer block into a first page cache according to the space mapping relationship; The sending module is used to send the space mapping relationship and the virtual address to the VFS module through the page cache expansion module, and the first page cache is used to enable the VFS module to add and copy data.

9. A device for accessing a file system disk, characterized in that: The device comprises: a query module configured to, upon receiving a disk data write operation from a user layer, query whether a file data block corresponding to the to-be-written data exists in a first page cache, wherein the first page cache is generated by converting a first buffer block in a storage medium of a hardware layer disk according to a spatial mapping relationship, wherein the first buffer block is a free block; the spatial mapping relationship is a mapping relationship between a virtual address allocated to the first buffer block and a physical address of the first buffer block; A copy module is used to add the first page cache to the internal data structure and copy the data to the first page cache if the first page cache does not exist; if the first page cache does not exist, first copy the data to the second page cache of the kernel layer, and then copy the data a second time to the buffer block in the storage medium through the second page cache.

10. An electronic device, characterized in that: The electronic device comprises: a memory and a processor, wherein the memory and the processor are connected; The memory stores computer instructions, and the processor executes the file system disk access method according to any one of claims 1 to 4, or 5 to 7 by executing the computer instructions.

11. A computer-readable storage medium, characterized in that The computer readable storage medium has computer instructions stored thereon, The computer instructions are used to enable a computer to execute the file system disk access method according to any one of claims 1 to 4, or 5 to 7.

Citation Information

Patent Citations

  • Non-volatile storage medium sharing method and device, electronic equipment and storage equipment

    CN111444113A

  • File system processing method and device for real-time data storage, vehicle-mounted terminal and commercial vehicle

    CN113703667A