Fine-grained file system and file reading and writing method

By setting a double-layer index structure for each file, the efficiency problem of new non-volatile memory devices in concurrent reading and writing of a single large file is solved, efficient file reading and writing operations are achieved, and the performance of the file system is improved.

WO2024197789A1PCT designated stage expired Publication Date: 2024-10-03SHANGHAI TECH UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2023/085386
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-28
Filing Date
2023-03-31
Publication Date
2024-10-03

AI Technical Summary

Technical Problem

The existing file system cannot effectively support the concurrent reading and writing of a single large file by new non-volatile memory devices in scenarios such as scientific computing, AI training, and sensor data collection, and has not specifically optimized non-volatile memory devices.

Method used

Provide a fine-grained file system that sets a double-layer index structure for each file and stores it in a non-volatile memory device and a dynamic random access memory respectively to achieve efficient positioning and read and write operations on sub-files, including file index nodes. , sub-file index nodes, key-value mapping tables, file locks and available space tables to optimize file reading and writing efficiency.

Benefits of technology

It realizes the concurrent reading and writing function of a single large file, improves the reading and writing speed and efficiency of the file, and solves the problem of insufficient optimization of the concurrent reading and writing scenario of a single large file in the existing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023085386_03102024_PF_FP_ABST
    Figure CN2023085386_03102024_PF_FP_ABST
Patent Text Reader

Abstract

The present application provides a fine-grained file system and a file reading and writing method. Corresponding read or write operations are performed on sub-files of one or a plurality of files with read and write needs by means of a double-layer index structure arranged for each file, such that the function of concurrent reading and writing of a single large file is achieved, and the speed and efficiency of file reading and writing are improved.
Need to check novelty before this filing date? Find Prior Art

Description

A fine-grained file system and file reading and writing method Technical Field

[0001] The present application relates to the field of file systems, and in particular to a fine-grained file system and a file reading and writing method. Background Art

[0002] New non-volatile devices offer excellent features such as low latency and high read and write bandwidth, making them ideal for use as storage disks in existing data centers. This new hardware can significantly improve storage subsystem performance and provide a better user experience.

[0003] Using new non-volatile memory devices as storage requires file system support. However, existing file systems are not specifically optimized for these new non-volatile devices. Existing new non-volatile memory file systems only optimize for aspects such as total bandwidth for multi-file read / write operations, read / write latency, and file system multi-core scalability. However, scenarios such as scientific computing, AI training, and sensor data collection require concurrent read / write operations for single large files. Currently, no effective optimization solutions have been proposed for these concurrent read / write operations.

[0004] Summary of the Invention

[0005] In view of the shortcomings of the prior art described above, the purpose of this application is to provide a fine-grained file system and file reading and writing method to solve the problems in the prior art that the concurrent reading and writing of a single large file cannot be supported and the traditional file system has not been specially optimized for non-volatile memory devices.

[0006] To achieve the above-mentioned purpose and other related purposes, the present application provides a fine-grained file system, including: an index structure setting module, which is used to set a double-layer index structure related to each sub-file in each file for each file, and store the double-layer index structure in a non-volatile memory device and a dynamic random access memory respectively; a file read and write module, connected to the index structure setting module, which is used to locate the corresponding sub-file based on the double-layer index structure of the corresponding file when one or more files have sub-file read and write operation requirements, and load the data in the data block storing the corresponding sub-file into the dynamic random access memory for corresponding read or write operations on the corresponding sub-file.

[0007] In some embodiments of the present application, the method of setting up a double-layer index structure related to each sub-file in each file for each file includes: establishing a mapping relationship between a file index node constructed for each file and a sub-file index node constructed corresponding to each sub-file in each file to obtain a first-layer index structure; establishing a mapping relationship between each sub-file index node that has a mapping relationship with a file index node and a data block that stores each sub-file corresponding to each sub-file index node to obtain a second-layer index structure; the first-layer index structure and the second-layer index structure constitute a double-layer index structure.

[0008] In some embodiments of the present application, the file index node includes: a key-value mapping table; wherein the key-value mapping table includes: a sub-file number and a sub-file index node corresponding to the sub-file number; the file system obtains the sub-file index node corresponding to the number based on the number of the sub-file with sub-file read and write operation requirements.

