File system locking method, device, equipment and medium

By using a modular lock-disarming design, which combines structural locks, module locks, and client locks, the system blocking problem caused by global mutex locks is solved, improving the concurrency and bandwidth performance of the file system.

CN115292057BActive Publication Date: 2025-10-28JINAN INSPUR DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210937738.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-05
Publication Date
2025-10-28
Estimated Expiration
2042-08-05

AI Technical Summary

Technical Problem

In multi-client or high-concurrency scenarios, the addition of global mutex locks by clients can lead to long system read/write times and low concurrency.

Method used

By employing a modular decoupling approach to differentiate the constraints of client locks, and through the combined use of structural locks, modular locks, and client locks, regional locking is performed based on the resource types involved in data block I/O operations, thereby narrowing the scope of mutex locks and improving system concurrency.

Benefits of technology

It reduces the blocking time caused by mutex locks, improves the read and write performance of the file system and the concurrency of data block operations, and indirectly improves the read and write bandwidth performance of files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115292057B_ABST
    Figure CN115292057B_ABST
Patent Text Reader

Abstract

This application discloses a locking method, apparatus, device, and medium for a file system, relating to the field of distributed file systems. The method includes: receiving a target I / O request; determining the type of the target requested resource in the current file system corresponding to the target I / O request; if the target requested resource is a file structure type, adding a structure lock to the structure corresponding to the target requested resource; if the target requested resource is an internal module resource type, adding a module lock to the module corresponding to the target requested resource; if the target requested resource is a globally shared resource type, adding a client lock to the data structure corresponding to the target requested resource; wherein the structure lock, module lock, and client lock are all mutex locks. This invention can differentiate the constraint force of client locks using a modular unlocking method, improving file read / write concurrency performance, reducing blocking phenomena caused by client locks, reducing read / write time, improving file system read / write performance, and indirectly improving file read / write bandwidth performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to distributed file systems, and particularly to a method, apparatus, device, and medium for locking a file system. Background Technology

[0002] In multi-client or high-concurrency scenarios, to ensure data consistency and security, global locking is implemented on the client side. For each data block I / O (Input / Output) operation, the client adds a mutex lock to prevent data from being contaminated by other threads or clients, thus ensuring data validity and consistency. The drawback is that after adding the client-side global mutex lock, other data block I / O operations can only synchronously wait for the lock to be released, causing long blocking times during system read and write operations, impacting concurrent operations and resulting in low bandwidth performance.

[0003] As can be seen from the above, how to avoid situations where the system read and write times are long and concurrency is low due to the client adding a global mutex lock is a problem that needs to be solved in this field. Summary of the Invention

[0004] In view of this, the purpose of this invention is to provide a file system locking method, apparatus, device, and medium that can differentiate the constraint force of client locks using a modular unlocking approach, improve file read / write concurrency performance, reduce blocking caused by client locks, reduce read / write time, improve file system read / write performance, increase the concurrency of data block operations, and indirectly improve file read / write bandwidth performance. The specific solution is as follows:

[0005] Firstly, this application discloses a file system locking method, including:

[0006] Receive the target I / O request and determine the type of the target requested resource in the current file system corresponding to the target I / O request;

[0007] If the target requested resource is a file structure type, then add a structure lock to the structure corresponding to the target requested resource;

[0008] If the target requested resource is an internal resource type of a module, then add a module lock to the module corresponding to the target requested resource;

[0009] If the target requested resource is a globally public resource type, then a client lock is added to the data structure corresponding to the target requested resource; wherein, the structure lock, the module lock, and the client lock are all mutex locks.

[0010] Optionally, adding a structure lock to the structure corresponding to the target requested resource includes:

[0011] Determine the inode number and structure name corresponding to the target requested resource;

[0012] The first target name is determined based on the index node number and the structure name, and using a preset structure lock naming rule;

[0013] Add a structure lock with the name of the first target to the structure corresponding to the target requested resource.

[0014] Optionally, adding a module lock to the module corresponding to the target requested resource includes:

[0015] Determine the inode number and module name corresponding to the target requested resource;

