Quota statistical method and device for distributed file storage and medium
By using the local metadata lock mechanism on the metadata service side, the problem of inaccurate calculation of quota changes in distributed file storage systems under multi-client concurrent access is solved, and the accurate calculation and update of quota changes is achieved.
Patent Information
- Application Number
- CN202411375952.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2024-12-06
AI Technical Summary
When multiple clients access the same file concurrently, traditional distributed file storage systems may have problems with inaccurate calculation of quota changes.
By using the local metadata lock mechanism on the metadata service side, we ensure the accurate calculation of the file quota changes, and the calculation and update of the quota changes are performed during interaction between the protocol access layer and the metadata service.
When multiple protocol accesses are concurrently accessed from the access layer, the accuracy of the calculation of file quota changes is ensured, and quota statistics delays and calculation errors are avoided.
Smart Images

Figure CN119088320A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of distributed storage technology, and in particular to a quota statistics method, device and medium for distributed file storage. Background Art
[0002] Quotas are a disk space management mechanism, which are divided into space quotas and file number quotas. Space quotas limit space usage, while file number quotas limit the maximum number of files in a directory. The main purpose of quotas is to ensure that all users have their own exclusive file system space, thereby ensuring fairness and security in the use of the system by users. After configuring the quota, the distributed file system needs to count the space usage or number of files in the directory in real time. If it is greater than the quota configured by the user, the user's write request will be returned as failed to prevent a single user from excessively occupying system resources.
[0003] In related technologies, the solutions for implementing quotas mainly include: doing quota statistics through the metadata service (MDS) background, and doing statistics through memory cache plus quota logs. However, the first solution requires the background to update the statistical values to the upper directory layer by layer, which has a large delay. The second solution relies on the protocol access layer to add a file metadata write lock through the file lock server to ensure the accuracy of the quota increment calculated by the protocol access layer. As a result, when multiple clients access the same file concurrently, there is a problem that the protocol layer may not be able to accurately calculate the exact quota change.
[0004] Therefore, technicians in this field now urgently need a quota statistics method for distributed file storage to solve the above problems. Summary of the invention
[0005] The purpose of the present invention is to provide a quota statistics method, device and medium for distributed file storage to solve the problem of inaccurate quota change calculation when multiple clients concurrently access the same file in the traditional solution.
[0006] In order to solve the above technical problems, the present invention provides a quota statistics method for distributed file storage, which is applied to the metadata service side, including:
[0007] When receiving a metadata query request sent by the protocol access layer, returning metadata of the target file to the corresponding protocol access layer;
[0008] When receiving the file size after access sent by the protocol access layer, locking the metadata of the target file through a local metadata lock; wherein the file size after access is determined by the protocol access layer according to the file size in the metadata of the target file and the file size in the file access request;
[0009] Determine a file quota change amount according to the file size after access and the file size in the metadata of the target file;
[0010] Update the metadata of the target file according to the size of the file after access;
[0011] Unlocks the metadata of the target file.
[0012] In a possible embodiment, after determining the file quota change, the method further includes:
[0013] Writing the metadata and quota log of the target file into a metadata service log; wherein the quota log includes the file quota change amount and the quota number corresponding to the file quota change amount;
[0014] The method further comprises:
[0015] When the metadata service background performs log cleaning optimization, the file metadata and the quota log are flushed to disk; wherein, when the quota log is flushed to disk, a write request sent to the storage pool includes a plurality of the quota logs.
[0016] In order to solve the above technical problems, the present invention also provides a quota statistics method for distributed file storage, which is applied to the protocol access layer side, and includes:
[0017] When receiving a file access request, sending a metadata query request for the target file to the metadata service;
[0018] Determine the size of the file after access according to the file size in the metadata of the target file returned by the metadata service and the file size in the file access request;
[0019] The accessed file size is sent to the metadata service so that the metadata service can: determine the file quota change according to the accessed file size and the file size in the target file metadata, and update the target file metadata according to the accessed file size; wherein, when the metadata service receives the accessed file size sent by any of the protocol access layers, it locks the target file metadata through a local metadata lock, and unlocks the target file metadata after the target file metadata is updated.
[0020] In a possible embodiment, after sending the accessed file size to the metadata service, the method further includes:
[0021] If a response returned by the metadata service is received, writing the file quota change in the response into the local cache;
[0022] The file quota change is reported to the quota service through a background task, so that the quota service: updates the quota usage in the memory according to the file quota change; and persists the quota usage to the storage pool according to a preset first period timing.
[0023] In a possible embodiment, the method further includes: reporting heartbeat information to the quota service according to a preset second period, so that the quota service:
[0024] Determining whether the protocol access layer is faulty according to the heartbeat information;
[0025] If so, then obtain the quota usage stored in the storage pool at the start time of the current counting cycle of the logical clock; wherein the logical clock is a clock signal maintained inside the distributed storage system, and the count value of the logical clock is increased by one after each counting cycle;
[0026] Acquire the quota log recorded by the storage pool in the current counting period, and filter to obtain the quota log related to the faulty protocol access layer;
[0027] Determine, according to the quota log related to the faulty protocol access layer, the file quota change amount of the faulty protocol access layer in the current counting period;
[0028] The file quota change amount of the faulty protocol access layer at the time of the fault is restored according to the quota usage at the start time of the counting cycle and the file quota change amount of the faulty protocol access layer in the current counting cycle.
[0029] In a possible embodiment, the quota log is written into the storage pool by the metadata service, and the quota logs written in the same counting period are aggregated and stored in the storage pool according to the counting period of the logical clock;
[0030] Then the step of obtaining the quota log recorded by the storage pool in the current counting period and filtering to obtain the quota log related to the faulty protocol access layer includes:
[0031] Obtaining all the quota logs recorded by the storage pool in the current counting period;
[0032] The quota log is filtered to retain only the quota log corresponding to the faulty protocol access layer.
[0033] In a possible embodiment, before determining the size of the file after access according to the file size in the metadata of the target file returned by the metadata service and the file size in the file access request, the method further includes:
[0034] Sending a pre-application quota request to the quota service; wherein the pre-application quota request includes: the quota number and the pre-application quota amount;
[0035] receiving the pre-allocated quota amount returned by the quota service, and recording the pre-allocated quota amount in a memory; wherein, if the remaining amount of quota in the quota service is greater than the pre-applied quota amount, then the pre-allocated quota amount is greater than the pre-applied quota amount;
[0036] When the file access request is received next time, if the file quota change is less than the pre-allocated quota, the pre-allocated quota is updated according to the file quota change returned by the metadata service, and the pre-application quota request is stopped from being sent to the quota service.
[0037] In order to solve the above technical problems, the present invention further provides a quota statistics device for distributed file storage, which is applied to the metadata service side and includes:
[0038] A metadata response module, configured to return metadata of a target file to the corresponding protocol access layer upon receiving a metadata query request sent by the protocol access layer;
[0039] A metadata lock module, configured to lock the metadata of the target file through a local metadata lock when receiving the file size after access sent by the protocol access layer; wherein the file size after access is determined by the protocol access layer according to the file size in the metadata of the target file and the file size in the file access request;
[0040] A quota calculation module, used to determine a file quota change amount according to the file size after the access and the file size in the metadata of the target file;
[0041] A metadata updating module, used for updating the metadata of the target file according to the size of the file after the access;
[0042] The metadata unlocking module is used to unlock the metadata of the target file.
[0043] In order to solve the above technical problems, the present invention also provides a quota statistics device for distributed file storage, which is applied to the protocol access layer side, and includes:
[0044] The metadata query module is used to send a metadata query request for a target file to the metadata service when receiving a file access request;
[0045] A file size calculation module, used to determine the size of the file after access according to the file size in the metadata of the target file returned by the metadata service and the file size in the file access request;
[0046] The file size response module is used to send the post-access file size to the metadata service so that the metadata service can: determine the file quota change according to the post-access file size and the file size in the target file metadata, and update the metadata of the target file according to the post-access file size; wherein, when the metadata service receives the post-access file size sent by any of the protocol access layers, it locks the metadata of the target file through a local metadata lock, and unlocks the metadata of the target file after the metadata of the target file is updated.
[0047] To solve the above technical problem, the present invention further provides a non-volatile storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the quota statistics method for distributed file storage as described above are implemented.
[0048] The present invention provides a quota statistics method for distributed file storage, which realizes the calculation of file quota changes through the interaction between the protocol access layer and the metadata service. In this method, the calculation of file quota changes is performed in the metadata service. When clients access files concurrently, that is, when multiple protocol access layers update the file size of the same file to the metadata service at the same time, the metadata service uses a local metadata lock to lock the metadata of the target file. Compared with the file metadata lock function provided by the file lock server, the local metadata lock of the metadata service does not have the problem of only allowing one protocol access layer to access at the same time, so that the calculation of file quota changes can still be accurate when multiple protocol access layers access concurrently.
[0049] The quota statistics device for distributed file storage and the non-volatile storage medium provided by the present invention correspond to the above method and have the same effect as above. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0051] FIG1 is a logical architecture diagram of a distributed file system provided by an embodiment of the present invention;
[0052] FIG2 is a logical architecture diagram of a first common quota statistics solution provided by an embodiment of the present invention;
[0053] FIG3 is a flow chart of a second common quota statistics solution provided by an embodiment of the present invention;
[0054] FIG4 is a schematic diagram of a concurrent access scenario of a second common quota statistics solution provided by an embodiment of the present invention;
[0055] 5 is a flow chart of a quota statistics method for distributed file storage applied to a metadata service side provided by an embodiment of the present invention;
[0056] 6 is a flow chart of a quota statistics method for distributed file storage applied to a metadata service side provided by an embodiment of the present invention;
[0057] FIG7 is a schematic diagram of a concurrent access scenario of a quota statistics method for distributed file storage provided by an embodiment of the present invention;
[0058] FIG8 is a flow chart of a quota statistics method for distributed file storage provided by an embodiment of the present invention;
[0059] FIG. 9 is a flow chart of a fault handling solution provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0060] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. 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 creative work are within the scope of protection of the present invention.
[0061] The core of the present invention is to provide a quota statistics method, device and medium for distributed file storage.
[0062] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0063] In the application of distributed file system (ceph), a quota management scheme is proposed to ensure fairness and security of users' use of the system. Quota is a disk space management mechanism, which is divided into space quota and file number quota. Space quota limits space occupancy, and file number quota limits the maximum number of files under a directory. The logical architecture of the distributed file system is shown in Figure 1. The protocol access layer processes the Network File System (NFS) or Common Internet File System (CIFS) requests from the client. Taking the write request as an example, the data is first written to the storage pool, and then the metadata request is sent to the metadata service (MDS). The MDS first updates the metadata cache, writes the metadata operation log (used for metadata recovery processing during abnormal restart) to the storage pool, and then returns success to the protocol access layer. After configuring the quota, the distributed file storage needs to count the space occupancy or number of files under the directory in real time. If it is greater than the quota configured by the user, the user's write request will be returned as failed to prevent a single user from excessively occupying system resources.
[0064] In related technologies, there are currently two common solutions for implementing the quota function:
[0065] 1. Quota statistics are performed by the MDS background.
[0066] Take open source ceph distributed storage as an example, as shown in Figure 2. Assume that quota is set in directory A. File 1 needs to be created in subdirectory C under directory A, and 1MB of data needs to be written to file 1. Then MDS adds 1 to the number of files in directory C, and the file size increment of file 1 by 1MB is added to the space occupied by directory C. After the next statistical cycle (for example, 5 seconds), MDS adds the number of files in directory C by 1 and the space increment of 1MB to directory A.
[0067] In addition, the MDS background statistics process will record logs for continued statistics after an abnormal restart. MDS will broadcast the number of files and space usage statistics of directory A to the file protocol layer on each node. If the number of files or space usage of directory A reaches the quota, when creating or appending files in A or its subdirectories (directories B and C), the file protocol layer returns an error to the file client.
[0068] The disadvantage of this quota solution is that there is a problem with the timeliness of quota interception. The background needs to update the statistical values to the upper directory layer by layer. If there are many directory levels, the delay will reach tens of seconds, resulting in a write failure being returned to the client tens of seconds after the quota is reached.
[0069] 2. Statistics are collected through memory cache and quota log.
[0070] Taking data writing as an example, as shown in Figure 3, assuming that after the protocol access layer processes the write request, it needs to update the file size and quota statistics at the same time. The process is as follows:
[0071] 1) The protocol access layer sends a lock request to the distributed lock server and adds a file metadata write lock.
[0072] 2) The protocol access layer calculates the quota increment of the parent directory.
[0073] 3) The protocol access layer sends a write request to the Object Storage Device (OSD), carrying the quota increment.
[0074] 4) OSD writes data to disk and records quota logs for quota statistics recovery after abnormal restart of MDS.
[0075] 5) The protocol access layer sends a request to the MDS to update the file size.
[0076] 6) MDS updates the file size in the file metadata and updates the quota statistics of the file's parent directory in the memory cache.
[0077] 7) The protocol access layer sends a request to the distributed lock server to release the file metadata write lock.
[0078] However, this solution relies on the protocol access layer to add a file metadata write lock first to ensure the accuracy of the quota increment calculated by the protocol access layer. The file metadata write lock implemented based on the distributed lock server only allows one protocol access layer to write data at the same time. Therefore, for some distributed storage, such as Ceph storage, which supports multiple clients to concurrently write different ranges of the same file, the protocol access layer will be unable to calculate the accurate quota increment, as shown in Figure 4:
[0079] Protocol access layer 1 queries file metadata from MDS, assumes the file size is 0, and caches the file size locally. Protocol access layer 2 also queries file metadata from MDS and caches the file size locally. Protocol access layer 1 receives the write request from client 1 and writes the file data in the range of 0 to 1MB. After writing the data to OSD, it considers the current file size to be 1MB and sends a request to MDS to update the file size. The quota increment is 1MB. Protocol access layer 2 receives the write request from client 2 and writes the file data in the range of 5 to 6MB. After writing the data to OSD, it considers the current file size to be 6MB and sends a request to MDS to update the file size. The quota increment is 6MB. When MDS receives the request from protocol access layer 1, it increases the quota of the file's parent directory by 1MB. When MDS receives the request from protocol access layer 2, it increases the quota of the file's parent directory by 6MB. The actual file size is 6MB, but the quota usage of the file's parent directory has increased by 6+1=7MB, resulting in quota statistics errors.
[0080] Therefore, in order to solve the above problems, the present invention provides a quota statistics method for distributed file storage, involving both the MDS and the protocol access layer. The present invention will be explained from the MDS and the protocol access layer. For the MDS side, as shown in FIG5 , the method includes:
[0081] S11: When a metadata query request sent by the protocol access layer is received, metadata of the target file is returned to the corresponding protocol access layer.
[0082] S12: When the size of the accessed file sent by the protocol access layer is received, the metadata of the target file is locked through the local metadata lock.
[0083] The size of the file after access is determined by the protocol access layer according to the file size in the metadata of the target file and the file size in the file access request.
[0084] S13: Determine a change in the file quota according to the size of the file after access and the file size in the metadata of the target file.
[0085] S14: Update the metadata of the target file according to the size of the file after access.
[0086] S15: Unlock the metadata of the target file.
[0087] In addition, for the protocol access layer side, the present invention also provides a quota statistics method for distributed file storage, as shown in FIG6 , including:
[0088] S21: When a file access request is received, a metadata query request for the target file is sent to the metadata service.
[0089] S22: Determine the size of the file after access according to the file size in the metadata of the target file returned by the metadata service and the file size in the file access request.
[0090] S23: Send the accessed file size to the metadata service so that the metadata service determines the file quota change according to the accessed file size and the file size in the target file metadata, and updates the target file metadata according to the accessed file size.
[0091] When the metadata service receives the accessed file size sent by any protocol access layer, it locks the metadata of the target file through a local metadata lock, and unlocks the metadata of the target file after the metadata of the target file is updated.
[0092] It should be noted that in the above examples, for the convenience of explanation, the write data request is used as the file access request for explanation. Correspondingly, the corresponding user quota of data writing is used, so the quota change is a positive change, that is, the file quota change is an increment. But in fact, the scenarios involving quota changes in actual applications also include: truncate, delete, rename and other operations. The change of file quota is not always positive, so the file quota change is referred to in this method. When the file quota change is a positive number, it indicates a positive change in the quota. When the file quota change is a negative number, it indicates a negative change in the quota. In addition, these scenarios also involve the modification or deletion of file metadata, which leads to the problem that the second solution in the related art cannot accurately calculate the file quota in concurrent scenarios. The present invention can also solve the problem of inaccurate file quota calculation in the above scenarios.
[0093] In addition, the above description states that file quotas include space quotas and file number quotas. Since both quotas are calculated and updated in the same way, the file quotas mentioned in this method refer to both space quotas and file number quotas. However, in the specific embodiment, for the convenience of explanation, the calculation of the relatively more complex space quota is used for explanation, but this does not mean that this method can only be applied to the calculation of space quotas, but also applies to file number quotas.
[0094] It is not difficult to see from the above that the quota statistics method for distributed file storage provided by the present invention is similar to the second quota scheme in the above-mentioned related technology in that the quota change is also calculated through the interaction between the protocol access layer and the metadata service. However, the difference is that in this method, the step of calculating the file quota change is implemented by the MDS, and the write lock of the target file metadata is implemented through the MDS local metadata lock. Since the MDS local metadata lock does not have the restriction of only allowing one protocol access layer to write at the same time, the accurate calculation of the file quota change can still be guaranteed in the scenario of concurrent access by multiple clients.
[0095] Specifically, taking multi-client concurrent direct writing as an example, combined with the example scenario shown in FIG4 , when the file quota is updated based on this method, the process is shown in FIG7 :
[0096] Protocol access layer 1 processes the write request and then sends a request to MDS to update the file size to 1MB. MDS calculates the difference between the file size in the request (1MB) and the file size in the file metadata (0), obtains a quota increment of 1MB, and then updates the file size in the file metadata to 1MB. Protocol access layer 2 processes the write request and then sends a request to MDS to update the file size to 6MB. MDS calculates the difference between the file size in the request (6MB) and the file size in the file metadata (1MB), obtains a quota increment of 5MB, and then updates the file size in the file metadata to 6MB.
[0097] It can be seen that this method avoids dependence on the distributed lock server through the local metadata lock of MDS, and solves the accuracy problem of concurrent quota increment calculation. Among them, the sum of the file quota changes calculated twice by MDS is 6MB=1MB+5MB, which is equal to the file size of 6MB. The calculation is accurate and can effectively solve the file quota calculation problem in the multi-client concurrent access scenario.
[0098] Furthermore, for the MDS side, this embodiment also provides a further implementation scheme, as shown in FIG8 , after determining the file quota change amount in step S13, the above method further includes:
[0099] S16: Write the metadata and quota log of the target file into the metadata service log.
[0100] The quota log includes the file quota change amount and the quota number (id) corresponding to the file quota change amount.
[0101] In addition, the method further comprises:
[0102] S17: When the metadata service background performs log cleaning optimization (trim mdlog), the file metadata and quota log are flushed to disk.
[0103] When the quota log is flushed to disk, the write request sent to the storage pool includes multiple quota logs.
[0104] That is, in this embodiment, after the MDS determines the file quota change, the MDS records the quota log in the metadata log (mdlog). The mdlog contains the file metadata modification and quota increment, so that when the MDS is abnormally restarted, the file metadata and quota increment can be restored by replaying the mdlog, ensuring the transaction integrity of metadata updates and quota statistics.
[0105] On the other hand, for the protocol access layer side, this embodiment also provides a further implementation scheme. After step S23, the method further includes:
[0106] S24: if a response is received from the metadata service, the file quota change in the response is written into the local cache;
[0107] S25: The file quota change is reported to the quota server through a background task, so that the quota server can update the quota usage in the memory according to the file quota change; and persist the quota usage to the storage pool according to a preset first period (such as 5s).
[0108] That is, in addition to calculating the file quota change and updating the local quota, the MDS and protocol access layer also report the file quota change for this access to the quota server. The quota server is a service that manages file quotas in a distributed file system. Reporting file quota changes to the quota server helps the quota server manage the quota of the entire distributed file system. At the same time, the quota server also persists the updated quota usage in the storage pool, i.e., the OSD, to ensure data recoverability.
[0109] Furthermore, in the above embodiment, after the protocol access layer receives the MDS response, it needs to write the quota increment into the local cache and report it to the quota server through a background task. If the protocol access layer restarts abnormally before reporting, the data in the cache will be lost, which will cause the report to fail, making the data about file quotas in the quota server and the access protocol layer inconsistent. To solve this problem, this embodiment also provides a further implementation scheme, as shown in Figure 9, the method also includes reporting heartbeat information to the quota service according to a preset second period (such as 0.5s) to facilitate the quota service:
[0110] S31: Determine whether the protocol access layer is faulty based on the heartbeat information.
[0111] S32: If yes, then obtain the quota usage stored in the storage pool at the start time of the current counting cycle of the logical clock.
[0112] The logical clock is a clock signal maintained inside the distributed storage system. The count value of the logical clock increases by one after each counting cycle (such as 60 seconds).
[0113] S33: Acquire the quota log recorded by the storage pool in the current counting period, and filter to obtain the quota log related to the faulty protocol access layer.
[0114] S34: Determine the file quota change amount of the faulty protocol access layer in the current counting period according to the quota log related to the faulty protocol access layer.
[0115] S35: Restore the file quota change amount of the faulty protocol access layer at the time of the fault according to the quota usage at the start time of the counting cycle and the file quota change amount of the faulty protocol access layer in the current counting cycle.
[0116] That is, this embodiment provides a fault recovery method when the protocol access layer fails to report the file quota change to the quota server. Specifically, a logical clock is maintained internally in the distributed file system, and the quota log persisted in the storage pool is linked to the counting period of the logical clock according to the write time. In addition, the quota server senses whether each protocol access layer is faulty through the heartbeat mechanism. If it fails, the counting period at the current moment can be determined based on the count value of the current logical clock. The quota usage at the start of this counting period and the quota log recorded by the faulty protocol access layer in this counting period are obtained from the storage pool, and the file quota change of the protocol access layer in the current counting period can be counted. Even if the protocol access layer fails, the quota usage can still be accurately updated, which solves the problem caused by the quota failure reported by the protocol access layer.
[0117] Furthermore, based on the above embodiment, as shown in FIG9 , this embodiment also provides a possible implementation scheme:
[0118] The quota log is written to the storage pool by the metadata service, and the quota logs written in the same counting period are aggregated and stored in the storage pool according to the counting period of the logical clock.
[0119] Accordingly, step S33 specifically includes:
[0120] S331: Obtain all quota logs recorded by the storage pool in the current counting period.
[0121] S332: Filter the quota logs and retain only the quota logs corresponding to the faulty protocol access layer.
[0122] It is easy to understand that, from the scheme of this embodiment, when the MDS persists the quota log to the storage pool, it aggregates and stores the quota logs written in the same counting period according to the logical clock. Therefore, when fault recovery needs to obtain all the quota logs recorded by the faulty protocol access layer in the counting period at the time of the fault, it can be easily obtained. However, the quota log does not distinguish between access protocol layers when aggregated and stored, so the quota log obtained is the quota log written by all protocol access layers in the counting period, and further filtering is required to obtain the quota log written by the faulty access protocol layer to complete the above fault recovery process.
[0123] On the other hand, this embodiment also provides a further implementation scheme, as shown in FIG8 , before step S22, the method further includes:
[0124] S26: Send a pre-application quota request to the quota service.
[0125] The pre-application quota request includes: a quota number and a pre-application quota amount.
[0126] S27: Receive the pre-allocated quota amount returned by the quota service, and record the pre-allocated quota amount in the memory.
[0127] If the remaining amount of quota in the quota service is greater than the pre-applied quota amount, the pre-allocated quota amount is greater than the pre-applied quota amount.
[0128] S28: When a file access request is received next time, if the file quota change is less than the pre-allocated quota, the pre-allocated quota is updated according to the file quota change returned by the metadata service, and the pre-application quota request to the quota service is stopped.
[0129] That is, this embodiment provides a solution for pre-applying for quota resources. When the protocol access layer needs to increase the quota when processing a file access request, a pre-application quota request is sent to the quota server. The request needs to include the quota ID and the pre-application quota amount to inform the quota server how much quota is required for this access request. After receiving the pre-application quota request, the quota server determines whether more quota resources can be allocated to the access protocol layer based on the current remaining quota amount. If so, it returns a pre-allocated quota amount that is larger than the pre-application quota amount requested by the protocol access layer to the protocol access layer, so that the next time the access protocol layer processes a write request or other request involving a quota increment, there is no need to pre-apply for quota resources again, thereby simplifying the process and improving efficiency.
[0130] It is easy to understand that the above pre-allocation scheme is based on the assumption that the quota server has sufficient quota resources. If not, no more quota will be allocated to the access protocol layer. Furthermore, if the remaining quota in the quota server is not enough to provide the pre-application quota requested by the access protocol layer, an application failure error will be returned.
[0131] For example, assuming that the protocol access layer pre-applies for a quota of 0.5MB, and the quota server determines that the remaining quota is 10GB, it can allocate 50MB of quota to the protocol access layer. If the remaining quota is less than 0.5MB, the quota server returns an application failure error to the protocol access layer.
[0132] In the above embodiment, a method for calculating quota statistics of distributed file storage is described in detail, and the present invention also provides an embodiment corresponding to a device for calculating quota statistics of distributed file storage. It should be noted that, similar to the method, the device embodiment provided in this embodiment is also described from both the MDS and the protocol access layer.
[0133] Applied to the metadata service side, this embodiment provides a quota statistics device for distributed file storage, including:
[0134] The metadata response module is used to return the metadata of the target file to the corresponding protocol access layer when receiving the metadata query request sent by the protocol access layer;
[0135] The metadata lock module is used to lock the metadata of the target file through a local metadata lock when receiving the file size after access sent by the protocol access layer; wherein the file size after access is determined by the protocol access layer according to the file size in the metadata of the target file and the file size in the file access request;
[0136] A quota calculation module, used to determine the file quota change amount according to the file size after access and the file size in the metadata of the target file;
[0137] A metadata update module, used for updating the metadata of a target file according to the size of the file after access;
[0138] The metadata unlocking module is used to unlock the metadata of the target file.
[0139] Applied to the metadata service side, this embodiment provides a quota statistics device for distributed file storage, including:
[0140] The metadata query module is used to send a metadata query request for a target file to the metadata service when receiving a file access request;
[0141] A file size calculation module, used to determine the size of the file after access according to the file size in the metadata of the target file returned by the metadata service and the file size in the file access request;
[0142] The file size response module is used to send the file size after access to the metadata service so that the metadata service can: determine the file quota change according to the file size after access and the file size in the metadata of the target file, and update the metadata of the target file according to the file size after access; wherein, when the metadata service receives the file size after access sent by any protocol access layer, the metadata of the target file is locked through the local metadata lock, and after the metadata of the target file is updated, the metadata of the target file is unlocked.
[0143] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.
[0144] The present invention further provides a quota statistics device for distributed file storage, comprising: a memory for storing computer programs;
[0145] The processor is used to implement the steps of a quota statistics method for distributed file storage in the above embodiment when executing a computer program.
[0146] The quota statistics device for distributed file storage provided in this embodiment may include but is not limited to a mobile terminal, a personal computer, a workstation, etc.
[0147] Among them, the processor may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor can be implemented in at least one hardware form of a digital signal processor (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0148] The memory may include one or more computer-readable storage media, which may be non-transitory. The memory may also include high-speed random access memory, and non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory is at least used to store the following computer program, wherein, after the computer program is loaded and executed by the processor, it can implement the relevant steps of a quota statistics method for distributed file storage disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory may also include an operating system and data, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system may include Windows, Unix, Linux, etc. The data may include but is not limited to a quota statistics method for distributed file storage, etc.
[0149] In some embodiments, a quota statistics device for distributed file storage may also include a display screen, an input and output interface, a communication interface, a power supply, and a communication bus.
[0150] An embodiment of the present invention provides a quota statistics device for distributed file storage, including a memory and a processor. When the processor executes a program stored in the memory, it can implement the following method: a quota statistics method for distributed file storage.
[0151] In addition to the embodiments of the method and device for calculating quota statistics of distributed file storage provided in the above embodiments, the present invention also provides an embodiment corresponding to a computer program product. A computer program product includes a computer program / instruction, and when the computer program / instruction is executed by a processor, the steps of the method for calculating quota statistics of distributed file storage described in any of the above embodiments can be implemented.
[0152] Since the embodiments of the computer program product part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the computer program product part, which will not be repeated here.
[0153] Finally, the present invention also provides an embodiment corresponding to a non-volatile storage medium. A computer program is stored on the non-volatile storage medium, and when the computer program is executed by a processor, the steps recorded in the above method embodiment (which may be a method corresponding to the metadata service side, or a method corresponding to the protocol access layer side, or a method corresponding to the metadata service side and the protocol access layer side) are implemented.
[0154] It is understandable that if the method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc. Various media that can store program codes.
[0155] The above is a detailed introduction to a quota statistics method, device and medium for distributed file storage provided by the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can be referenced to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the present invention.
[0156] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. A quota statistics method for distributed file storage, characterized in that: Applied to the metadata service side, including: When receiving a metadata query request sent by the protocol access layer, returning metadata of the target file to the corresponding protocol access layer; upon receiving the post-access file size sent by the protocol access layer, locking the metadata of the target file using a local metadata lock; wherein the post-access file size is determined by the protocol access layer based on the file size in the metadata of the target file and the file size in the file access request; Determining a file quota change amount according to the file size after the access and the file size in the metadata of the target file; updating the metadata of the target file according to the size of the file after access; Unlocks the metadata of the target file.
2. The quota statistics method for distributed file storage according to claim 1, characterized in that: After determining the file quota change, the following steps are also included: Writing the metadata and quota log of the target file into a metadata service log; wherein the quota log includes the file quota change amount and the quota number corresponding to the file quota change amount; The method further comprises: When the metadata service background performs log cleaning optimization, the file metadata and the quota log are flushed to disk; wherein, when the quota log is flushed to disk, the write request sent to the storage pool includes multiple quota logs.
3. A quota statistics method for distributed file storage, characterized in that: Applied to the protocol access layer, including: When a file access request is received, a metadata query request for the target file is sent to the metadata service; Determine the size of the file after access according to the file size in the metadata of the target file returned by the metadata service and the file size in the file access request; The post-access file size is sent to the metadata service so that the metadata service can: determine a file quota change based on the post-access file size and the file size in the target file metadata, and update the target file metadata based on the post-access file size; wherein, when the metadata service receives the post-access file size sent by any of the protocol access layers, it locks the target file metadata through a local metadata lock, and unlocks the target file metadata after the target file metadata is updated.
4. The quota statistics method for distributed file storage according to claim 3, characterized in that: After sending the accessed file size to the metadata service, the method further includes: If a response is received from the metadata service, the file quota change in the response is written into the local cache; The file quota change is reported to the quota service through a background task, so that the quota service can: update the quota usage in the memory according to the file quota change; and persist the quota usage to the storage pool according to a preset first period.
5. The quota statistics method for distributed file storage according to claim 4, characterized in that: Also includes: Report heartbeat information to the quota service according to the preset second period, so that the quota service: Determining whether the protocol access layer is faulty according to the heartbeat information; If so, obtaining the quota usage stored in the storage pool at the start time of the current counting cycle of the logical clock; wherein the logical clock is a clock signal maintained internally by the distributed storage system, and the count value of the logical clock is increased by one after each counting cycle; Obtaining the quota log recorded by the storage pool in the current counting period, and filtering to obtain the quota log related to the faulty protocol access layer; determining, according to the quota log related to the faulty protocol access layer, a change in the file quota of the faulty protocol access layer in the current counting period; The file quota change of the faulty protocol access layer at the time of the fault is restored according to the quota usage at the start time of the counting period and the file quota change of the faulty protocol access layer in the current counting period.
6. The quota statistics method for distributed file storage according to claim 5, characterized in that: The quota log is written into the storage pool by the metadata service, and the quota logs written into the same counting period are aggregated and stored in the storage pool according to the counting period of the logical clock; Then, obtaining the quota log recorded by the storage pool in the current counting period and filtering to obtain the quota log related to the faulty protocol access layer includes: Obtain all the quota logs recorded by the storage pool in the current counting period; The quota log is filtered to retain only the quota log corresponding to the faulty protocol access layer.
7. The method for calculating quota statistics for distributed file storage according to claim 3, wherein: Before determining the size of the file after access according to the file size in the metadata of the target file returned by the metadata service and the file size in the file access request, the method further includes: Sending a pre-application quota request to the quota service; wherein the pre-application quota request includes: the quota number and the pre-application quota amount; receiving the pre-allocated quota amount returned by the quota service and recording the pre-allocated quota amount in a memory; wherein, if the remaining amount of quota in the quota service is greater than the pre-applied quota amount, then the pre-allocated quota amount is greater than the pre-applied quota amount; When the file access request is received next time, if the file quota change is less than the pre-allocated quota, the pre-allocated quota is updated according to the file quota change returned by the metadata service, and the pre-application quota request to the quota service is stopped.
8. A quota statistics device for distributed file storage, characterized in that: Applied to the metadata service side, including: A metadata response module, configured to return metadata of a target file to the corresponding protocol access layer upon receiving a metadata query request sent by the protocol access layer; a metadata lock module configured to lock the metadata of the target file using a local metadata lock upon receiving a post-access file size sent by the protocol access layer; wherein the post-access file size is determined by the protocol access layer based on the file size in the metadata of the target file and the file size in the file access request; A quota calculation module, configured to determine a file quota change based on the size of the accessed file and the file size in the metadata of the target file; A metadata updating module, configured to update the metadata of the target file according to the size of the file after access; The metadata unlocking module is used to unlock the metadata of the target file.
9. A quota statistics device for distributed file storage, characterized in that: Applied to the protocol access layer, including: The metadata query module is used to send a metadata query request for a target file to the metadata service when receiving a file access request; A file size calculation module, configured to determine a file size after access based on the file size in the metadata of the target file returned by the metadata service and the file size in the file access request; The file size response module is configured to send the post-access file size to the metadata service so that the metadata service can determine a file quota change based on the post-access file size and the file size in the target file metadata, and update the target file metadata based on the post-access file size. When the metadata service receives the post-access file size sent by any of the protocol access layers, it locks the target file metadata using a local metadata lock, and unlocks the target file metadata after the target file metadata is updated.
10. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a computer program, which, when executed by a processor, implements the steps of the quota statistics method for distributed file storage according to any one of claims 1 to 7.
Citation Information
Cited By
File caching method and device, storage medium and electronic equipment
CN119759277A