[0009] In some embodiments of the present application, each sub-file index node includes a first pointer pair; wherein, the first pointer pair is used to obtain the location of the file log page of the sub-file, so as to update the information of the file log page after the write operation is completed.

[0010] In some embodiments of the present application, the log page of the sub-file includes a second pointer pair; wherein the second pointer pair is used to obtain the physical address of the sub-file for read or write operations, and to update the physical address of the sub-file for write operations; the second pointer pair is also used for file garbage collection after the physical address of the sub-file for write operations is updated.

[0011] In some embodiments of the present application, the sub-file index node includes a file lock; wherein the file lock is used to lock the sub-file when a write operation is performed on the sub-file and to unlock the sub-file after the write operation is completed.

[0012] In some embodiments of the present application, the system further includes: an available space table associated with multiple data blocks for file management; the file system creates a new file when there are unused data blocks in the data blocks managed in the available space table.

[0013] To achieve the above-mentioned purpose and other related purposes, the present application provides a file reading and writing method, which includes: setting a two-layer index structure related to each sub-file in each file for each file through a fine-grained file system; when one or more files have sub-file reading and writing operation requirements, the fine-grained file system locates the corresponding sub-file based on the two-layer index structure of the corresponding file, so as to perform corresponding read or write operations on the corresponding sub-file.

[0014] As described above, the fine-grained file system and file reading and writing method of the present application have the following beneficial effects: the present invention performs corresponding read or write operations on the sub-files of one or more files with read and write requirements through a double-layer index structure set for each file, thereby realizing the function of concurrent reading and writing of a single large file, and improving the reading and writing speed of the file, with higher reading and writing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] FIG1 is a schematic diagram showing a fine-grained file system structure in an embodiment of the present application.

[0016] FIG2 is a schematic diagram of a double-layer index structure in an embodiment of the present application.

[0017] FIG3 shows a schematic diagram of a key-value mapping representation in an embodiment of the present application.

[0018] FIG. 4 is a schematic diagram showing a first pointer pair and a second pointer pair in an embodiment of the present application.

[0019] FIG. 5 is a schematic diagram showing a double-layer index structure with file locks according to an embodiment of the present application.

[0020] FIG6 shows a flow chart of a file reading and writing method in one embodiment of the present application. DETAILED DESCRIPTION

[0021] The following describes the embodiments of the present application through specific examples. Those skilled in the art can easily understand the other advantages and effects of the present application from the content disclosed in this specification. The present application can also be implemented or applied through other different specific embodiments. The details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that the following embodiments and features in the embodiments can be combined with each other unless they conflict.

[0022] It should be noted that in the following description, reference is made to the accompanying drawings, which describe several embodiments of the present application. It should be understood that other embodiments may also be used, and that mechanical, structural, electrical, and operational changes may be made without departing from the spirit and scope of the present application. The following detailed description should not be considered restrictive, and the scope of the embodiments of the present application is limited only by the claims of the published patents. The terms used herein are only for describing specific embodiments and are not intended to limit the present application. Spatially related terms, such as "upper", "lower", "left", "right", "below", "below", "lower", "above", "upper", etc., may be used in the text to facilitate the description of the relationship between one element or feature shown in the figure and another element or feature.

[0023] In this application, unless otherwise specified or limited, the terms "mounted," "connected," "connect," "fixed," "holding," and the like should be understood broadly. For example, they may refer to fixed, detachable, or integral connections; mechanical or electrical connections; direct or indirect connections through an intermediary; or internal communication between two components. Those skilled in the art will understand the specific meanings of these terms in this application based on specific circumstances.

[0024] Furthermore, as used herein, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context indicates otherwise. The terms "first," "second," "third," "fourth," and so on (if any) in the description and claims of the present invention and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "comprising" and "including" indicate the presence of the stated features, operations, elements, components, items, types, and / or groups, but do not preclude the presence, occurrence, or addition of one or more other features, operations, elements, components, items, types, and / or groups. It should be further understood that the terms "or" and "and / or" used herein are to be interpreted as inclusive, or to mean any one or any combination. Thus, "A, B, or C" or "A, B, and / or C" means "any of the following: A; B; C; A and B; A and C; B and C; A, B, and C." Exceptions to this definition occur only when a combination of elements, functions, or operations are inherently mutually exclusive in some manner.