[0016] The second target name is determined based on the index node number and the module name, and using a preset module lock naming rule;

[0017] Add a module lock with the name of the second target to the module corresponding to the target requested resource.

[0018] Optionally, adding a structure lock to the structure corresponding to the target requested resource includes:

[0019] Add a structure lock to one or more of the following structures: inode structure, fh structure, dentry structure, and objectset structure, corresponding to the target requested resource.

[0020] Optionally, adding a module lock to the module corresponding to the target requested resource includes:

[0021] Add a module lock to one or more of the pre-read module, cache module, and direct read module corresponding to the target requested resource.

[0022] Optionally, adding a client lock to the data structure corresponding to the target requested resource includes:

[0023] Add a client lock to one or more data structures, such as arrays, linked lists, and queues, corresponding to the target requested resource.

[0024] Optionally, the file system locking method further includes:

[0025] When the target requested resource corresponds to multiple types among the file structure type, the module internal resource type, and the global public resource type, the target requested resource is locked and unlocked according to a preset locking and unlocking rule; wherein, the preset locking and unlocking rule includes the priority relationship between the structure lock, the module lock, and the client lock.

[0026] Secondly, this application discloses a file system locking device, comprising:

[0027] The type determination module is used to receive the target IO request and determine the type of the target requested resource in the current file system corresponding to the target IO request;

[0028] The structure lock adding module is used to add a structure lock to the structure corresponding to the target requested resource if the target requested resource is a file structure type.

[0029] The module lock addition module is used to add a module lock to the module corresponding to the target requested resource if the target requested resource is an internal resource type of the module.

[0030] A client lock adding module is used to add a client lock to the data structure corresponding to the target requested resource if the target requested resource is a globally public resource type; wherein the structure lock, the module lock, and the client lock are all mutex locks.

[0031] Thirdly, this application discloses an electronic device, comprising:

[0032] Memory, used to store computer programs;

[0033] A processor is used to execute the computer program to implement the aforementioned file system locking method.

[0034] Fourthly, this application discloses a computer storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the aforementioned disclosed file system locking method.

[0035] This application first receives a target I / O request and determines the type of the target requested resource in the current file system. If the target requested resource is a file structure, a structure lock is added to the structure corresponding to the target requested resource. If the target requested resource is an internal module resource, a module lock is added to the module corresponding to the target requested resource. If the target requested resource is a globally shared resource, a client lock is added to the data structure corresponding to the target requested resource. All structure locks, module locks, and client locks are mutexes. In this way, the present invention proposes the concepts of structure locks and module locks, refining and decomposing client locks based on data structures, operation steps, and internal module characteristics in the file system. This differentiates the constraints of existing client locks (i.e., client_lock), reduces the blocking impact of global client locks on high concurrency, and performs regional locking based on the resources involved in data block I / O operations. This narrows the scope of client lock mutexes, improves the system's concurrency capability, reduces blocking time caused by mutexes, increases the concurrency of data block operations, and indirectly improves the bandwidth performance of file read and write operations. Attached Figure Description

[0036] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0037] Figure 1 A flowchart of a file system locking method provided in this application;

[0038] Figure 2 A flowchart illustrating a specific file system locking method provided in this application;

[0039] Figure 3 A schematic diagram of a file system locking device provided in this application;

[0040] Figure 4 This is a schematic diagram of an electronic device structure provided in this application. Detailed Implementation

[0041] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0042] In existing technologies, in multi-client or high-concurrency scenarios, to ensure data consistency and security, global locking is implemented on the client side. For each data block I / O operation, the client adds a mutex lock to protect the data from contamination by other threads or clients, thus ensuring data validity and consistency. The drawback is that after adding the client-side global mutex lock, other data block I / O operations can only synchronously wait for the lock to be released, resulting in long blocking times during system read / write operations, affecting concurrent operations and reducing bandwidth performance. In this application, a modular unlocking approach can be used to differentiate the constraints of client-side locks, improving file read / write concurrency performance, reducing blocking caused by client-side locks, reducing read / write time, improving file system read / write performance, increasing the concurrency of data block operations, and indirectly improving file read / write bandwidth performance.

