File system access method, apparatus, device, storage medium, and program product
By using version number consistency checks in the file system, directory backtracking is only performed when version numbers are inconsistent, thus solving the problem of low access efficiency caused by high directory depth and achieving efficient access processing.
Patent Information
- Application Number
- CN202611183801.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-05
- Publication Date
- 2026-11-20
AI Technical Summary
Traditional file systems suffer from low access and processing efficiency and high resource consumption when the directory depth is high, resulting in poor performance.
By responding to access requests in the file system, directory backtracking is performed based on the consistency between the version number of the target metadata and the global version number. Directory rules are only looked up when the version numbers are inconsistent; otherwise, the request is processed directly using the directory rule pointer, thus reducing unnecessary directory backtracking.
It improves access processing efficiency, reduces directory backtracking, lowers resource consumption, and enhances system performance.
Smart Images

Figure CN123138196A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of file system technology, and in particular to a file system access method, apparatus, device, storage medium and program product. Background Technology
[0002] A file system is a management system that organizes directories and files into a tree structure for managing and storing user file data. In various cloud service scenarios, file systems are a widely used data storage and management system. Typically, cloud services assign a directory to each cloud tenant. When providing services to cloud tenants, it's necessary to ensure that services between different cloud tenants do not interfere with each other, requiring corresponding rule information for each tenant. Therefore, directory rules need to be set for the directory. Through directory rules, the upper limit of resources used by a tenant can be restricted, ensuring that the usage of one tenant does not affect the resource usage of other tenants as much as possible.
[0003] In traditional techniques, rules can be set on directories. When accessing a subdirectory or a subdirectory of a subdirectory, the system can look up and back to find the directory with the nearest directory rule to the currently accessed directory or file. This way, the system can find the directory rule corresponding to the accessed directory or file.
[0004] However, if the directory depth of the file system is high, every read and write access to the directory requires directory backtracking, which results in low overall efficiency, high resource consumption, excessive system performance consumption and data processing latency, poor performance, and thus low access processing efficiency. Summary of the Invention
[0005] Therefore, it is necessary to provide a file system access method, apparatus, computer device, computer-readable storage medium, and computer program product that can improve access processing efficiency in response to the above-mentioned technical problems.
[0006] On one hand, this application provides a file system access method, comprising: responding to an access request from a target user for a target object in the file system, searching for target metadata corresponding to the target object based on a directory tree in the file system corresponding to the target user, wherein the target object is a directory or a file; if the target version number in the target metadata is inconsistent with the global version number of the directory tree, then performing directory backtracking on the directory tree starting from the target node corresponding to the target object, in order to search for a matching node whose metadata contains a rule entry marker from the target path determined based on the target node and the root node; if a matching node is found, searching for a directory rule set for the directory represented by the matching node from the directory rule record information to obtain a matching directory rule; if the target version number is consistent with the global version number and is not the initial version number, then obtaining the matching directory rule according to the directory rule pointer in the target metadata; and processing the access request according to the matching directory rule.
[0007] In this embodiment, in response to a target user's access request for a target object in the file system, the target metadata corresponding to the target object is searched based on the directory tree in the file system corresponding to the target user. The target object is a directory or file. If the target version number in the target metadata is inconsistent with the global version number of the directory tree, the directory tree is backtracked starting from the target node corresponding to the target object to find a matching node whose metadata contains a rule entry marker in the target path determined based on the target node and the root node. If a matching node is found, the directory rule set for the directory represented by the matching node is searched from the directory rule record information to obtain the matching directory rule. If the target version number is consistent with the global version number but is not the initial version number, the matching directory rule is obtained according to the directory rule pointer in the target metadata, and the access request is processed according to the matching directory rule. Therefore, when accessing a target object, directory backtracking is only performed when the target version number in the target metadata is inconsistent with the global version number. When they are consistent and the global version number is not the initial version number, the corresponding directory rule is directly found through the directory rule pointer in the target metadata. Thus, directory backtracking is not required for every access, reducing the workload of directory backtracking and improving access processing efficiency.
[0008] In some embodiments, the step of performing directory backtracking on the directory tree starting from the target node corresponding to the target object if the target version number in the target metadata is inconsistent with the global version number of the directory tree includes: if the target version number is the initial version number and the global version number is not the initial version number, then performing directory backtracking on the directory tree starting from the target node corresponding to the target object; if the target version number is not the initial version number and the target version number is inconsistent with the global version number, then performing directory backtracking on the directory tree starting from the target node corresponding to the target object; the method further includes: if both the target version number and the global version number are the initial version number, then performing the operation corresponding to the access request.
[0009] In this embodiment, if both the target version number and the global version number are the initial version number, it means that the target object currently has no matching directory rules. Therefore, executing the operation corresponding to the access request can ensure that the access request is processed normally and in a timely manner.
[0010] In some embodiments, the method further includes: when a matching node is found, pointing the directory rule pointer in the target metadata to the directory rule set for the directory represented by the matching node, and updating the target version number to the global version number.
[0011] In this embodiment, when a matching node is found, the directory rule pointer in the target metadata is set to the directory rule represented by the matching node. This allows the target object to be indirectly matched with the directory rule through the directory rule pointer. Updating the target version number to the global version number facilitates the direct retrieval of directory rules based on the target rule pointer in the target metadata in the next iteration, improving the efficiency of obtaining directory rules.
[0012] In some embodiments, the method further includes: if no matching node is found, updating the target version number to the global version number, initializing the directory rule pointer in the target metadata to a null pointer, and performing the operation corresponding to the access request.
[0013] In this embodiment, the target version number is updated to the global version number, and the directory rule pointer in the target metadata is initialized to a null pointer. This allows the target object to indicate that there is no matching directory rule when no matching directory rule exists, by updating the target version number and the target rule pointer.
[0014] In some embodiments, obtaining the matching directory rule based on the directory rule pointer in the target metadata includes: if the directory rule pointer in the target metadata is not a null pointer, then obtaining the directory rule pointed to by the directory rule pointer in the target metadata to obtain the matching directory rule; the method further includes: if the directory rule pointer in the target metadata is a null pointer, then performing the operation corresponding to the access request.
[0015] In this embodiment, if the directory rule pointer is not null, the matching directory rule can be quickly obtained according to the directory rule pointed to by the directory rule pointer, which improves the efficiency of obtaining the matching directory rule. If the directory rule pointer is null, the operation corresponding to the access request is executed, which can ensure that the access request is successfully processed.
[0016] In some embodiments, the method further includes at least one of the following: in response to a rule setting request for setting target directory rules for the target object, adding the target directory rule corresponding to the target object to the directory rule record information, adding a rule entry marker to the target metadata, and updating the global version number; or, in response to a rule deletion request for the target object, deleting the rule entry marker from the target metadata, deleting the target directory rule corresponding to the target object from the directory rule record information, and updating the global version number; or, in response to a rule modification request for the target object, modifying the target directory rule in the directory rule record information based on the rule modification content in the rule modification request, and updating the global version number.
[0017] In this embodiment, by updating the global version number, adding or deleting rule entry markers, or modifying the target directory rules in the directory rule record information, it is possible to set, delete, or modify directory rules, thereby improving the efficiency of managing directory rules.
[0018] In some embodiments, the step of searching for the directory rules set for the directory represented by the matching node from the directory rule record information includes: obtaining the identification information of the metadata in the matching node; searching for the directory rules corresponding to the identification information from the directory rule record information to obtain the directory rules set for the directory represented by the matching node.
[0019] In this embodiment, directory rules are managed by recording directory rules and the directory rules are searched based on the metadata identification information, which can improve the convenience and efficiency of obtaining and managing directory rules.
[0020] On the other hand, this application also provides a file system access device, including: a metadata lookup module, used to respond to an access request from a target user for a target object in the file system, and search for target metadata corresponding to the target object based on a directory tree in the file system corresponding to the target user, wherein the target object is a directory or a file; a first rule processing module, used to perform directory backtracking on the directory tree starting from the target node corresponding to the target object if the target version number in the target metadata is inconsistent with the global version number of the file system, so as to search for a matching node whose metadata contains a rule entry mark from the target path determined based on the target node and the root node, and if a matching node is found, search for the directory rule set for the directory represented by the matching node from the directory rule record information to obtain the matching directory rule; a second rule processing module, used to obtain the matching directory rule according to the directory rule pointer in the target metadata if the target version number is consistent with the global version number and is not the initial version number; and a request processing module, used to process the access request according to the matching directory rule.
[0021] On the other hand, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described file system access method.
[0022] On the other hand, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the above-described file system access method.
[0023] On the other hand, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps in the above-described file system access method.
[0024] The aforementioned file system access method, apparatus, computer device, computer-readable storage medium, and computer program product, in response to a target user's access request for a target object in the file system, search for the target metadata corresponding to the target object based on the directory tree in the file system corresponding to the target user. The target object is a directory or a file. If the target version number in the target metadata is inconsistent with the global version number of the directory tree, the directory tree is backtracked starting from the target node corresponding to the target object to find a matching node whose metadata contains a rule entry marker from the target path determined based on the target node and the root node. If a matching node is found, the directory rule set for the directory represented by the matching node is searched from the directory rule record information to obtain the matching directory rule. If the target version number is consistent with the global version number and is not the initial version number, the matching directory rule is obtained according to the directory rule pointer in the target metadata, and the access request is processed according to the matching directory rule. Therefore, when accessing a target object, directory backtracking is only performed if the target version number of the target metadata is inconsistent with the global version number. If they are consistent and the global version number is not the initial version number, the corresponding directory rule is found directly through the directory rule pointer in the target metadata. Thus, directory backtracking is not required for every access, reducing the workload of directory backtracking and improving access processing efficiency. Attached Figure Description
[0025] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 This is a diagram illustrating the application environment of a file system access method in one embodiment.
[0027] Figure 2 This is a flowchart illustrating a file system access method in one embodiment;
[0028] Figure 3 This is a schematic diagram of the file system directory tree structure in one embodiment;
[0029] Figure 4 This is a flowchart illustrating a file system access method in another embodiment;
[0030] Figure 5 This is a structural block diagram of a file system access device in one embodiment;
[0031] Figure 6 This is an internal structural diagram of a computer device in one embodiment;
[0032] Figure 7 This is a diagram of the internal structure of a computer device in another embodiment. Detailed Implementation
[0033] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0034] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.
[0035] The file system access method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on a cloud or other network server. Server 104 can be a storage node in a distributed storage system. The distributed storage system can be a system used to provide cloud services. In various cloud service scenarios, a file system is a widely used data storage management system. Typically, a cloud service provides a directory to a cloud tenant. When providing services to cloud tenants, it is necessary to ensure that services between different cloud tenants do not interfere with each other. This requires providing each tenant with corresponding rule information, such as the capacity of the directory used by each tenant, the IOPS (Input / Output Operations Per Second) for directory read / write operations, or the network bandwidth used. From the management interface, these rules are set for the cloud tenant; from the underlying file system perspective, the rules are actually set on the corresponding directory structure of the cloud tenant. Because the directory is a tree structure, there may be deeply nested subdirectories. When a user accesses a file or directory at the bottom level of the directory tree, it is necessary to ensure that the user can quickly, accurately, and efficiently match the corresponding rules. The file system access method provided in this application can be applied to cloud service scenarios to improve the processing efficiency of access requests in cloud service scenarios.
[0036] Specifically, terminal 102 can send an access request to server 104 for a target object in the file system. The file system is the file system in server 104. Server 104 searches for the target metadata corresponding to the target object in the directory tree of the file system. The target object is a directory or file. If the target version number in the target metadata is inconsistent with the global version number of the file system, server 104 starts from the target node corresponding to the target object and performs directory backtracking in the directory tree to find a matching node whose metadata contains a rule entry mark from the target path determined based on the target node and the root node. If a matching node is found, the server 104 searches for the directory rule set for the directory represented by the matching node in the directory rule record information to obtain the matching directory rule. If the target version number is consistent with the global version number and is not the initial version number, server 104 can obtain the matching directory rule according to the directory rule pointer in the target metadata. Server 104 can process the access request according to the matching directory rule. Server 104 can return the processing result of the access request to terminal 102.
[0037] Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, drones, low-altitude aircraft, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, and projection equipment. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted displays. Head-mounted displays can be virtual reality (VR) devices, augmented reality (AR) devices, and smart glasses. Server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0038] In one exemplary embodiment, such as Figure 2 As shown, a file system access method is provided. This method can be executed by a terminal or a server, or by both a terminal and a server. This method is applied to... Figure 1 Taking server 104 as an example, the following steps are included:
[0039] Step 202: In response to the target user's access request for a target object in the file system, search for the target metadata corresponding to the target object based on the directory tree in the file system corresponding to the target user. The target object is a directory or a file.
[0040] The target user can be a target tenant. The access request can be sent from the target tenant's terminal in the distributed storage system to the server. The target tenant can be any tenant in the distributed storage system or a cloud tenant. The access request can be a read request, a write request, or at least one of the read-write requests.
[0041] An object can be a directory or a file in the file system. The target object is the object being accessed, and therefore the target object is a directory or file in the file system. The access request can carry the object path of the target object, which refers to the location of the target object in the directory tree. For example, if the target object is a directory, the access request can carry the directory path; if the target object is a file, the access request can carry the file path (e.g., / tenant_A / data / logs / app.log).
[0042] Access requests can carry the target user's identity information. Based on this information, the directory tree corresponding to the target user can be determined from the file system. The target user has permission to access the directories and files represented by the nodes in the corresponding directory tree. Each node in the directory tree corresponds to (i.e., represents) a directory or file. The node corresponding to a directory can store metadata identification information (e.g., a unique key), which allows the directory's metadata to be found. The node corresponding to a file can also store metadata identification information (e.g., a unique key), which allows the file's metadata to be found. If the target object is a directory, the target metadata is the directory's metadata. If the target object is a file, the target metadata is the file's metadata. Metadata describes data and mainly records data attributes such as size, location, permissions, and other related information. Target metadata may include a version number and / or directory rule pointers, and the version number and directory rule pointers in the target metadata can be updated.
[0043] If the target object is a directory, it can have at least one subdirectory and / or parent directory. The node corresponding to the subdirectory is a child node of the node corresponding to the target object, and the node corresponding to the parent directory is the parent node of the node corresponding to the target object. For example... Figure 3 As shown, schematic diagrams of the directory tree structure are provided in some embodiments.
[0044] For example, the access request may carry the identity of the target tenant, and the server may store a tenant directory mapping table, which records the correspondence between the tenant's identity and the tenant's root directory. From the tenant directory mapping table, the root directory corresponding to the target tenant's identity is searched, and the target metadata corresponding to the target object is searched from the directory tree corresponding to that root directory (i.e., the directory tree corresponding to the target user), where the root node of the directory tree corresponding to the target user represents that root directory.
[0045] For example, the target node corresponding to the target object can be located in the directory tree based on the object path of the target object, and the target metadata corresponding to the target object can be obtained from the target node.
[0046] Step 204: If the target version number in the target metadata is inconsistent with the global version number of the directory tree, then start from the target node corresponding to the target object to backtrack the directory tree to find the matching node whose metadata contains the rule entry mark from the target path determined based on the target node and the root node. If a matching node is found, search for the directory rule set for the directory represented by the matching node from the directory rule record information to obtain the matching directory rule.
[0047] The target version number is the version number contained in the target metadata. The server can maintain a global version number for the directory tree corresponding to the target tenant. The initial value (i.e., the default value) of the global version number is the initial version number.
[0048] The global version number can increment from 0, so the initial version number can be 0. The global version number updates as directory rules are updated. Each update increments the global version number by 1. The global version number can be represented as `sysversion`. The global version number is unique within the directory tree and can only increment, not decrease. When any node in the directory tree represents an object whose directory rule is set (added), deleted, or modified, the global version number of the directory tree will increment.
[0049] If the target version number is the initial version number, it means that no directory rules have been set for the target object. If the global version number is the initial version number, it means that no directory rules have been set for the objects represented by any of the nodes in the directory tree. The starting point of the target path is the target node and its parent node, and the ending point is the root node in the directory tree.
[0050] There are two scenarios where the target version number and the global version number are inconsistent: One is that the target version number is the initial version number and the global version number is not the initial version number (i.e., the global version number is greater than the initial version number); the other is that the target version number is not the initial version number and the global version number is greater than the target version number. Therefore, if the target version number and the global version number are inconsistent, it indicates that the directory corresponding to the node on the target path may have directory rules set, and these rules can be found by tracing back through the directory.
[0051] Directory rule records are used to document the directory rules set for the directories represented by nodes in the directory tree. These directory rules can be indexed using the metadata identifiers within the nodes, allowing the retrieval of directory rules for the directory represented by a node from the directory rule records based on these identifiers. Directory rule records can be implemented using data structures such as linked lists or hash buckets, and are therefore also referred to as directory rule organization structures. For example, to improve efficiency, hash buckets can be preferred, as they are more efficient than linked lists. The metadata identifiers can be the metadata keys.
[0052] The target node represents the target object. The matching node represents a directory, and its metadata includes a rule entry tag. This rule entry tag can be added to the metadata of the matching node when setting directory rules for the object it represents. For directories with set directory rules, the corresponding node includes a rule entry tag. This tag indicates that directory rules have been set for that directory. Once a rule entry tag is identified, the corresponding directory rule can be found in the directory rule record information. For example, the corresponding directory rule can be found from the directory rule record information based on the metadata's identifier information.
[0053] Directory backtracking refers to searching upwards along directories or files, layer by layer, until a matching directory is found or the root directory of the file system is reached. Directory rules can include the directory size, as well as the IOPS and / or network bandwidth consumed by tenants' directory read / write operations. Directory rules can be set according to actual needs.
[0054] In the file system of this application embodiment, for directories and files without set directory rules, only the directory rules set by the directory closest to the top of the path are effective / valid. Thus, for example, traversing the directory tree from the target node corresponding to the target object includes: traversing the nodes in the target path from the target node's parent node to the root node along the direction from the target node to the root node; for the current node being traversed, if the metadata of the current node contains a rule entry marker, then traversal stops and the current node is taken as the matching node; if the metadata of the current node does not contain a rule entry marker, then traversal continues; if when traversing to the root node, the metadata of the root node also does not contain a rule entry marker, then it is determined that no matching node was found.
[0055] In related technologies, when creating directory rules, all subdirectories and files under the directory can be traversed, and rules can be created separately for each subdirectory and file. This approach requires traversing all subdirectories and files during creation, deletion, and modification, and also requires creating rules for newly created subdirectories or files within the directory or subdirectories. Creating, deleting, and modifying directory rules all require traversing existing directories and files under the directory. Especially when exceptions occur during directory or file processing, rollback and other exception handling are required, resulting in high processing logic complexity. Subsequent creation of new directories under the directory also requires adding rules, involving multiple processing logics and branches, making the functionality complex and prone to errors.
[0056] Based on this, in an exemplary embodiment, the method further includes at least one of the following: in response to a rule setting request for setting target directory rules for a target object, adding a target directory rule corresponding to the target object to the directory rule record information, adding a rule entry marker to the target metadata, and updating the global version number; or, in response to a rule deletion request for a target object, deleting the rule entry marker from the target metadata, deleting the target directory rule corresponding to the target object to the directory rule record information, and updating the global version number; or, in response to a rule modification request for a target object, modifying the target directory rule in the directory rule record information based on the rule modification content in the rule modification request, and updating the global version number.
[0057] When the target object is a directory, directory rules can be set for the target object. "Update global version number" can increment the global version number; for example, if the global version number was 0 before the update, the global version number can be 1 after the update.
[0058] In this embodiment, by updating the global version number, adding or deleting rule entry markers, or modifying the target directory rules in the directory rule record information, it is possible to set, delete, or modify directory rules, thereby improving the efficiency of managing directory rules.
[0059] In an exemplary embodiment, the method further includes: if a matching node is found, pointing the directory rule pointer in the target metadata to the directory rule set for the directory represented by the matching node, and updating the target version number to the global version number.
[0060] In this embodiment, when a matching node is found, the directory rule pointer in the target metadata is set to the directory rule represented by the matching node. This allows the target object to be indirectly matched with the directory rule through the directory rule pointer. Updating the target version number to the global version number facilitates the direct retrieval of directory rules based on the target rule pointer in the target metadata in the next iteration, improving the efficiency of obtaining directory rules.
[0061] Step 206: If the target version number is the same as the global version number and is not the initial version number, then obtain the matching directory rule based on the directory rule pointer in the target metadata.
[0062] The target metadata includes a directory rule pointer. If the directory rule pointer is null, it means that there is no matching directory rule for the target object. If the directory rule pointer is not null, it means that the directory rule pointer points to the directory rule that matches the target object (i.e., the matching directory rule).
[0063] If the target version number is the same as the global version number and neither the target version number nor the global version number is the initial version number, it means that the directory rule pointer in the target metadata has been updated to the latest state, and the matching directory rule can be determined based on the directory rule pointer in the target metadata.
[0064] For example, if the target version number is the same as the global version number but is not the initial version number, and the directory rule pointer in the target metadata is not a null pointer, then the directory rule pointed to by the directory rule pointer in the target metadata is obtained to get the matching directory rule.
[0065] In an exemplary embodiment, obtaining a matching directory rule based on a directory rule pointer in the target metadata includes: if the directory rule pointer in the target metadata is not a null pointer, then obtaining the directory rule pointed to by the directory rule pointer in the target metadata to obtain a matching directory rule; the method further includes: if the directory rule pointer in the target metadata is a null pointer, then performing the operation corresponding to the access request.
[0066] In this embodiment, if the directory rule pointer is not null, the matching directory rule can be quickly obtained according to the directory rule pointed to by the directory rule pointer, which improves the efficiency of obtaining the matching directory rule. If the directory rule pointer is null, the operation corresponding to the access request is executed, which can ensure that the access request is successfully processed.
[0067] For example, if the target metadata contains a rule entry marker, the directory rule set for the target object is searched from the directory rule record information based on the identification information of the target metadata to obtain the matching directory rule. If the target metadata does not contain a rule entry marker, the steps after step 202 are executed.
[0068] Step 208: Process the access request according to the matching directory rules.
[0069] Specifically, the operation corresponding to the access request can be executed or denied based on the matching directory rules. For example, if the matching directory rule is "read-only" and the access request is a write request, the access request is denied; if the matching directory rule is "read-only" and the access request is a read request, the read operation is executed. If the matching directory rule is "read-write" and the access request is a read / write request, the read / write operation is executed.
[0070] In the aforementioned file system access method, in response to a target user's access request for a target object in the file system, the target metadata corresponding to the target object is searched based on the directory tree corresponding to the target user in the file system. The target object is either a directory or a file. If the target version number in the target metadata is inconsistent with the global version number of the directory tree, the directory tree is backtracked starting from the target node corresponding to the target object to find a matching node whose metadata contains a rule entry marker in the target path determined based on the target node and the root node. If a matching node is found, the directory rule set for the directory represented by the matching node is searched from the directory rule record information to obtain the matching directory rule. If the target version number is consistent with the global version number but is not the initial version number, the matching directory rule is obtained according to the directory rule pointer in the target metadata, and the access request is processed according to the matching directory rule. Therefore, when accessing a target object, directory backtracking is only performed when the target version number in the target metadata is inconsistent with the global version number. When they are consistent and the global version number is not the initial version number, the corresponding directory rule is directly found through the directory rule pointer in the target metadata. Thus, directory backtracking is not required for every access, reducing the workload of directory backtracking and improving access processing efficiency.
[0071] In an exemplary embodiment, if the target version number in the target metadata is inconsistent with the global version number of the directory tree, then the directory tree is traced back from the target node corresponding to the target object. This includes: if the target version number is the initial version number and the global version number is not the initial version number, then the directory tree is traced back from the target node corresponding to the target object; if the target version number is not the initial version number and the target version number is inconsistent with the global version number, then the directory tree is traced back from the target node corresponding to the target object. The method further includes: if both the target version number and the global version number are initial version numbers, then the operation corresponding to the access request is executed.
[0072] For example, if both the target version number and the global version number are the initial version number, then update the target version number (i.e., still set it to the initial version number), set the directory rule pointer in the target metadata to a null pointer, and perform the operation corresponding to the access request (e.g., read / write operation).
[0073] In this embodiment, if both the target version number and the global version number are the initial version number, it means that the target object currently has no matching directory rules. Therefore, executing the operation corresponding to the access request can ensure that the access request is processed normally and in a timely manner.
[0074] In an exemplary embodiment, the method further includes: if no matching node is found, updating the target version number to the global version number, setting the directory rule pointer in the target metadata to a null pointer, and performing the operation corresponding to the access request.
[0075] If no matching node is found, it means that there is no matching directory rule for the target object.
[0076] In this embodiment, the target version number is updated to the global version number, and the directory rule pointer in the target metadata is initialized to a null pointer. This allows the target object to indicate that there is no matching directory rule when no matching directory rule exists, by updating the target version number and the target rule pointer.
[0077] In an exemplary embodiment, searching for the directory rules set for the directory represented by the matching node from the directory rule record information includes: obtaining the identification information of the metadata in the matching node; searching for the directory rules corresponding to the identification information from the directory rule record information to obtain the directory rules set for the directory represented by the matching node.
[0078] The directory rule record information records the directory rules set for the directories represented by nodes in the directory tree. The directory rules in the directory rule record information can use the identification information of the metadata in the node as an index, so that the directory rules set for the directory represented by the node can be found in the directory rule record information based on the identification information of the metadata in the node.
[0079] In this embodiment, directory rules are managed by recording directory rules and the directory rules are searched based on the metadata identification information, which can improve the convenience and efficiency of obtaining and managing directory rules.
[0080] In one exemplary embodiment, such as Figure 4 As shown, a file system access method is provided, including:
[0081] 1. When there is data I / O that needs to read or write a directory or file (i.e., when an access request for the target object is received), the target object's metadata (i.e., target metadata) is first located. If the sysversion (i.e., target version number) on the target metadata is 0, the target metadata may be loaded into the system memory for the first time. It needs to be compared with the global sysversion (i.e., global version number). If they are equal, i.e., the global sysversion value is 0, it means that there are currently no directory rules and no directory rule-based matching is required. If the global sysversion is not 0, it means that the target metadata is being used for the first time and a directory backtracking is required.
[0082] 2. When performing directory backtracking, if the metadata containing the rule entry mark is not found when backtracking to the root directory of the file system, it means that there is no directory rule that restricts access to the target object on the full path of the target object. The target object does not need to match the directory rule. Then, update the sysversion on the target metadata to the global sysversion and set the directory rule pointer on the target metadata to NULL (i.e., null pointer).
[0083] 3. When performing directory backtracking, if the metadata of a directory contains a rule entry marker, the key value of the metadata of the found directory is used to search for the corresponding directory rule in the directory rule organization structure. The rule pointer of the target object's metadata is then set to the found directory rule, and the sysversion value in the target object's metadata is updated to the global sysversion, so that the target object matches the directory rule.
[0084] 4. When data I / O needs to read or write the target object, the target metadata of the target object needs to be found first. If the sysversion of the target metadata is not 0, the target metadata is not loaded into the system memory for the first time. The sysversion of the target metadata is directly compared with the global sysversion. If they are consistent and the directory rule pointer of the target metadata is NULL, it means that the target object has no matching directory rule. If the directory rule pointer in the target metadata is not NULL, the corresponding directory rule is found directly according to the directory rule pointer in the target metadata and matched. If the sysversion of the target metadata is inconsistent with the global sysversion, directory backtracking is required, as in steps 2 and 3.
[0085] The default value of the system-wide sysversion is 0. The global sysversion changes with the directory rules and increases monotonically, never decreasing.
[0086] The file system access method provided in this application uses pointers to directory rules in the metadata. These pointers point to the directory rule closest to the target object. A global sysversion is used to indicate whether a directory rule has changed. The validity of the metadata rule is determined by comparing the global sysversion with the sysversion in the metadata. By comparing the global sysversion with the sysversion in the directory rule metadata, directory backtracking is reduced. Using a global sysversion mechanism to determine if a directory rule has changed, and using directory rule pointers to point to directory rules in the metadata, directory backtracking is reduced, the efficiency of directory rule activation is improved, and resource consumption is reduced. Since directory backtracking only occurs when the directory rule in the target metadata is invalid (i.e., when the target version number is inconsistent with the global version number), directory backtracking is reduced, and I / O processing efficiency is improved.
[0087] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0088] Based on the same inventive concept, this application also provides a file system access apparatus for implementing the file system access method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more file system access apparatus embodiments provided below can be found in the limitations of the file system access method described above, and will not be repeated here.
[0089] In one exemplary embodiment, such as Figure 5 As shown, a file system access device is provided, including: a metadata lookup module 502, a first rule processing module 504, a second rule processing module 506, and a request processing module 508, wherein:
[0090] Metadata lookup module 502 is used to respond to a target user's access request for a target object in the file system, and to look up the target metadata corresponding to the target object based on the directory tree in the file system corresponding to the target user. The target object is a directory or a file.
[0091] The first rule processing module 504 is used to perform directory backtracking on the directory tree starting from the target node corresponding to the target object if the target version number in the target metadata is inconsistent with the global version number of the directory tree. This is done to find a matching node in the target path determined based on the target node and the root node whose metadata contains the rule entry mark. If a matching node is found, the directory rule set for the directory represented by the matching node is found in the directory rule record information to obtain the matching directory rule.
[0092] The second rule processing module 506 is used to obtain the matching directory rule based on the directory rule pointer in the target metadata if the target version number is the same as the global version number and is not the initial version number.
[0093] The request processing module 508 is used to process access requests according to the matching directory rules.
[0094] In some embodiments, the first rule processing module 504 is further configured to: if the target version number is the initial version number and the global version number is not the initial version number, then perform directory backtracking on the directory tree starting from the target node corresponding to the target object; if the target version number is not the initial version number and the target version number is inconsistent with the global version number, then perform directory backtracking on the directory tree starting from the target node corresponding to the target object; the device further includes a third request processing module, which is configured to: if both the target version number and the global version number are initial version numbers, then perform the operation corresponding to the processing access request.
[0095] In some embodiments, the first rule processing module 504 is further configured to, when a matching node is found, point the directory rule pointer in the target metadata to the directory rule set for the directory represented by the matching node, and update the target version number to the global version number.
[0096] In some embodiments, the first rule processing module 504 is further configured to update the target version number to the global version number, initialize the directory rule pointer in the target metadata to a null pointer, and perform the operation corresponding to the access request if no matching node is found.
[0097] In some embodiments, the second rule processing module 506 is further configured to: if the directory rule pointer in the target metadata is not a null pointer, obtain the directory rule pointed to by the directory rule pointer in the target metadata and obtain the matching directory rule; if the directory rule pointer in the target metadata is a null pointer, execute the operation corresponding to the access request.
[0098] In some embodiments, the apparatus further includes a rule maintenance module, which is configured to perform at least one of the following: in response to a rule setting request for setting target directory rules for a target object, add a target directory rule corresponding to the target object to the directory rule record information, add a rule entry marker to the target metadata, and update the global version number; or, in response to a rule deletion request for a target object, delete the rule entry marker from the target metadata, delete the target directory rule corresponding to the target object to the directory rule record information, and update the global version number; or, in response to a rule modification request for a target object, modify the target directory rule in the directory rule record information based on the rule modification content in the rule modification request, and update the global version number.
[0099] In some embodiments, the first rule processing module 504 is further configured to obtain the identification information of the metadata in the matching node; search for the directory rule corresponding to the identification information from the directory rule record information, and obtain the directory rule set for the directory represented by the matching node.
[0100] Each module in the aforementioned file system access device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can invoke and execute the operations corresponding to each module.
[0101] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores at least a portion of the data involved in the file system access method. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a file system access method.
[0102] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 7As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a file system access method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0103] Those skilled in the art will understand that Figure 6 and Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0104] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0105] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0106] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0107] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0108] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0109] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0110] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A file system access method, characterized in that, The method includes: In response to a target user’s access request for a target object in the file system, the target metadata corresponding to the target object is searched based on the directory tree in the file system corresponding to the target user, where the target object is a directory or a file; If the target version number in the target metadata is inconsistent with the global version number of the directory tree, then the directory tree is traced back from the target node corresponding to the target object to find a matching node whose metadata contains a rule entry mark from the target path determined based on the target node and the root node. If a matching node is found, the directory rule set for the directory represented by the matching node is found from the directory rule record information to obtain the matching directory rule. If the target version number is the same as the global version number and is not the initial version number, then the matching directory rule is obtained according to the directory rule pointer in the target metadata; The access request is processed according to the matching directory rules.
2. The method according to claim 1, characterized in that, If the target version number in the target metadata is inconsistent with the global version number of the directory tree, then a directory backtracking is performed on the directory tree starting from the target node corresponding to the target object, including: If the target version number is the initial version number and the global version number is not the initial version number, then the directory tree is traced back from the target node corresponding to the target object; If the target version number is not the initial version number and the target version number is inconsistent with the global version number, then the directory tree is traced back from the target node corresponding to the target object; The method further includes: If both the target version number and the global version number are the initial version number, then the operation corresponding to the access request is executed.
3. The method according to claim 1, characterized in that, The method further includes: If a matching node is found, the directory rule pointer in the target metadata is set to the directory rule set for the directory represented by the matching node, and the target version number is updated to the global version number.
4. The method according to claim 1, characterized in that, The method further includes: If no matching node is found, the target version number is updated to the global version number, the directory rule pointer in the target metadata is set to a null pointer, and the operation corresponding to the access request is executed.
5. The method according to any one of claims 1 to 4, characterized in that, The step of obtaining the matching directory rule based on the directory rule pointer in the target metadata includes: If the directory rule pointer in the target metadata is not a null pointer, then the directory rule pointed to by the directory rule pointer in the target metadata is obtained to get the matching directory rule; The method further includes: If the directory rule pointer in the target metadata is a null pointer, then the operation corresponding to the access request is executed.
6. The method according to any one of claims 1 to 4, characterized in that, The method further includes at least one of the following: In response to a rule setting request for setting target directory rules for the target object, the target directory rule corresponding to the target object is added to the directory rule record information, a rule entry marker is added to the target metadata, and the global version number is updated; or, In response to a rule deletion request for the target object, the rule entry tag is deleted from the target metadata, the target directory rule corresponding to the target object is deleted from the directory rule record information, and the global version number is updated; or, In response to a rule modification request for the target object, the target directory rule in the directory rule record information is modified based on the rule modification content in the rule modification request, and the global version number is updated.
7. The method according to any one of claims 1 to 4, characterized in that, The step of searching the directory rules set for the directory represented by the matching node from the directory rule record information includes: Obtain the identification information of the metadata in the matching node; Search the directory rules corresponding to the identification information in the directory rule record information to obtain the directory rules set for the directory represented by the matching node.
8. A file system access device, characterized in that, The device includes: The metadata lookup module is used to respond to a target user's access request for a target object in the file system, and to look up the target metadata corresponding to the target object based on the directory tree in the file system corresponding to the target user, wherein the target object is a directory or a file; The first rule processing module is used to perform directory backtracking on the directory tree starting from the target node corresponding to the target object if the target version number in the target metadata is inconsistent with the global version number of the directory tree. This is to search for a matching node whose metadata contains a rule entry mark in the target path determined based on the target node and the root node. If a matching node is found, the module searches for the directory rule set for the directory represented by the matching node in the directory rule record information to obtain the matching directory rule. The second rule processing module is used to obtain the matching directory rule based on the directory rule pointer in the target metadata if the target version number is consistent with the global version number and is not the initial version number. The request processing module is used to process the access request according to the matching directory rules.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