[0025] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the following embodiments and the accompanying drawings are used to further describe the technical solutions in the embodiments of the present invention. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0026] As shown in FIG1 , it is a schematic diagram of the fine-grained file system structure in an embodiment of the present invention.

[0027] The fine-grained file system 1 includes:

[0028] The index structure setting module 11 is used to set a double-layer index structure 2 related to each sub-file in each file for each file, and store the double-layer index structure 2 in the non-volatile memory device and the dynamic random access memory respectively; wherein, the index structure setting module 11 divides each file into several sub-files according to the set allocation granularity size, and sets a related double-layer index structure for each file; through the double-layer index structure, a mapping relationship between each file and its sub-files is constructed.

[0029] It should be noted that the allocation granularity can be selected according to actual needs, and the present invention does not limit this. The fine-grained file system must be loaded into the dynamic random access memory to implement file access.

[0030] The file reading and writing module 12 is connected to the index structure setting module 11 and is used to locate the corresponding sub-file based on the double-layer index structure of the corresponding file when one or more files have sub-file reading and writing operation requirements, and load the data in the data block storing the corresponding sub-file into the dynamic random access memory for the corresponding reading or writing operation on the corresponding sub-file.

[0031] The data of a file is stored in one or more data blocks, and each sub-file of each file corresponds to a data block for storing the data of each sub-file.

[0032] Specifically, file reading and writing include the following methods:

[0033] The first method: When a sub-file in one or more files needs to be read, the file reading and writing module 12 locates the data block corresponding to the sub-file that needs to be read through the double-layer index structure, and loads the data of the data block corresponding to the sub-file that needs to be read into the dynamic random access memory for the reading operation of the sub-file;

[0034] The second method: when a sub-file in one or more files needs to be written, the file reading and writing module 12 locates the data block corresponding to the sub-file that needs to be written through the double-layer index structure, and loads the data of the data block corresponding to the sub-file that needs to be written into the dynamic random access memory for the writing operation on the sub-file;

[0035] The third method: When a sub-file that needs to be read and a sub-file that needs to be written exist in the same file at the same time, the file reading and writing module 12 locates the data blocks corresponding to the sub-file that needs to be read and the data blocks corresponding to the sub-file that needs to be written through the double-layer index structure 2, and loads the data in the data blocks corresponding to the sub-file that needs to be read and the data in the data blocks corresponding to the sub-file that needs to be written into the dynamic random access memory, so as to perform corresponding reading or writing operations on the sub-file that needs to be read and the sub-file that needs to be written.

[0036] It should be noted that the division of the various modules of the above devices is merely a division of logical functions. In actual implementation, they may be fully or partially integrated into a single physical entity, or physically separated. Furthermore, these modules may be implemented entirely in the form of software called by processing elements, entirely in the form of hardware, or partially in the form of software called by processing elements, while others may be implemented in the form of hardware.

[0037] In some preferred embodiments of the present invention, the index structure setting module 11 divides each file into several sub-files according to the size of the Linux operating system kernel page, that is, with 4KiB or 2MiB as the allocation granularity, and the index structure setting module 11 will give priority to using 2MiB data blocks for storing file data to solve the problem of storage device space fragmentation.

[0038] In some embodiments of the present invention, the dual-layer index structure is shown in Figure 2, including: a first-layer index structure of a mapping relationship between a file index node (Inode) 21 constructed for each file and a sub-file index node (Sub-inode) 22 constructed corresponding to each sub-file in each file; a second-layer index structure is obtained by establishing a mapping relationship between each sub-file index node that has a mapping relationship with a file index node 21 and a data block (Data Block) that stores each sub-file corresponding to each sub-file index node 22; the first-layer index structure and the second-layer index structure constitute a dual-layer index structure.