[0043] This invention discloses a file system locking method, see [link to relevant documentation]. Figure 1 The method includes:

[0044] Step S11: Receive the target IO request and determine the type of the target requested resource in the current file system corresponding to the target IO request.

[0045] In this embodiment, the file system is further subdivided based on its basic structure, operation steps, and internal characteristics of modules. Upon receiving a target IO request, the type of the target requested resource corresponding to the IO request is first determined. If the target requested resource involves the basic structure of the file system, it is determined to be a file structure type. If the target requested resource involves internal characteristics unique to a module in the file system, it is determined to be an internal resource type of the module. If the target requested resource involves the data structure of a public resource in the file system, it is determined to be a global public resource type.

[0046] Step S12: If the target requested resource is a file structure type, then add a structure lock to the structure corresponding to the target requested resource.

[0047] In this embodiment, if the target requested resource involves the basic structure of the file system, this step will add a structure lock to the structure related to file operations. The structure lock is used to manage file-related structure variables, has global constraints on the protected data, mainly constrains the basic structure of the file, and the control effect can achieve concurrency between I / O blocks within a file, while ensuring that different files do not affect each other.

[0048] In a specific implementation, the structure may include: inode, fh, dentry, and objectset. Specifically, each structure type corresponds to a structure lock, and the structure locks are mutually exclusive, non-nested, and independent. When the target I / O request requests resources targeting the inode, a structure lock is added to the inode structure to enable I / O concurrency between structures within the file.

[0049] In some specific implementations of this application, when metadata acquisition, viewing, and modification are performed during file reading, or when internal parameters of the inode structure are judged, a structure lock is added to the corresponding inode structure. When the file is read from the cache, a structure lock is added to the corresponding object set when the object location of the data segment is obtained in the objectcacher based on the read data fragment.

[0050] In this embodiment of the application, adding a structure lock to the structure corresponding to the target requested resource may include: determining the inode number and structure name corresponding to the target requested resource; determining a first target name based on the inode number and the structure name and using a preset structure lock naming rule; and adding a structure lock with the first target name to the structure corresponding to the target requested resource.

[0051] It is understood that in this embodiment of the application, when a structure lock is added to a structure, a corresponding name is added to the structure lock. In a specific implementation, the inode number (i.e., the inode number) and the structure name corresponding to the target requested resource can be determined, and then the name of the current structure lock can be determined in the form of inode number + structure name.

[0052] Step S13: If the target requested resource is an internal resource type of a module, then add a module lock to the module corresponding to the target requested resource.

[0053] In this embodiment, if the target requested resource involves unique internal characteristics of a module within the file system, this step adds a module lock to the module corresponding to the target requested resource. The module lock manages the unique structure data of the functional module, primarily handling the associations and dependencies between various functional modules. The module lock only manages data within its own module, constraining structures related to file operation functions. It does not constrain public resources or resources managed by the structure lock. This control effect allows module functional characteristics to be implemented concurrently within a file, without interfering with each other between different files.

[0054] In this embodiment, the module can be a pre-set functional module in the system, and each module has its own corresponding function. In specific implementations, the module can be set as a pre-read module, a cache module, a direct read module, etc. When the target IO request is a request for resources in the pre-read module, a module lock will be added to the pre-read module during data IO to enable IO concurrency between modules within the file.

[0055] In this embodiment of the application, adding a module lock to the module corresponding to the target requested resource may include: determining the inode number and module name corresponding to the target requested resource; determining a second target name based on the inode number and the module name and using a preset module lock naming rule; and adding a module lock to the module corresponding to the target requested resource with the second target name as the name.

[0056] It is understood that in this embodiment of the application, when a module lock is added to a structure, a corresponding name is added to the module lock. In a specific implementation, the inode number and module name corresponding to the target requested resource can be determined, and then the name of the current module lock can be determined in the form of inode number + module name.

[0057] Step S14: If the target requested resource is a globally public resource type, then add a client lock to the data structure corresponding to the target requested resource; wherein, the structure lock, the module lock, and the client lock are all mutex locks.

