Method and device for supporting disk quota by user mode file system framework
By reusing the Linux kernel disk quota function in the FUSE framework, the problem of the FUSE file system requiring a lot of code modification and expansion when supporting disk quota is solved, and the rapid use of disk quota function is achieved and system performance and stability is improved.
Patent Information
- Application Number
- CN202411580528.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-02-25
AI Technical Summary
When the existing FUSE file system supports disk quota functionality, it requires a lot of code modifications and function extensions to the client, which increases implementation complexity and may affect performance and stability.
Reuse the Linux kernel disk quota function in the FUSE framework. By initializing the quota metadata information in the file specified by the user, find the corresponding disk format and callback function based on this information when the file system is mounted, set the disk quota ID, and Quota management and persistent storage during file operations.
It realizes the rapid use of disk quota function in FUSE clients, reduces adaptation and migration costs, and improves system stability and overall performance.
Smart Images

Figure CN119512458A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of disk quota processing, and in particular to a method and device for supporting disk quotas in a user-mode file system framework. Background Art
[0002] Existing FUSE file systems usually rely on disk quota functions that have been implemented in the underlying file system (such as ext4 or XFS). In this architecture, the FUSE file system does not directly handle the specific management tasks of disk quotas, but uses the existing quota mechanism of the underlying file system as the basic resource limit.
[0003] In this implementation, the FUSE file system forwards file operation requests from users to the underlying file system for processing, and the underlying file system allocates and manages resources according to its own quota limits. As an intermediate layer, the FUSE file system is responsible for coordinating between the user space and the kernel space to ensure that the user's file operations are subject to the constraints of the underlying quota limits. At the same time, the FUSE file system can also redistribute and manage these quotas in the intermediate layer according to the needs of different users or applications to provide a more flexible quota management strategy. In this way, the FUSE file system can provide upper-level users with disk quota functions similar to traditional file systems, but the specific quota checks and restrictions are still performed by the underlying file system.
[0004] Currently, the FUSE client does not reuse the existing quota management functions and related implementations in the Linux kernel. As a result, if you want to support disk quota functions in the FUSE client, you need to make a lot of code modifications and function extensions to the client. This not only includes re-implementing the quota management logic in user space, but also needs to handle communication and coordination with the kernel to ensure that the quota function can be accurately applied to file system operations. This additional development workload increases the complexity of implementing the quota function and may affect the performance and stability of the file system.
[0005] Therefore, how to invent a disk quota method to reuse the Linux kernel disk quota function in the FUSE framework, integrate the disk quota function into the FUSE framework, and reduce the adaptation and migration costs of the FUSE client has become an urgent problem to be solved. Summary of the invention
[0006] To this end, the present invention provides a method and device for supporting disk quotas in a user-mode file system framework, which reuses the Linux kernel disk quota function in the FUSE framework, integrates the disk quota function in the FUSE framework, thereby reducing the adaptation and migration costs of the FUSE client, and can effectively enable the existing FUSE client to quickly use the disk quota function.
[0007] In order to achieve the above object, the present invention provides the following technical solution: a method for a user-mode file system framework to support disk quotas, comprising:
[0008] Initialize the quota metadata information required by the kernel in the user-specified file;
[0009] When the file system is mounted, the kernel finds the corresponding disk format and callback function from the file specified by the user according to the quota metadata information;
[0010] Setting a disk quota ID for a setting file or a setting directory; setting a disk quota for the disk quota ID;
[0011] Create a new file, the new file inherits the disk quota ID of the set directory;
[0012] When writing data, processing is performed according to the amount of the written data;
[0013] When deleting a file, the disk quota corresponding to the deleted file is released;
[0014] When the file system is uninstalled, the disk quota data is written into the file specified by the user for persistent storage.
[0015] As a preferred solution for a method in which a user-mode file system framework supports disk quotas, in the process of setting the disk quota ID for the setting file or the setting directory, the disk quota ID is forwarded to the user-mode file system client for persistent storage.
[0016] As a preferred solution for a method in which a user-mode file system framework supports disk quotas, during the process of writing data, if the amount of the written data exceeds the disk quota of the new file, an EQUOTA error is returned; if the amount of the written data does not exceed the disk quota of the new file, the disk quota used for the written data is increased.
[0017] As a preferred solution for a method in which a user-mode file system framework supports disk quotas, during the process of deleting files, the corresponding disk quota is released by subtracting the size of the deleted file from the disk size.
[0018] As a preferred solution for a method in which a user-mode file system framework supports disk quotas, during the process of unmounting the file system, the file system is unmounted using the umount command, and the disk quota data is written into the user-specified file for persistent storage.
[0019] The present invention also provides a device for supporting disk quotas in a user-mode file system framework, based on the above method for supporting disk quotas in a user-mode file system framework, comprising:
[0020] The quota metadata initialization module is used to initialize the quota metadata information required by the kernel in the file specified by the user;
[0021] The disk format and callback function confirmation module is used for the kernel to find the corresponding disk format and callback function from the file specified by the user according to the quota metadata information when the file system is mounted;
[0022] The disk quota ID and disk quota setting module are used to set the disk quota ID for the setting file or setting directory; and set the disk quota for the disk quota ID;
[0023] A new file creation module, used for creating a new file, wherein the new file inherits the disk quota ID of the set directory;
[0024] A data writing processing module, used for processing data according to the amount of the written data when writing data;
[0025] The file deletion processing module is used to release the disk quota corresponding to the deleted file when the file is deleted;
[0026] The file system unloading processing module is used to write the disk quota data into the file specified by the user for persistent storage when the file system is unloaded.
[0027] As a preferred solution for a device that supports disk quotas in a user-state file system framework, in the disk quota ID and disk quota setting module, during the process of setting the disk quota ID for the setting file or the setting directory, the disk quota ID is forwarded to the user-state file system client for persistent storage.
[0028] As a preferred solution for a device that supports disk quotas in a user-mode file system framework, in the data writing processing module, during the process of writing data, if the amount of the written data exceeds the disk quota of the new file, an EQUOTA error is returned; if the amount of the written data does not exceed the disk quota of the new file, the disk quota used for the written data is increased.
[0029] As a preferred solution for a device supporting disk quotas in a user-mode file system framework, in the file deletion processing module, during the process of deleting files, the disk size is subtracted from the size of the deleted file to release the corresponding disk quota.
[0030] As a preferred solution for a user-mode file system framework supporting disk quotas, in the file system unloading processing module, during the process of unloading the file system, the file system is unloaded through the umount command, and the disk quota data is written into the file specified by the user for persistent storage.
[0031] The present invention has the following advantages: the quota metadata information required by the kernel is initialized in the file specified by the user; when the file system is mounted, the kernel finds the corresponding disk format and callback function from the file specified by the user according to the quota metadata information; sets the disk quota ID for the setting file or the setting directory; sets the disk quota for the disk quota ID; creates a new file, and the new file inherits the disk quota ID of the setting directory; when writing data, it is processed according to the data volume of the written data; when deleting a file, the disk quota corresponding to the deleted file is released; when the file system is uninstalled, the disk quota data is written into the file specified by the user for persistent storage. The present invention can enable the existing FUSE client to quickly use the disk quota function without repeatedly implementing related functions and repeatedly designing the corresponding disk format. Reusing the Linux kernel disk quota function can improve system stability and overall system performance. The present invention reduces the adaptation and migration costs of the FUSE client, and can effectively enable the existing FUSE client to quickly use the disk quota function. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the implementation methods of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the implementation methods or the description of the prior art. Obviously, the drawings in the following description are only exemplary, and for ordinary technicians in this field, other implementation drawings can be derived from the provided drawings without creative work.
[0033] The structures, proportions, sizes, etc. illustrated in this specification are only used to match the contents disclosed in the specification so as to facilitate understanding and reading by persons familiar with the technology. They are not used to limit the conditions under which the present invention can be implemented, and therefore have no substantial technical significance. Any structural modification, change in proportion or adjustment in size shall still fall within the scope of the technical contents disclosed in the present invention without affecting the effects and purposes that can be achieved by the present invention.
[0034] Figure 1 A schematic flow chart of a method for supporting disk quotas in a user-mode file system framework provided in Embodiment 1 of the present invention;
[0035] Figure 2A schematic diagram of a specific implementation process of a method for supporting disk quotas in a user-mode file system framework provided in Embodiment 1 of the present invention;
[0036] Figure 3 This is a schematic diagram of the architecture of a device for supporting disk quotas in a user-mode file system framework provided in Example 2 of the present invention. DETAILED DESCRIPTION
[0037] The following is a description of the implementation of the present invention by specific embodiments. People familiar with the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] Example 1
[0039] See also Figure 1 and Figure 2 Embodiment 1 of the present invention provides a method for a user-mode file system framework to support disk quotas, comprising the following steps:
[0040] S1. Initialize the quota metadata information required by the kernel in the file specified by the user;
[0041] S2. When the file system is mounted, the kernel finds the corresponding disk format and callback function from the file specified by the user according to the quota metadata information;
[0042] S3, setting a disk quota ID for a setting file or a setting directory; setting a disk quota for the disk quota ID;
[0043] S4, creating a new file, the new file inherits the disk quota ID of the set directory;
[0044] S5. When writing data, processing is performed according to the amount of the written data;
[0045] S6. When deleting a file, the disk quota corresponding to the deleted file is released;
[0046] S7. When the file system is uninstalled, the disk quota data is written into the file specified by the user for persistent storage.
[0047] In this embodiment, in step S1, the quota metadata information required by the kernel is initialized in the file specified by the user; for example, the user-specified file is the quota_file file, the metadata information version is v1, and the quota_header is 0xF8B1C876517690FF.
[0048] In this embodiment, in step S2, when the file system is mounted, the kernel finds the corresponding disk format and callback function from the file specified by the user according to the quota metadata information;
[0049] Specifically, when the file system is mounted, the kernel turns on the quota function and finds the corresponding disk format and callback function based on the metadata information in the specified file. For example, the kernel finds the corresponding disk format and the corresponding callback function based on version v1 and quota_header0xF8B1C876517690FF.
[0050] In this embodiment, in step S3, a disk quota ID is set for a setting file or a setting directory; a disk quota is set for the disk quota ID;
[0051] Specifically, when a user sets a disk quota ID for a file or a directory, the ID needs to be forwarded to the FUSE client for persistent storage. For example, the user sets the ID of the directory / A to 10000.
[0052] The user sets a disk quota for the disk quota ID. For example, the user sets the upper limit of the disk quota with ID 1000 to 9999.
[0053] In this embodiment, in step S4, a new file is created, and the new file inherits the disk quota ID of the set directory;
[0054] Specifically, when a user creates a new file, it automatically inherits the disk quota ID of the directory. For example, if a user creates a new file / A / B in the / A directory, the ID of B is also 1000.
[0055] In this embodiment, in step S5, when writing data, processing is performed according to the amount of the written data;
[0056] Specifically, during the process of writing data, if the amount of data written exceeds the disk quota of the new file, an EQUOTA error is returned; for example, if the total amount of disk written by the user to the / A / directory exceeds 9999, an EQUOTA error is returned. If the amount of data written does not exceed the disk quota of the new file, the disk quota used for writing the data is increased.
[0057] In this embodiment, in step S6, when a file is deleted, the disk quota corresponding to the deleted file is released;
[0058] Specifically, when a user deletes a file, the disk size minus the size of the deleted file is used to release the corresponding disk quota. For example, if a user deletes the / A / B file that occupies 100 disk blocks, the total used disk space is reduced from 10100 to 10000.
[0059] In this embodiment, in step S7, when the file system is uninstalled, the disk quota data is written into the file specified by the user for persistent storage.
[0060] Specifically, when the file system is unmounted, all disk quota data is written to the file specified by the user for persistent storage. For example, if the user uses the umount command to unmount the file system, all memory data is written to the quota_file file specified by the user.
[0061] In summary, the steps of reusing the Linux kernel disk quota function in the FUSE framework in this embodiment are as follows:
[0062] a) Initialize quota metadata information, and initialize the quota metadata information required by the kernel in the file specified by the user. For example: the user specifies the file as quota_file, the metadata version is v1, and quota_header is 0xF8B1C876517690FF.
[0063] b) When the file system is mounted, the kernel turns on the quota function and finds the corresponding disk format and callback function based on the metadata information in the specified file. For example, the kernel finds the corresponding disk format and the corresponding callback function based on version v1 and quota_header0xF8B1C876517690FF.
[0064] c) When a user sets a disk quota ID for a file or directory, it needs to be forwarded to the FUSE client for persistent storage. For example, the user sets the ID of the directory / A to 10000.
[0065] d) The user sets a disk quota for the disk quota ID. For example, the user sets the upper limit of the disk quota for the disk with ID 1000 to 9999.
[0066] e) User-created files: When a user creates a new file, it automatically inherits the disk quota ID of the directory. For example, if a user creates a new file / A / B in the / A directory, the ID of B is also 1000.
[0067] f) User writes files: Checks whether the data written by the user exceeds the set disk quota. If so, an EQUOTA error is returned. For example, if the total amount of disk data written by the user to the / A / directory exceeds 9999, an EQUOTA error is returned.
[0068] g) User deletes a file. When a user deletes a file, the disk size minus the size of the deleted file is used to release the corresponding disk quota. For example, if a user deletes the / A / B file that occupies 100 disk blocks, the total amount of used disk space is reduced from 10100 to 10000.
[0069] h) When the file system is unmounted, all disk quota data is written to the file specified by the user for persistent storage. For example, if the user uses the umount command to unmount the file system, all memory data will be written to the quota_file file specified by the user.
[0070] To summarize again, the present invention initializes the quota metadata information required by the kernel in the file specified by the user; when the file system is mounted, the kernel finds the corresponding disk format and callback function from the file specified by the user according to the quota metadata information; sets the disk quota ID for the setting file or setting directory; sets the disk quota for the disk quota ID; creates a new file, and the new file inherits the disk quota ID of the setting directory; when writing data, it processes according to the data volume of the written data; when deleting a file, the disk quota corresponding to the deleted file is released; when the file system is uninstalled, the disk quota data is written into the file specified by the user for persistent storage. The present invention can enable the existing FUSE client to quickly use the disk quota function without repeatedly implementing related functions and repeatedly designing the corresponding disk format. Reusing the Linux kernel disk quota function can improve system stability and overall system performance. The present invention reduces the adaptation and migration costs of the FUSE client, and can effectively enable the existing FUSE client to quickly use the disk quota function.
[0071] It should be noted that the method of the embodiment of the present disclosure can be performed by a single device, such as a computer or a server. The method of the present embodiment can also be applied in a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of the embodiment of the present disclosure, and the multiple devices will interact with each other to complete the described method.
[0072] It should be noted that the above describes some embodiments of the present disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0073] Example 2
[0074] See also Figure 3 Embodiment 2 of the present invention further provides a device for supporting disk quotas in a user-mode file system framework, including:
[0075] The quota metadata initialization module 001 is used to initialize the quota metadata information required by the kernel in the file specified by the user;
[0076] The disk format and callback function confirmation module 002 is used for the kernel to find the corresponding disk format and callback function from the file specified by the user according to the quota metadata information when the file system is mounted;
[0077] The disk quota ID and disk quota setting module 003 is used to set the disk quota ID for the setting file or setting directory; and set the disk quota for the disk quota ID;
[0078] A new file creation module 004, used for creating a new file, the new file inherits the disk quota ID of the set directory;
[0079] The data writing processing module 005 is used to process the data according to the amount of the written data when writing the data;
[0080] The file deletion processing module 006 is used to release the disk quota corresponding to the deleted file when deleting the file;
[0081] The file system unloading processing module 007 is used to write the disk quota data into the file specified by the user for persistent storage when the file system is unloaded.
[0082] In this embodiment, in the disk quota ID and disk quota setting module 003, in the process of setting the disk quota ID for the setting file or the setting directory, the disk quota ID is forwarded to the user-mode file system client for persistent storage.
[0083] In this embodiment, in the data writing processing module 005, during the process of writing data, if the data volume of the written data exceeds the disk quota of the new file, an EQUOTA error is returned; if the data volume of the written data does not exceed the disk quota of the new file, the disk quota used for writing the data is increased.
[0084] In this embodiment, in the file deletion processing module 006, during the process of deleting a file, the disk size is subtracted from the size of the deleted file to release the corresponding disk quota.
[0085] In this embodiment, in the file system unloading processing module 007, during the process of unloading the file system, the file system is unloaded by using the umount command, and the disk quota data is written into the file specified by the user for persistent storage.
[0086] It should be noted that the information interaction, execution process, etc. between the modules of the above-mentioned system are based on the same concept as the method embodiment in Example 1 of the present application, and the technical effects they bring are the same as those of the method embodiment of the present application. For specific contents, please refer to the description in the method embodiment shown above in the present application, and will not be repeated here.
[0087] Example 3
[0088] Embodiment 3 of the present invention provides a non-transitory computer-readable storage medium, in which a program code for a method for a user-mode file system framework to support disk quotas is stored. The program code includes instructions for executing embodiment 1 or any possible implementation thereof.
[0089] The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0090] Example 4
[0091] Embodiment 4 of the present invention provides an electronic device, including: a memory and a processor;
[0092] The processor and the memory communicate with each other via a bus; the memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute a method in which a user-mode file system framework supports disk quotas in Example 1 or any possible implementation thereof.
[0093] Specifically, the processor can be implemented by hardware or by software. When implemented by hardware, the processor can be a logic circuit, an integrated circuit, etc.; when implemented by software, the processor can be a general-purpose processor implemented by reading software codes stored in a memory. The memory can be integrated in the processor or can be located outside the processor and exist independently.
[0094] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable systems. The computer instructions can be stored in a computer-readable storage medium, or transmitted from a computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center.
[0095] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing system, they can be concentrated on a single computing system, or distributed on a network composed of multiple computing systems, and optionally, they can be implemented by a program code executable by a computing system, so that they can be stored in a storage system and executed by the computing system, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0096] Although the present invention has been described in detail above by general description and specific embodiments, it is obvious to those skilled in the art that some modifications or improvements can be made to the present invention. Therefore, these modifications or improvements made without departing from the spirit of the present invention all belong to the scope of protection claimed by the present invention.
Claims
1. A method for supporting disk quotas in a user-mode file system framework, characterized in that: include: Initialize the quota metadata information required by the kernel in the user-specified file; When the file system is mounted, the kernel finds the corresponding disk format and callback function from the file specified by the user according to the quota metadata information; Set disk quota ID for setting files or setting directories; Setting a disk quota for the disk quota ID; Create a new file, the new file inherits the disk quota ID of the set directory; When writing data, processing is performed according to the amount of the written data; When deleting a file, the disk quota corresponding to the deleted file is released; When the file system is uninstalled, the disk quota data is written into the file specified by the user for persistent storage.
2. According to claim 1, a method for supporting disk quotas in a user-mode file system framework, characterized in that: In the process of setting the disk quota ID for the setting file or the setting directory, the disk quota ID is forwarded to the user-mode file system client for persistent storage.
3. A method for supporting disk quotas in a user-mode file system framework according to claim 2, characterized in that: During the process of writing data, if the amount of the written data exceeds the disk quota of the new file, an EQUOTA error is returned; if the amount of the written data does not exceed the disk quota of the new file, the disk quota used for the written data is increased.
4. A method for supporting disk quotas in a user-mode file system framework according to claim 3, characterized in that: When deleting files, the disk size minus the size of the deleted file is used to release the corresponding disk quota.
5. A method for supporting disk quotas in a user-mode file system framework according to claim 4, characterized in that: In the process of unmounting the file system, the file system is unmounted through the umount command, and the disk quota data is written into the file specified by the user for persistent storage.
6. A device for supporting disk quotas in a user-mode file system framework, using the method for supporting disk quotas in a user-mode file system framework as described in any one of claims 1 to 5, characterized in that: include: The quota metadata initialization module is used to initialize the quota metadata information required by the kernel in the file specified by the user; The disk format and callback function confirmation module is used for the kernel to find the corresponding disk format and callback function from the file specified by the user according to the quota metadata information when the file system is mounted; Disk quota ID and disk quota setting module, used to set disk quota ID for setting files or setting directories; Setting a disk quota for the disk quota ID; A new file creation module, used for creating a new file, wherein the new file inherits the disk quota ID of the set directory; A data writing processing module, used for processing data according to the amount of the written data when writing data; The file deletion processing module is used to release the disk quota corresponding to the deleted file when the file is deleted; The file system unloading processing module is used to write the disk quota data into the file specified by the user for persistent storage when the file system is unloaded.
7. The device for supporting disk quotas in a user-mode file system framework according to claim 6, characterized in that: In the disk quota ID and disk quota setting module, in the process of setting the disk quota ID for the setting file or the setting directory, the disk quota ID is forwarded to the user-mode file system client for persistent storage.
8. The device for supporting disk quotas in a user-mode file system framework according to claim 7, characterized in that: In the data writing processing module, during the process of writing data, if the amount of the written data exceeds the disk quota of the new file, an EQUOTA error is returned; if the amount of the written data does not exceed the disk quota of the new file, the disk quota used for the written data is increased.
9. The device for supporting disk quotas in a user-mode file system framework according to claim 8, characterized in that: In the file deletion processing module, during the process of deleting files, the disk size is subtracted from the size of the deleted file to release the corresponding disk quota.
10. The device for supporting disk quotas in a user-mode file system framework according to claim 9, characterized in that: In the file system unloading processing module, during the process of unloading the file system, the file system is unloaded through the umount command, and the disk quota data is written into the file specified by the user for persistent storage.