[0039] Specifically, the fine-grained file system sets a corresponding file index node 21 for each file. Each file's file index node 21 forms a file index node table (Inode table). Furthermore, the fine-grained file system sets a corresponding sub-file index node 22 for each sub-file within each file. In the first-level index structure, there is a one-to-many mapping relationship between each file's file index node 21 and each sub-file's sub-files within that file. In the second-level index structure, each sub-file index node that is mapped to a file index node 21 has a one-to-one mapping relationship with each sub-file's data block corresponding to each sub-file index node 22.

[0040] In some embodiments of the present invention, reading and writing files through the above-mentioned dual-layer index structure 2 includes the following methods:

[0041] The first method: When a sub-file in one or more files needs to be read, the file reading and writing module locates the sub-file index node 22 of the sub-file that needs to be read through the double-layer index structure 2, locates the data block 23 storing the data of the sub-file that needs to be read through the sub-file index node 22, and loads the data in the data block 23 into the dynamic random access memory for the reading operation of the sub-file;

[0042] The second method: when a sub-file in one or more files needs to be written, the file reading and writing module locates the sub-file index node 22 of the sub-file that needs to be written through the double-layer index structure 2, locates the data block 23 storing the data of the sub-file that needs to be written through the sub-file index node 22, and loads the data in the data block 23 into the dynamic random access memory for performing the writing operation on the sub-file that needs to be written;

[0043] The third method: When a sub-file that needs to be read and a sub-file that needs to be written exist in the same file at the same time, the file reading and writing module locates the sub-file index node 22 of the sub-file that needs to be read and the sub-file index node 22 that needs to be written respectively through the double-layer index structure 2, so that the file reading and writing module can locate the data block 23 storing the data of the sub-file that needs to be read and the data block 23 storing the data of the sub-file that needs to be written, and load the data in the data block 23 corresponding to the sub-file that needs to be read and the data in the data block 23 corresponding to the sub-file that needs to be written into the dynamic random access memory respectively, so as to perform a reading operation on the sub-file that needs to be read and a writing operation on the sub-file that needs to be written.

[0044] In some embodiments of the present invention, each file index node includes a file attribute management pointer pair for managing log entries related to file attribute changes. Specifically, when a write operation is completed on a file, the file's file attributes change. The fine-grained file system can use this file attribute management pointer pair to update data related to the file attribute changes. File attributes include file size, creation time, file permissions, and creator.

[0045] In some embodiments of the present invention, the file index node includes: a key-value mapping table as shown in Figure 3; wherein the key-value mapping table includes: a sub-file number and a sub-file index node 22 corresponding to the sub-file number; the file system obtains the sub-file index node 22 corresponding to the number of the sub-file with sub-file read and write operation requirements.

[0046] Specifically, the data of each file is stored in one or more data blocks, each of which corresponds to a sub-file number and a sub-file index node 22. When a sub-file in one or more files needs to be read or written, the file read / write module obtains the sub-file index node 22 corresponding to the sub-file number based on the sub-file number in the key-value mapping table, and then locates the data block corresponding to the sub-file through the sub-file index node 22.

[0047] In some embodiments of the present invention, as shown in FIG4 , each sub-file index node 22 includes a first pointer pair (head & tail); the first pointer pair is used to obtain the location of the file log page (File log) of the sub-file, so as to update the information of the file log page after the write operation is completed. The information of the file log page includes: the amount of data written by this write operation and the logical address of the written data stored in the storage device. The logical address is the address used by the program code and is generated by the operating system. The logical address points to an address space in the memory and is an offset relative to the starting address of the program. In other words, the logical address is the address used in the program. There is a correspondence between the logical address and the physical address, and the physical address of the written data in the storage device can be located by the logical address.

[0048] In some embodiments of the present invention, as shown in Figure 4, the log page of the sub-file includes a second pointer pair (prev&curr); the second pointer pair is used to obtain the physical address of the sub-file for reading or writing operations, and to update the physical address of the sub-file for writing operations; the second pointer pair is also used for file garbage collection after the physical address of the sub-file for writing operations is updated.

[0049] Specifically, the data in a file is stored in the data area of ​​the disk. The data area of ​​the disk contains multiple data blocks, and the disk assigns a physical address to each data block. The physical address is the real address in the memory, generated by the CPU, and used to access the data block.