[0058] In this embodiment, if the target requested resource involves a data structure of a public resource in the file system, this step adds a client lock (client_lock) to the data structure corresponding to the target requested resource. The client_lock is used to manage public resources and also has global constraints. In specific implementations, the public resource may include data structures such as a map, list, lru (Least Recently Used) queue, array, or linked list.

[0059] In this embodiment, the structure lock, module lock, and client lock are all mutex locks, providing global constraints on the data they protect. It should be noted that in this embodiment, when adding the structure lock, module lock, and client lock, locking operations can be performed on the corresponding variables in specific implementations. Furthermore, in this embodiment, structure locks and module locks of the same type do not affect each other, are independent, and do not support nesting, achieving separation of structure management and reducing coupling; structure locks and module locks are also independent and do not nest, collaboratively managing and constraining functional modules.

[0060] It should be noted that the purpose of locking in this embodiment is to protect data resources from inconsistencies caused by multiple users / threads modifying the resources. Therefore, the lock can be unlocked after the relevant data operations are completed. The purpose of subsequent unlocking is to reduce the lock contention between data resources, reduce lock contention waiting, and increase the concurrency performance of system resources.

[0061] In this embodiment, a target IO request is first received, and the type of the target requested resource in the current file system corresponding to the target IO request is determined. If the target requested resource is a file structure type, a structure lock is added to the structure corresponding to the target requested resource. If the target requested resource is an internal module resource type, a module lock is added to the module corresponding to the target requested resource. If the target requested resource is a globally shared resource type, a client lock is added to the data structure corresponding to the target requested resource. The structure lock, module lock, and client lock are all mutex locks. In this way, the present invention proposes the concepts of structure locks and module locks, refining and decomposing client locks based on data structures, operation steps, and internal module characteristics in the file system. This differentiates the constraints of existing client locks, reduces the blocking impact of global client locks on high concurrency, and regionalizes locking based on the resources involved in data block IO operations. This narrows the scope of client lock mutexes, improves the system's concurrency capability, reduces blocking time caused by mutexes, increases the concurrency of data block operations, and indirectly improves the bandwidth performance of file read and write operations.

[0062] Figure 2 A flowchart illustrating a specific file system locking method provided in this application embodiment. See also... Figure 2 As shown, the method includes:

[0063] Step S21: Receive the target IO request and determine the type of the target requested resource in the current file system corresponding to the target IO request.

[0064] Step S22: If the target requested resource is a file structure type, then add a structure lock to one or more of the following structures: inode structure, fh structure, dentry structure, and objectset structure corresponding to the target requested resource.

[0065] In some preferred embodiments, when the target requested resource is a file structure type, a structure lock can be added to the inode structure, fh structure, dentry structure, and objectset structure.

[0066] Step S23: If the target requested resource is an internal resource type of a module, then add a module lock to one or more of the pre-read module, cache module, and direct read module corresponding to the target requested resource.

[0067] In some preferred embodiments, when the target requested resource is an internal resource type of the module, a module lock can be added to the pre-read module, the cache module, and the direct read module.

[0068] Step S24: If the target requested resource is a globally public resource type, then add a client lock to one or more data structures among the array, linked list, and queue corresponding to the target requested resource; wherein, the structure lock, the module lock, and the client lock are all mutex locks.

[0069] In some preferred embodiments, when the target requested resource is a global public resource type, client locks can be added to queues, arrays, or linked lists such as map, list, and lru in the public resource.

[0070] In this embodiment of the application, the file system locking method may further include: when the target requested resource corresponds to multiple types among the file structure type, the module internal resource type, and the global public resource type, locking and unlocking the target requested resource according to a preset locking and unlocking rule; wherein, the preset locking and unlocking rule includes the priority relationship between the structure lock, the module lock, and the client lock.