[0050] The method in which the second pointer pair is used to obtain the physical address of the sub-file for reading or writing operations includes: when a sub-file in one or more files needs to be read or written, the physical address of the data block corresponding to the sub-file that needs to be read or written is located through the second pointer pair, and the corresponding data block is located through the physical address of the data block, and the read or write operation is performed on it.

[0051] The method for updating the physical address of a sub-file used for a write operation by a second pointer pair includes: the second pointer pair includes a prev pointer and a curr pointer, the prev pointer is used to locate the physical address of a data block storing data of a current version, and the curr pointer is used to locate the physical address of a data block storing updated data. When a write operation is required for a sub-file in one or more files, the data written by the write operation is stored in the corresponding data block via the curr pointer. When the write operation is completed, the prev pointer points to the physical address of the data block corresponding to the curr pointer, and the curr pointer points to the physical address of a new data block without stored data.

[0052] It should be noted that when the prev pointer points to the address of the data block corresponding to the curr pointer, and the curr pointer points to a new data block that does not store data, an update of the physical address of the sub-file performing the write operation is completed, that is, an update of the data version.

[0053] After updating the sub-file undergoing a write operation, data garbage will be stored on the disk. To free up disk space, garbage collection needs to be performed regularly. The second pointer pair is used for garbage collection in a manner that: after the physical address of the sub-file undergoing a write operation is updated, the data in the data block corresponding to the physical address to which the prev pointer corresponded after the previous update operation is completed is stored as garbage on the disk; after the physical address of the sub-file undergoing a write operation is updated again, the data in the data block corresponding to the physical address to which the prev pointer corresponded after the previous update operation is completed is recycled.

[0054] For example, completing an update of the physical address of a sub-file that is undergoing a write operation is equivalent to an update of the data version. Set the sub-file currently being read by the user to version 1. At this time, the prev pointer points to the address of the data block corresponding to the sub-file of version 1. Version 1 is the current version, and version 0 is the previous version of version 1. When the user writes to this sub-file, the system stores the data written by the write operation in the corresponding data block through the curr pointer. When the write operation is completed, the prev pointer points to the physical address of the data block corresponding to the curr pointer, and the curr pointer points to the physical address of the new data block that does not store data. The prev pointer points to the address of the data block corresponding to the sub-file of version 2. Version 2 is the current version, and version 1 is the previous version of version 2. At this time, the data in the data block corresponding to the sub-file of version 0 will be recycled.

[0055] In some embodiments of the present invention, as shown in FIG. 5 , the sub-file index node includes a file lock; the file lock is used to lock a sub-file when a write operation is performed on the sub-file and to unlock the sub-file after the write operation is completed.

[0056] Specifically, when a sub-file in one or more files needs to be read, the file lock locks the sub-file index node corresponding to the sub-file that needs to be written. At this time, other operations such as reading the sub-file that needs to be written cannot be performed on the sub-file, and only the current write operation can be performed. When the write operation is completed, the locked sub-file index node is unlocked, and the sub-file can now be written or read.

[0057] In some embodiments of the present invention, when a file contains both a subfile requiring a read operation and a subfile requiring a write operation, a file lock locks the subfile index node corresponding to the subfile requiring a write operation. At this point, the subfile requiring a write operation cannot be read, but other unlocked subfiles can be read. Because each subfile index node is protected by a lock, multiple users can simultaneously read and write to the same file. This solves the problem of other users having to wait for the current user's write operation to complete before continuing to operate on the file, saving users time and improving efficiency.

[0058] In some embodiments of the present invention, as shown in FIG4 , the system further includes: an available space table (Free list) associated with a plurality of data blocks for file management; the file system creates a new file when there are unused data blocks in the data blocks managed in the free space table.

[0059] Specifically, as shown in the figure, a portion of the disk area is allocated to the free space table for file management. When unused data blocks exist in the data blocks managed by the free space table, there are still unused data blocks on the disk that can be used to store data. In this case, users can create new files in the system. When all data blocks managed by the free space table are used, there are no unused data blocks on the disk. In this case, users cannot create new files in the system.

[0060] In some embodiments of the present invention, after a write operation is completed, information updated in the dual-layer index structure is transferred to the non-volatile memory device for storage. The updated information in the dual-layer index structure includes information such as file attribute changes and file log page information. File attributes include file size, creation time, file permissions, and creator. File log page information includes the amount of data written in this write operation and the logical address where the written data is stored in the storage device.

[0061] In some embodiments of the present invention, a fine-grained file system can be added to the Linux source tree file system. The file system can be compiled into the kernel or loaded as a kernel module. Specifically, the fine-grained file system and the non-volatile memory device using the fine-grained file system are mounted to corresponding mount points using the Linux mount command.

[0062] As shown in FIG6 , it shows a flow chart of a file reading and writing method according to an embodiment of the present invention.

[0063] File reading and writing methods include:

[0064] Step S1: setting a double-layer index structure related to each sub-file in each file for each file through a fine-grained file system;

[0065] Step S2: When one or more files have sub-file read or write operation requirements, the fine-grained file system locates the corresponding sub-files based on the double-layer index structure of the corresponding files, so as to perform corresponding read or write operations on the corresponding sub-files.

[0066] In some embodiments of the present invention, step S1 includes: dividing each file into a plurality of sub-files according to a set allocation granularity, and establishing a related dual-layer index structure for each file and its sub-files; using the dual-layer index structure, a mapping relationship between each file and its sub-files is established. It should be noted that the selected allocation granularity can be any byte size, which is not limited by the present invention.

[0067] In some preferred embodiments of the present invention, the allocation granularity can be set according to the size of the Linux operating system kernel page, that is, 4KiB or 2MiB is used as the allocation granularity, each file is divided into several sub-files, and 2MiB data blocks are preferentially used for storing file data to solve the problem of storage device space fragmentation.

[0068] In some embodiments of the present invention, step S2 includes the following methods:

[0069] The first method: When a sub-file in one or more files needs to be read, the file reading and writing module locates the data block corresponding to the sub-file that needs to be read through the double-layer index structure, and loads the data of the data block corresponding to the sub-file that needs to be read into the dynamic random access memory for the reading operation of the sub-file;

[0070] The second method: when a sub-file in one or more files needs to be written, the file reading and writing module locates the data block corresponding to the sub-file that needs to be written through the double-layer index structure, and loads the data of the data block corresponding to the sub-file that needs to be written into the dynamic random access memory for the writing operation on the sub-file;

[0071] The third method: When a sub-file that needs to be read and a sub-file that needs to be written exist in the same file at the same time, the file reading and writing module locates the data blocks corresponding to the sub-file that needs to be read and the data blocks corresponding to the sub-file that needs to be written through a double-layer index structure, and loads the data in the data blocks corresponding to the sub-file that needs to be read and the data in the data blocks corresponding to the sub-file that needs to be written into the dynamic random access memory, so as to perform corresponding reading or writing operations on the sub-file that needs to be read and the sub-file that needs to be written.

[0072] In some embodiments of the present invention, a method of setting a double-layer index structure related to each sub-file in each file for each file includes: establishing a mapping relationship between a file index node constructed for each file and a sub-file index node constructed corresponding to each sub-file in each file to obtain a first-layer index structure; based on each sub-file index node that has a mapping relationship with a file index node, establishing a mapping relationship between each sub-file index node and a data block stored in each sub-file to obtain a second-layer index structure; the first-layer index structure and the second-layer index structure constitute a double-layer index structure.

[0073] In some embodiments of the present invention, reading and writing files using the above-mentioned dual-layer index structure includes the following methods:

[0074] The first method: When a sub-file in one or more files needs to be read, the file reading and writing module locates the sub-file index node of the sub-file that needs to be read through the double-layer index structure, locates the data block storing the data of the sub-file that needs to be read through the sub-file index node, and loads the data in the data block into the dynamic random access memory for the reading operation of the sub-file;

[0075] The second method: when a sub-file in one or more files needs to be written, the file reading and writing module locates the sub-file index node of the sub-file that needs to be written through the double-layer index structure, locates the data block storing the data of the sub-file that needs to be written through the sub-file index node, and loads the data in the data block into the dynamic random access memory for performing the writing operation on the sub-file that needs to be written;