[0071] It should be noted that the target IO request described in this embodiment may correspond to multiple resource types. In this case, locking will be performed according to the priority of the resource types. In a specific implementation, the priority of the file structure type is higher than the priority of the internal resource type of the module, and the priority of the internal resource type of the module is higher than the priority of the global public resource type. Furthermore, when a resource has already been locked with a lower priority first lock, and a higher priority second lock needs to be added at the same time, the first lock will be unlocked first, then the second lock will be added, and then the first lock will be added again, to ensure that locking is performed sequentially according to the priority of the three locks.

[0072] For example, in a specific implementation, when the target I / O request involves the pre-read function in the pre-read module, if the target I / O request is a lookup of the inode number of a global resource, since it involves the inode structure in the file infrastructure, an inode_lock in the structure lock will be added before the lookup. After adding the inode_lock, if it then involves a global public resource, a client_lock needs to be added on top of the inode_lock; similarly, after adding the inode_lock, if it involves a public resource within the module, a pre-read lock in the module lock needs to be added on top of the inode_lock.

[0073] In this embodiment, a target I / O request is first received, and the type of the target requested resource in the current file system corresponding to the target I / O request is determined. If the target requested resource is a file structure type, a structure lock is added to one or more of the following structures: inode structure, fh structure, dentry structure, and objectset structure corresponding to the target requested resource. If the target requested resource is an internal module resource type, a module lock is added to one or more of the following modules: pre-read module, cache module, and direct read module corresponding to the target requested resource. If the target requested resource is a globally public resource type, a client lock is added to one or more data structures: array, linked list, and queue corresponding to the target requested resource; wherein, the structure lock, the module lock, and the client lock are all mutex locks. In this way, this embodiment differentiates the constraint of client_lock through a modular delocking design at the file granularity. It performs regional locking based on the functional modules involved in data block IO operations. When the target resource corresponds to multiple types, the locking and unlocking methods can be determined according to the priority of each lock in the preset locking and unlocking rules. The entire process of file system locking and unlocking proposed in this invention reduces the constraint of concurrent granularity of file operations, realizes concurrency between IO blocks, improves file concurrency performance, and reduces the blocking time caused by client_lock.

[0074] See Figure 3 As shown in the figure, this application discloses a file system locking device, which may specifically include:

[0075] The type determination module 11 is used to receive the target IO request and determine the type of the target requested resource in the current file system corresponding to the target IO request;

[0076] The structure lock adding module 12 is used to add a structure lock to the structure corresponding to the target requested resource if the target requested resource is a file structure type.

[0077] Module lock adding module 13 is used to add a module lock to the module corresponding to the target requested resource if the target requested resource is an internal resource type of the module;

[0078] The client lock adding module 14 is used to add a client lock to the data structure corresponding to the target requested resource if the target requested resource is a globally public resource type; wherein the structure lock, the module lock and the client lock are all mutex locks.

[0079] In this embodiment, a target IO request is first received, and the type of the target requested resource in the current file system corresponding to the target IO request is determined. If the target requested resource is a file structure type, a structure lock is added to the structure corresponding to the target requested resource. If the target requested resource is an internal module resource type, a module lock is added to the module corresponding to the target requested resource. If the target requested resource is a globally shared resource type, a client lock is added to the data structure corresponding to the target requested resource. The structure lock, module lock, and client lock are all mutex locks. In this way, the present invention proposes the concepts of structure locks and module locks, refining and decomposing client locks based on data structures, operation steps, and internal module characteristics in the file system. This differentiates the constraints of existing client locks, reduces the blocking impact of global client locks on high concurrency, and regionalizes locking based on the resources involved in data block IO operations. This narrows the scope of client lock mutexes, improves the system's concurrency capability, reduces blocking time caused by mutexes, increases the concurrency of data block operations, and indirectly improves the bandwidth performance of file read and write operations.

[0080] In some specific embodiments, the structure lock adding module 12 includes:

[0081] The first information determination unit is used to determine the index node number and structure name corresponding to the target requested resource;

[0082] The first name determination unit is used to determine the first target name based on the index node number and the structure name, and using a preset structure lock naming rule;

[0083] The first locking unit is used to add a structure lock with the name of the first target name to the structure corresponding to the target requested resource.

[0084] In some specific embodiments, the module lock adding module 13 includes:

[0085] The second information determination unit is used to determine the index node number and module name corresponding to the target requested resource;

[0086] The second name determination unit is used to determine the second target name based on the index node number and the module name, and using a preset module lock naming rule;

[0087] The second locking unit is used to add a module lock to the module corresponding to the target requested resource, with the name of the second target.

[0088] In some specific embodiments, the structure lock adding module 12 includes:

[0089] The structure lock adding unit is used to add a structure lock to one or more of the following structures: inode structure, fh structure, dentry structure, and objectset structure, corresponding to the target requested resource.

[0090] In some specific embodiments, the module lock adding module 13 includes:

[0091] The module lock adding unit is used to add a module lock to one or more of the pre-read module, cache module, and direct read module corresponding to the target requested resource.

[0092] In some specific embodiments, the client lock adding module 14 includes:

[0093] The client lock adding unit is used to add a client lock to one or more data structures, such as arrays, linked lists, and queues, corresponding to the target requested resource.

[0094] In some specific embodiments, the file system locking device further includes:

[0095] The locking and unlocking module is used to lock and unlock the target requested resource according to a preset locking and unlocking rule when the target requested resource corresponds to multiple types, including the file structure type, the module internal resource type, and the global public resource type; wherein the preset locking and unlocking rule includes the priority relationship between the structure lock, the module lock, and the client lock.

[0096] Furthermore, embodiments of this application also disclose an electronic device, Figure 4 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of use of this application.

[0097] Figure 4 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a display screen 24, an input / output interface 25, a communication interface 26, and a communication bus 27. The memory 22 stores a computer program, which is loaded and used by the processor 21 to implement the following steps:

[0098] Receive the target I / O request and determine the type of the target requested resource in the current file system corresponding to the target I / O request;

[0099] If the target requested resource is a file structure type, then add a structure lock to the structure corresponding to the target requested resource;

[0100] If the target requested resource is an internal resource type of a module, then add a module lock to the module corresponding to the target requested resource;

[0101] If the target requested resource is a globally public resource type, then a client lock is added to the data structure corresponding to the target requested resource; wherein, the structure lock, the module lock, and the client lock are all mutex locks.

[0102] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:

[0103] Determine the inode number and structure name corresponding to the target requested resource;

[0104] The first target name is determined based on the index node number and the structure name, and using a preset structure lock naming rule;

[0105] Add a structure lock with the name of the first target to the structure corresponding to the target requested resource.

[0106] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:

[0107] Determine the inode number and module name corresponding to the target requested resource;

[0108] The second target name is determined based on the index node number and the module name, and using a preset module lock naming rule;

[0109] Add a module lock with the name of the second target to the module corresponding to the target requested resource.

[0110] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:

[0111] Add a structure lock to one or more of the following structures: inode structure, fh structure, dentry structure, and objectset structure, corresponding to the target requested resource.

[0112] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:

[0113] Add a module lock to one or more of the pre-read module, cache module, and direct read module corresponding to the target requested resource.

[0114] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:

[0115] Add a client lock to one or more data structures, such as arrays, linked lists, and queues, corresponding to the target requested resource.

[0116] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:

[0117] When the target requested resource corresponds to multiple types among the file structure type, the module internal resource type, and the global public resource type, the target requested resource is locked and unlocked according to a preset locking and unlocking rule; wherein, the preset locking and unlocking rule includes the priority relationship between the structure lock, the module lock, and the client lock.

[0118] In this embodiment, the electronic device 20 can specifically be an electronic computer. The power supply 23 is used to provide operating voltage for the various hardware devices on the electronic device 20. The communication interface 26 can create a data transmission channel between the electronic device 20 and external devices. The communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here. The input / output interface 25 is used to acquire external input data or output data to the outside world. Its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0119] Furthermore, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk, or optical disk, etc. The resources stored on it can include an operating system 221, computer programs 222, and virtual machine data 223, etc. The virtual machine data 223 can include various types of data. The storage method can be temporary storage or permanent storage.

[0120] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the file system locking method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.