[0076] The third method: When a sub-file that needs to be read and a sub-file that needs to be written exist in the same file at the same time, the file reading and writing module locates the sub-file index node of the sub-file that needs to be read and the sub-file index node that needs to be written through a double-layer index structure, so that the file reading and writing module can locate the data block storing the data of the sub-file that needs to be read and the data block storing the data of the sub-file that needs to be written, and load the data in the data block corresponding to the sub-file that needs to be read and the data in the data block corresponding to the sub-file that needs to be written into the dynamic random access memory respectively, so as to perform a reading operation on the sub-file that needs to be read and a writing operation on the sub-file that needs to be written.

[0077] In summary, this application provides a fine-grained file system and file reading and writing method. By setting a dual-layer index structure for each file, corresponding read or write operations are performed on sub-files of one or more files with read or write requirements. This enables the concurrent reading and writing of a single large file, improves file reading and writing speed, and achieves higher reading and writing efficiency. Therefore, this application effectively overcomes the various shortcomings of the existing technology and has high industrial application value.

[0078] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Anyone skilled in the art may modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by one of ordinary skill in the art without departing from the spirit and technical concepts disclosed in this application shall be covered by the claims of this application.

Claims

1. A fine-grained file system, characterized in that: include: An index structure setting module, used for setting a double-layer index structure related to each sub-file in each file for each file, and storing the double-layer index structure in a non-volatile memory device and a dynamic random access memory respectively; The file reading and writing module is connected to the index structure setting module and is used to locate the corresponding sub-files based on the double-layer index structure of the corresponding files when one or more files have sub-file reading and writing operation requirements, and load the data in the data blocks storing the corresponding sub-files into the dynamic random access memory for corresponding reading or writing operations on the corresponding sub-files.

2. The system according to claim 1, characterized in that The method of respectively setting a double-layer index structure related to each sub-file in each file for each file includes: Establishing a mapping relationship between the file index node constructed for each file and the sub-file index node constructed for each sub-file in each file, so as to obtain a first-level index structure; Establishing mapping relationships between each sub-file index node having a mapping relationship with a file index node and data blocks of each sub-file corresponding to each sub-file index node, so as to obtain a second-level index structure; The first-layer index structure and the second-layer index structure form a double-layer index structure.

3. The system according to claim 2, characterized in that The file index node includes: a key-value mapping table; Among them, the key-value mapping table includes: sub-file numbers and sub-file index nodes corresponding to the sub-file numbers one by one; the file system obtains the sub-file index node corresponding to the number according to the number of the sub-file with sub-file read and write operation requirements based on the key-value mapping table.

4. The system according to claim 3, characterized in that Each sub-file index node includes a first pointer pair; The first pointer pair is used to obtain the location of the file log page of the sub-file, so as to update the information of the file log page after the write operation is completed.

5. The system according to claim 4, characterized in that The log page of the sub-file includes a second pointer pair; The second pointer pair is used to obtain the physical address of the sub-file for reading or writing, and to update the physical address of the sub-file for writing; the second pointer pair is also used for file garbage collection after the physical address of the sub-file for writing is updated.

6. The system according to claim 5, characterized in that The sub-file index node includes a file lock; The file lock is used to lock a sub-file when a write operation is performed on the sub-file and to unlock the sub-file after the write operation is completed.

7. The system according to claim 5, characterized in that The system further includes: an available space table associated with a plurality of data blocks for file management; The case where the file system has unused data blocks in the data blocks managed in the available space table Next, create a new file.

8. A file reading and writing method, characterized in that: The method comprises: A double-layer index structure related to each sub-file in each file is set for each file through a fine-grained file system; When one or more files have a sub-file read or write operation requirement, the fine-grained file system locates the corresponding sub-file based on the double-layer index structure of the corresponding file to perform a corresponding read or write operation on the corresponding sub-file.

Citation Information

Patent Citations

  • Method for sharing and downloading files in P2P protocol

    CN103986747A

  • Methods for rapid aggregation and reading of multiple files of shared-file system

    CN104410868A

  • Block chain large file secure storage method and system

    CN110062034A

  • System and method for efficiently replicating a file among a plurality of recipients having improved scalability

    US20040143576A1