[0121] Furthermore, this application also discloses a computer-readable storage medium, which includes random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, magnetic disks, optical disks, or any other form of storage medium known in the art. When the computer program is executed by a processor, it implements the aforementioned file system locking method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0122] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatuses disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section. Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.

[0123] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0124] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0125] The above provides a detailed description of the file system locking method, apparatus, device, and storage medium provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A file system locking method, characterized in that, include: Receive the target I / O request and determine the type of the target requested resource in the current file system corresponding to the target I / O request; If the target requested resource is a file structure type, then add a structure lock to the structure corresponding to the target requested resource; If the target requested resource is an internal resource type of a module, then add a module lock to the module corresponding to the target requested resource; If the target requested resource is a globally public resource type, then a client lock is added to the data structure corresponding to the target requested resource; wherein, the structure lock, the module lock, and the client lock are all mutex locks; Adding a structure lock to the structure corresponding to the target requested resource includes: Add a structure lock to one or more of the following structures: inode structure, fh structure, dentry structure, and objectset structure, corresponding to the target requested resource; Adding a module lock to the module corresponding to the target requested resource includes: Add a module lock to one or more of the pre-read module, cache module, and direct read module corresponding to the target requested resource; Adding a client lock to the data structure corresponding to the target requested resource includes: Add a client lock to one or more data structures, such as arrays, linked lists, and queues, corresponding to the target requested resource; The file system locking method further includes: When the target requested resource corresponds to multiple types among the file structure type, the module internal resource type, and the global public resource type, the target requested resource is locked and unlocked according to a preset locking and unlocking rule; wherein, the preset locking and unlocking rule includes the priority relationship between the structure lock, the module lock, and the client lock.

2. The file system locking method according to claim 1, characterized in that, Adding a structure lock to the structure corresponding to the target requested resource includes: Determine the inode number and structure name corresponding to the target requested resource; The first target name is determined based on the index node number and the structure name, and using a preset structure lock naming rule; Add a structure lock with the name of the first target to the structure corresponding to the target requested resource.

3. The file system locking method according to claim 1, characterized in that, Adding a module lock to the module corresponding to the target requested resource includes: Determine the inode number and module name corresponding to the target requested resource; The second target name is determined based on the index node number and the module name, and using a preset module lock naming rule; Add a module lock with the name of the second target to the module corresponding to the target requested resource.

4. A file system locking device, characterized in that, include: The type determination module is used to receive the target IO request and determine the type of the target requested resource in the current file system corresponding to the target IO request; The structure lock adding module is used to add a structure lock to the structure corresponding to the target requested resource if the target requested resource is a file structure type. The module lock addition module is used to add a module lock to the module corresponding to the target requested resource if the target requested resource is an internal resource type of the module. A client lock adding module is used to add a client lock to the data structure corresponding to the target requested resource if the target requested resource is a globally public resource type; wherein, the structure lock, the module lock, and the client lock are all mutex locks; The structure lock adding module includes: The structure lock adding unit is used to add a structure lock to one or more of the following structures: inode structure, fh structure, dentry structure, and objectset structure, corresponding to the target requested resource. The module lock adding module includes: The module lock adding unit is used to add a module lock to one or more of the pre-read module, cache module, and direct read module corresponding to the target requested resource; The client lock adding module includes: A client lock adding unit is used to add a client lock to one or more data structures, such as an array, linked list, or queue, corresponding to the target requested resource. The file system locking device further includes: The locking and unlocking module is used to lock and unlock the target requested resource according to a preset locking and unlocking rule when the target requested resource corresponds to multiple types, including the file structure type, the module internal resource type, and the global public resource type; wherein the preset locking and unlocking rule includes the priority relationship between the structure lock, the module lock, and the client lock.

5. An electronic device, characterized in that, It includes a processor and a memory; wherein, when the processor executes a computer program stored in the memory, it implements the file system locking method as described in any one of claims 1 to 3.

6. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein, when the computer programs are executed by a processor, they implement the file system locking method as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Client lock splitting method based on distributed file system

    CN107633090A

  • A method and a device for realizing data consistency in a distributed file system

    CN109582658A