Quota information reporting method and device
In the distributed file system, distributed nodes request and convert quota information from the metadata server to ensure the accuracy of the quota information and then report it to the quota server. This solves the problem of low accuracy of quota information reporting and achieves quota usage and Accurate statistics of remaining quantities.
Patent Information
- Application Number
- CN202410706092.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-10-01
AI Technical Summary
The reporting accuracy of quota information in the existing technology is low, resulting in inaccurate statistics of quota usage and remaining amounts.
In a distributed file system, distributed nodes send target quota requests to the metadata server, receive and convert the initial quota information, ensure the accuracy of the quota information, and then report it to the quota server.
It improves the reporting accuracy of quota information, ensures the statistical accuracy of quota usage and remaining amount, and solves the problem of low accuracy of quota information.
Smart Images

Figure CN118733251A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the computer field, and in particular, to a method and device for reporting quota information. Background Art
[0002] The quota server is used to set quotas for directories in the file system to limit and count the space and number of files used by front-end services in the quota directory, so as to achieve a reasonable allocation of file system storage resources. When running, the quota server needs to collect information about the usage of the quota applied by the client that applies for the quota from the quota server. The client will determine the usage of the applied quota based on the size of the file before and after the file operation it performs. However, because the operation of reporting the file size to the metadata server (MDS) after the client performs the file operation is performed asynchronously, the above quota usage judgment method cannot actually accurately determine the usage of the applied quota, so the accuracy of the reported quota information is not very high. Summary of the invention
[0003] The embodiments of the present application provide a method and device for reporting quota information, so as to at least solve the problem of low accuracy of the reported quota information in the related art.
[0004] According to an embodiment of the present application, a method for reporting quota information is provided. The distributed file system includes a distributed node, a metadata server and a quota server. The distributed node is connected to the metadata server and the quota server respectively. The distributed node is used to process a user's file request. The metadata server is used to manage the file metadata of the distributed node. The quota server is used to manage the file quota of the distributed node. The method is applied to the distributed node. The method includes:
[0005] Receiving a target file request initiated by a user, and performing a target file operation on the target file in response to the target file request;
[0006] Sending a target quota request to the metadata server, wherein the target quota request is used to request the metadata server to detect current quota information of the target file, and the quota information is used to indicate usage of the target file quota of the target file by the target file operation;
[0007] Receiving initial quota information returned by the metadata server in response to the target quota request, wherein the metadata server is used to detect the current quota information of the target file in response to the target quota request according to the currently recorded file metadata of the target file and the file metadata of the target file after the target file operation is performed to obtain the initial quota information;
[0008] Converting the initial quota information into target quota information corresponding to the target file, wherein the target quota information is used to indicate usage of the target file quota of the target file by the target file operation and remaining status of the target file quota;
[0009] Report the target quota information to the quota server.
[0010] As an optional implementation manner, the sending the target quota request to the metadata server includes:
[0011] A first synchronization request is sent to the metadata server, wherein the first synchronization request is used to instruct the metadata server to synchronize the file metadata of the target file, and the metadata server is used to detect and return the current quota information of the target file after synchronizing the file metadata of the target file in response to the first synchronization request.
[0012] As an optional implementation manner, the sending the target quota request to the metadata server includes:
[0013] Acquire a second synchronization request to be sent to the metadata server, wherein the second synchronization request is used to instruct the metadata server to synchronize file metadata of the target file;
[0014] Adding the target quota request to the second synchronization request to obtain a third synchronization request;
[0015] The third synchronization request is sent to the metadata server, wherein the metadata server is configured to respond to the target quota request to detect current quota information of the target file after synchronizing file metadata of the target file in response to the third synchronization request.
[0016] As an optional implementation manner, converting the initial quota information into target quota information corresponding to the target file includes:
[0017] Extracting a quota usage parameter from the initial quota information, wherein the quota usage parameter is used to indicate a usage of a target file quota of the target file by the target file operation;
[0018] A quota remaining parameter is calculated according to the quota usage parameter, the initial size of the target file, and the target size of the target file, wherein the initial size is the file size of the target file before the target file operation is performed, the target size is the file size of the target file after the target file operation is performed, the quota remaining parameter is used to indicate the remaining amount of the target file quota, and the target quota information includes the quota usage parameter and the quota remaining parameter.
[0019] As an optional implementation manner, receiving a target file request initiated by a user and performing a target file operation on a target file in response to the target file request includes:
[0020] receiving a file write operation initiated by the user, wherein the target file request includes the file write operation, and the file write operation is used to request writing to the target file;
[0021] In response to the file write operation, sending a reference quota request to the quota server, wherein the reference quota request is used to request the quota server to allocate a file quota that satisfies the file write operation;
[0022] Receiving the pre-application quota amount returned by the quota server in response to the reference quota request;
[0023] Performing the write file operation on the target file according to the pre-applied quota amount, and calculating the reference quota remaining amount according to the consumption of the pre-applied quota amount by the write file operation and the pre-applied quota amount;
[0024] The converting the initial quota information into target quota information corresponding to the target file includes:
[0025] Calculating a target quota remaining amount according to the target quota usage, wherein the initial quota information includes the target quota usage;
[0026] Detecting whether the target quota remaining amount matches the reference quota remaining amount;
[0027] In the case where it is detected that the target quota remaining amount does not match the reference quota remaining amount, the reference quota remaining amount is corrected according to the target quota remaining amount.
[0028] As an optional implementation manner, the reporting the target quota information to the quota server includes:
[0029] Reporting a quota usage parameter to the quota server, wherein the quota usage parameter is used to indicate a usage of a target file quota of the target file by the target file operation;
[0030] Reporting a quota remaining parameter to the quota server, wherein the quota remaining parameter is used to indicate the remaining amount of the target file quota.
[0031] As an optional implementation manner, after sending the target quota request to the metadata server, the method further includes:
[0032] Extracting the first file metadata of the target file currently recorded through the metadata server;
[0033] Synchronizing the file metadata of the target file with the distributed nodes through the metadata server;
[0034] Extracting, through the metadata server, second file metadata of the synchronized target file;
[0035] Detecting the current quota information of the target file according to the first file metadata and the second file metadata by the metadata server, obtaining the initial quota information;
[0036] The initial quota information is sent to the distributed nodes through the metadata server.
[0037] According to another embodiment of the present application, a quota information reporting device is provided, wherein the distributed file system includes a distributed node, a metadata server and a quota server, wherein the distributed node is connected to the metadata server and the quota server respectively, wherein the distributed node is used to process a user's file request, wherein the metadata server is used to manage the file metadata of the distributed node, wherein the quota server is used to manage the file quota of the distributed node, wherein the device is applied to the distributed node, and wherein the device includes:
[0038] An execution module, used for receiving a target file request initiated by a user, and performing a target file operation on the target file in response to the target file request;
[0039] A first sending module is used to send a target quota request to the metadata server, wherein the target quota request is used to request the metadata server to detect the current quota information of the target file, and the quota information is used to indicate the usage of the target file quota of the target file by the target file operation;
[0040] a receiving module, configured to receive the initial quota information returned by the metadata server in response to the target quota request, wherein the metadata server is configured to detect the current quota information of the target file in response to the target quota request according to the currently recorded file metadata of the target file and the file metadata of the target file after the target file performs the target file operation to obtain the initial quota information;
[0041] a conversion module, configured to convert the initial quota information into target quota information corresponding to the target file, wherein the target quota information is used to indicate the usage of the target file quota of the target file by the target file operation and the remaining status of the target file quota;
[0042] The reporting module is used to report the target quota information to the quota server.
[0043] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.
[0044] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0045] Through the present application, in a distributed file system, a metadata server manages file metadata of distributed nodes, a quota server manages file quotas of distributed nodes, and distributed nodes respond to target file requests initiated by users to perform target file operations on target files, send target quota requests to the metadata server to request the metadata server to detect current quota information of the target files, receive initial quota information returned by the metadata server in response to the target quota request, and then convert the initial quota information into target quota information corresponding to the target file, indicating the usage of the target file quota of the target file by the target file operation and the remaining status of the target file quota, and report the target quota information to the quota server. That is, after executing the target file operation corresponding to the target file request, the distributed node will send a target quota request to the metadata server, triggering the metadata server to respond to the target quota request and detect the current quota information of the target file according to the file metadata of the currently recorded target file and the file metadata after the target file executes the target file operation to obtain the initial quota information. The metadata server manages the file metadata of the distributed nodes in the distributed system. The metadata server detects the current quota information of the target file according to the recorded metadata, which can ensure that the file metadata of the currently recorded target file is true and accurate. Therefore, the current quota information and initial quota information of the target file obtained by detection are also accurate. The accuracy of the target quota information obtained by converting the initial quota information from the metadata server is also improved, that is, the accuracy of the target quota information reported to the quota server is improved. Therefore, the problem of low accuracy of the reported quota information in the related technology can be solved, and the effect of improving the accuracy of the reported quota information can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is a hardware structure block diagram of a server device of a quota information reporting method according to an embodiment of the present application;
[0047] Figure 2 is a flowchart of a method for reporting quota information according to an embodiment of the present application;
[0048] Figure 3 This is a schematic diagram of a data interaction according to an embodiment of the present application. Figure 1 ;
[0049] Figure 4 This is a schematic diagram of a data interaction according to an embodiment of the present application. Figure 2 ;
[0050] Figure 5 This is a schematic diagram of a data interaction according to an embodiment of the present application. Figure 3 ;
[0051] Figure 6 It is a structural block diagram of a quota information reporting device according to an embodiment of the present application. DETAILED DESCRIPTION
[0052] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0053] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0054] The method embodiments provided in the embodiments of the present application can be executed in a server device or a similar computing device. Taking running on a server device as an example, Figure 1 1 is a hardware structure block diagram of a server device of a quota information reporting method according to an embodiment of the present application. Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the server device may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above server device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0055] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for reporting quota information in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0056] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the server device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0057] In this embodiment, a method for reporting quota information is provided. Figure 2 The present invention is a flowchart of a method for reporting quota information according to an embodiment of the present application. The distributed file system includes a distributed node, a metadata server and a quota server. The distributed node is connected to the metadata server and the quota server respectively. The distributed node is used to process user file requests. The metadata server is used to manage file metadata of the distributed node. The quota server is used to manage file quotas of the distributed node. The method is applied to the distributed node. Figure 2 As shown, the process includes the following steps:
[0058] Step S202, receiving a target file request initiated by a user, and performing a target file operation on the target file in response to the target file request;
[0059] Step S204, sending a target quota request to the metadata server, wherein the target quota request is used to request the metadata server to detect the current quota information of the target file, and the quota information is used to indicate the usage of the target file quota of the target file by the target file operation;
[0060] Step S206, receiving the initial quota information returned by the metadata server in response to the target quota request, wherein the metadata server is used to detect the current quota information of the target file according to the currently recorded file metadata of the target file and the file metadata of the target file after the target file operation is performed to obtain the initial quota information in response to the target quota request;
[0061] Step S208, converting the initial quota information into target quota information corresponding to the target file, wherein the target quota information is used to indicate the usage of the target file quota of the target file by the target file operation and the remaining status of the target file quota;
[0062] Step S210: reporting the target quota information to the quota server.
[0063] Through the above steps, in the distributed file system, the metadata server manages the file metadata of the distributed nodes, the quota server manages the file quotas of the distributed nodes, the distributed nodes respond to the target file request initiated by the user to perform the target file operation on the target file, send the target quota request to the metadata server to request the metadata server to detect the current quota information of the target file, receive the initial quota information returned by the metadata server in response to the target quota request, and then convert the initial quota information into the target quota information corresponding to the target file indicating the usage of the target file quota of the target file by the target file operation and the remaining status of the target file quota, and report the target quota information to the quota server. That is, after executing the target file operation corresponding to the target file request, the distributed node will send a target quota request to the metadata server, triggering the metadata server to respond to the target quota request and detect the current quota information of the target file according to the file metadata of the currently recorded target file and the file metadata after the target file executes the target file operation to obtain the initial quota information. The metadata server manages the file metadata of the distributed nodes in the distributed system. The metadata server detects the current quota information of the target file according to the recorded metadata, which can ensure that the file metadata of the currently recorded target file is true and accurate. Therefore, the current quota information and initial quota information of the target file obtained by detection are also accurate. The accuracy of the target quota information obtained by converting the initial quota information from the metadata server is also improved, that is, the accuracy of the target quota information reported to the quota server is improved. Therefore, the problem of low accuracy of the reported quota information in the related technology can be solved, and the effect of improving the accuracy of the reported quota information can be achieved.
[0064] Optionally, in an embodiment of the present application, the distributed file system includes but is not limited to the presence of one or more distributed nodes, and the distributed nodes include but are not limited to docking front-end services, such as creating files, writing files, etc. Each service corresponds to a series of metadata requests, and the distributed nodes send the metadata requests to MDS for processing. After the MDS processes, the distributed nodes feed back the results to the front end. MDS is a metadata server. In a distributed file system, MDS mainly manages the metadata of files and processes metadata requests. Metadata requests initiated by distributed nodes are processed by MDS. The quota server is used to manage the file quotas of the distributed nodes of the distributed file system. By setting quotas for directories in the distributed file system, the space used and the number of files in the quota directory of the front-end service can be limited and counted. In a distributed file system, the quota needs to count the data written by all distributed nodes. There are three important parameters for the quota: threshold, usage, and remaining amount. For example, when a distributed node processes the front-end batch file creation business, the distributed node needs to first initiate a pre-application quota request to the Quotaserver, the quota server, and then initiate a file metadata creation request to the MDS. After the file is successfully created, the distributed node consumes the quota and reports the quota change to the Quotaserver. This process will update the quota usage and remaining amount. Using Quotaserver as the quota server instead of MDS to process quota requests, on the one hand, reduces the metadata request pressure of MDS, and on the other hand, makes the distributed file system quota architecture more reasonable. Quotaserver manages the usage and remaining amount of the quota directory in the file system, and processes pre-application quota, usage reporting, pre-application recovery and other requests for all distributed nodes in the file system. When each distributed node processes the front-end business, it needs to send the quota request to the Quotaserver.
[0065] Optionally, in an embodiment of the present application, the user's file request includes but is not limited to a request to create a file, a request to write a file, etc., and this solution does not limit this.
[0066] In the embodiment provided in step S202, performing a target file operation on a target file in response to the target file request includes but is not limited to obtaining file metadata from a metadata server according to the received target file request, determining a file quota requirement according to the obtained file metadata and the target file request, applying to the quota server for a quota pre-application amount that meets the file quota requirement, and performing a target file operation corresponding to the target file request after obtaining the quota application amount.
[0067] Optionally, in an embodiment of the present application, the quota server allocates a quota application amount in response to a quota application initiated by a distributed node, including but not limited to the following: the quota server receives a quota application message from the distributed node at the first moment, and the quota server determines the quota application amount allocated to the distributed node that has made the application in response to the quota pre-application amount based on the total remaining amount of the distributed file system quota at the first moment: the relationship between the total remaining amount of the distributed file system quota at the first moment and the quota pre-application amount is calculated, and when the total remaining amount of the quota is greater than the quota pre-application amount, and when the proportion of the total remaining amount of the distributed file system quota at the first moment to the total amount of space available for use by the distributed file system is higher than a first threshold, the first increment is added to the quota pre-application amount to obtain the quota application amount; the total remaining amount of the distributed file system quota at the first moment to the distributed file system When the proportion of the total space that can be used by the distributed file system is not higher than the first threshold but higher than the second threshold, the second increment is added to the pre-quota application amount to obtain the quota application amount; when the proportion of the total remaining amount of the distributed file system quota to the total space that can be used by the distributed file system at the first moment is not higher than the second threshold but higher than the third threshold, the pre-quota application amount is set to the quota application amount; when the proportion of the total remaining amount of the distributed file system quota to the total space that can be used by the distributed file system at the first moment is lower than the third threshold, according to the authority of the distributed node that applies for the quota, it is selected to respond to the quota application of the distributed node to allocate the pre-application amount quota or not to respond to the quota application of the distributed node, wherein the thresholds are arranged from large to small in numerical value as the first threshold, the second threshold, and the third threshold, and the first increment is greater than the second increment.
[0068] In the embodiment provided in step S204, sending a target quota request to a metadata server includes but is not limited to sending a target file metadata synchronization request to the metadata server, the metadata server is configured to automatically trigger a quota information detection action upon receiving the metadata synchronization request, or obtains a target file metadata synchronization request to be sent to the metadata server as a preliminary target quota request, adds request information instructing the metadata server to detect quota information to the initial target quota request to obtain a target quota request, and sends the target quota request to the metadata server.
[0069] In the embodiment provided in step S206, the file metadata of the target file currently recorded by the metadata server includes but is not limited to the fact that during the process of executing the target file operation on the distributed node, the metadata server receives other target quota requests from other distributed nodes, resulting in the file metadata of the target file currently recorded by the metadata server being different from the file metadata before executing the target file operation stored in the distributed node.
[0070] In the embodiment provided in step S208, converting the initial quota information into the target quota information corresponding to the target file includes but is not limited to converting the initial quota information in the form of percentage into the target quota information in the form of numerical value.
[0071] In the embodiment provided in step S210, reporting the target quota information to the quota server includes but is not limited to reporting quota usage parameters and quota remaining parameters to the quota server. Reporting of quota usage parameters and quota remaining parameters includes but is not limited to being completed with one reporting request, or being completed with two reporting requests. In the case where the reporting of quota usage parameters and quota remaining parameters is completed with two reporting requests, it includes but is not limited to first reporting the quota usage parameters to the quota server and then reporting the quota remaining parameters to the quota server, or first reporting the quota remaining parameters to the quota server and then reporting the quota usage parameters to the quota server.
[0072] As an optional implementation manner, the sending the target quota request to the metadata server includes:
[0073] A first synchronization request is sent to the metadata server, wherein the first synchronization request is used to instruct the metadata server to synchronize the file metadata of the target file, and the metadata server is used to detect and return the current quota information of the target file after synchronizing the file metadata of the target file in response to the first synchronization request.
[0074] Optionally, in an embodiment of the present application, the file metadata of the target file includes but is not limited to the file size of the target file, etc., and this solution does not make any specific limitations on this.
[0075] Through the above steps, by sending a synchronization request, both the target file metadata synchronization operation and the detection operation of the current quota information of the target file are triggered, thereby reducing the number of data interactions between the metadata server and the distributed nodes, thereby reducing the use of operating resources and improving the interaction efficiency between the metadata server and the distributed nodes.
[0076] As an optional implementation manner, the sending the target quota request to the metadata server includes:
[0077] Acquire a second synchronization request to be sent to the metadata server, wherein the second synchronization request is used to instruct the metadata server to synchronize file metadata of the target file;
[0078] Adding the target quota request to the second synchronization request to obtain a third synchronization request;
[0079] The third synchronization request is sent to the metadata server, wherein the metadata server is configured to respond to the target quota request to detect current quota information of the target file after synchronizing file metadata of the target file in response to the third synchronization request.
[0080] Through the above steps, the target quota request is added to the second synchronization request that instructs the metadata server to synchronize the file metadata of the target file, and a third synchronization request is obtained. The third request is sent to the metadata server to trigger the metadata server to synchronize the file metadata of the target file, and then respond to the target quota request to detect the current quota information of the target file. By implementing a mechanism to trigger the metadata server to perform the required operation without making additional settings to the metadata server, there is no additional setting requirement for the metadata server in the distributed file system, and the restrictions are smaller, which makes it more applicable.
[0081] As an optional implementation manner, converting the initial quota information into target quota information corresponding to the target file includes:
[0082] Extracting a quota usage parameter from the initial quota information, wherein the quota usage parameter is used to indicate a usage of a target file quota of the target file by the target file operation;
[0083] A quota remaining parameter is calculated according to the quota usage parameter, the initial size of the target file, and the target size of the target file, wherein the initial size is the file size of the target file before the target file operation is performed, the target size is the file size of the target file after the target file operation is performed, the quota remaining parameter is used to indicate the remaining amount of the target file quota, and the target quota information includes the quota usage parameter and the quota remaining parameter.
[0084] Optionally, in the embodiment of the present application, the quota usage parameter includes but is not limited to indicating the size of the quota usage, or the ratio of the used quota to the quota application amount issued by the quota server, etc.
[0085] Through the above steps, the quota usage parameters are extracted from the initial quota information returned by the metadata server and the extracted quota usage parameters are used as the basis for calculating the quota remaining parameters, so that more accurate quota remaining parameters and quota usage parameters can be calculated, thereby improving the accuracy of the reported quota usage data and quota remaining data.
[0086] As an optional implementation manner, receiving a target file request initiated by a user and performing a target file operation on a target file in response to the target file request includes:
[0087] receiving a file write operation initiated by the user, wherein the target file request includes the file write operation, and the file write operation is used to request writing to the target file;
[0088] In response to the file write operation, sending a reference quota request to the quota server, wherein the reference quota request is used to request the quota server to allocate a file quota that satisfies the file write operation;
[0089] Receiving the pre-application quota amount returned by the quota server in response to the reference quota request;
[0090] Performing the write file operation on the target file according to the pre-applied quota amount, and calculating the reference quota remaining amount according to the consumption of the pre-applied quota amount by the write file operation and the pre-applied quota amount;
[0091] The converting the initial quota information into target quota information corresponding to the target file includes:
[0092] Calculating a target quota remaining amount according to the target quota usage, wherein the initial quota information includes the target quota usage;
[0093] Detecting whether the target quota remaining amount matches the reference quota remaining amount;
[0094] In the case where it is detected that the target quota remaining amount does not match the reference quota remaining amount, the reference quota remaining amount is corrected according to the target quota remaining amount.
[0095] As an optional implementation manner, the reporting the target quota information to the quota server includes:
[0096] Reporting a quota usage parameter to the quota server, wherein the quota usage parameter is used to indicate a usage of a target file quota of the target file by the target file operation;
[0097] Reporting a quota remaining parameter to the quota server, wherein the quota remaining parameter is used to indicate the remaining amount of the target file quota.
[0098] Through the above steps, accurate quota usage parameters and quota remaining parameters are reported to the quota server, which improves the reporting efficiency of quota information.
[0099] As an optional implementation manner, after sending the target quota request to the metadata server, the method further includes:
[0100] Extracting the first file metadata of the target file currently recorded through the metadata server;
[0101] Synchronizing the file metadata of the target file with the distributed nodes through the metadata server;
[0102] Extracting, through the metadata server, second file metadata of the synchronized target file;
[0103] Detecting the current quota information of the target file according to the first file metadata and the second file metadata by the metadata server, obtaining the initial quota information;
[0104] The initial quota information is sent to the distributed nodes through the metadata server.
[0105] As an optional implementation method, in order to further improve the accuracy of quota usage statistics, the present application proposes an implementation method in which the MDS (metadata server) calculates the quota usage, the client (corresponding to the above-mentioned distributed node) reports the quota usage, and the Quotaserver counts the quota usage of all clients, under the premise that the MDS (metadata server) is used as the server for metadata requests and the Quotaserver (quota server) is used as the server for quota requests. Figure 3 This is a schematic diagram of a data interaction according to an embodiment of the present application. Figure 1 .like Figure 3 As shown, the process of the quota information reporting method includes the following steps:
[0106] Step S1.1, the user initiates a file write operation;
[0107] Step S1.2: If the client has not cached the file metadata information, it obtains the metadata information from the MDS, adds a write lock to the file, and obtains the current file size;
[0108] Step S1.3: The client sends a pre-quota request to the Quotaserver based on the current file size, the offset and length of the write operation, requesting a batch of quotas to be allocated to satisfy the current file write;
[0109] Step S1.4: Quotaserver allocates a batch of quotas when there is sufficient remaining quota and replies the pre-application amount to the client;
[0110] Step S1.5, after the client applies for the quota, it writes the data to the file and updates the file size;
[0111] Step S1.6, the client calculates the pre-application amount consumed (not the actual usage) based on the file size, write operation offset, and length;
[0112] Step S1.7, the client returns the write operation result, and the user writes the file successfully;
[0113] Step S1.8, the client asynchronously synchronizes the file size change to the MDS and records the old file size locally;
[0114] Step S1.9, the MDS calculates the actual quota usage based on the received file size and the file size recorded by the MDS itself, and returns the usage to the client;
[0115] Step S1.10, after receiving the actual quota usage, the client corrects the pre-application remaining amount according to the actual usage, the new file size, and the old file size (because the client usage is the pre-application consumption, the usage calculation is inaccurate, so the pre-application remaining amount is also inaccurate and needs to be corrected);
[0116] In step S1.11, the client asynchronously reports the quota usage and pre-application remaining amount to the Quotaserver, and the Quotaserver uses this to update the quota usage and remaining amount of the entire cluster.
[0117] Because MDS is the metadata server of the distributed file system, changes to the file size by each client will eventually be synchronized to MDS. Therefore, MDS is the first to perceive the change in file size. MDS calculates the quota usage. Even when multiple client services are concurrent, the final calculated total quota usage is accurate.
[0118] As an optional implementation, Figure 4 This is a schematic diagram of a data interaction according to an embodiment of the present application. Figure 2 . Figure 5 This is a schematic diagram of a data interaction according to an embodiment of the present application. Figure 3 . Figure 4 and Figure 5 Corresponding to the two processing situations that client1 processes metadata synchronization of the first business application and client2 processes metadata synchronization of the second business application, the first business application and the second business application are both write operations on the same target file. Figure 4 This corresponds to client1 first processing the metadata synchronization of the first service application, and then client2 processing the metadata synchronization of the second service application. Figure 5 This corresponds to client2 processing the metadata synchronization of the second service application first, and then client1 processing the metadata synchronization of the first service application.
[0119] like Figure 4 As shown, the quota information reporting process includes the following steps:
[0120] Step S2.1, the initial size of the file recorded by the MDS is 4M, and both client1 and client2 cache the file size locally;
[0121] Step S2.2, client1 receives a write service request, the write range is [4M, 8M], which is an append write;
[0122] Step S2.3, client2 receives a write service request, the write range is [1M, 5M], which is overwrite write + append write;
[0123] Step S2.4, after client1 writes the data, it changes the size of the local cache file to 8M;
[0124] Step S2.5, after client2 writes the data, it changes the size of the local cache file to 5M;
[0125] Step S2.6, client1 synchronizes the file size to MDS, MDS updates the file size to 8M, calculates the quota usage to 4M, and returns the quota usage to client1;
[0126] Step S2.7, client2 synchronizes the file size to MDS. MDS recognizes that the received file size is smaller than the known file size, and does not update it, keeping the file size at 8M. At the same time, since the file size has not changed, the quota usage is 0M. The quota usage is returned to client2;
[0127] Step S2.8, therefore, the final accumulated quota usage of client1 and client2 is 4M+0M=4M, and the final result is consistent with the file size change.
[0128] like Figure 4 As shown, the quota information reporting process includes the following steps:
[0129] Step S3.1, the initial size of the file recorded by the MDS is 4M, and both client1 and client2 cache the file size locally;
[0130] Step S3.2, client1 receives a write service request, the write range is [4M, 8M], which is an append write;
[0131] Step S3.3, client2 receives a write service request, the write range is [1M, 5M], which is overwrite write + append write;
[0132] Step S3.4, after client1 writes the data, it changes the size of the local cache file to 8M;
[0133] Step S3.5, after client2 writes the data, it changes the size of the local cache file to 5M;
[0134] Step S3.6, client2 synchronizes the file size to MDS, MDS updates the file size to 5M, calculates the quota usage to 1M, and returns the quota usage to client2;
[0135] Step S3.7, client1 synchronizes the file size to MDS, MDS updates the file size to 8M, calculates the quota usage to 3M, and returns the quota usage to client1;
[0136] Step S3.8, therefore, the final accumulated quota usage of client1 and client2 is 3M+1M=4M, and the final result is consistent with the change in file size.
[0137] Through the above steps, MDS calculates the quota usage, downplaying the issue of whether the quota usage in a single process is correct, and instead emphasizing the fact that the final quota usage of the entire process is correct, ensuring that the final quota statistics are accurate when multiple client services are concurrent. MDS returns the actual quota usage to the client, and the client has the opportunity to correct the pre-application remaining amount. The pre-application remaining amount determines whether the quota statistics can be limited according to the quota threshold. Therefore, this application has a positive feedback effect on the two core functions of the quota (capacity statistics and capacity limitation).
[0138] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0139] In this embodiment, a quota information reporting device is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0140] Figure 61 is a structural block diagram of a quota information reporting device according to an embodiment of the present application, wherein the distributed file system comprises a distributed node, a metadata server and a quota server, wherein the distributed node is connected to the metadata server and the quota server respectively, wherein the distributed node is used to process a user's file request, wherein the metadata server is used to manage the file metadata of the distributed node, wherein the quota server is used to manage the file quota of the distributed node, and wherein the device is applied to the distributed node, such as Figure 6 As shown, the device comprises:
[0141] An execution module 602 is used to receive a target file request initiated by a user, and execute a target file operation on the target file in response to the target file request;
[0142] A first sending module 604 is used to send a target quota request to the metadata server, wherein the target quota request is used to request the metadata server to detect the current quota information of the target file, and the quota information is used to indicate the usage of the target file quota of the target file by the target file operation;
[0143] The receiving module 606 is used to receive the initial quota information returned by the metadata server in response to the target quota request, wherein the metadata server is used to detect the current quota information of the target file according to the currently recorded file metadata of the target file and the file metadata of the target file after the target file operation is performed to obtain the initial quota information in response to the target quota request;
[0144] A conversion module 608, configured to convert the initial quota information into target quota information corresponding to the target file, wherein the target quota information is used to indicate the usage of the target file quota of the target file by the target file operation and the remaining status of the target file quota;
[0145] The reporting module 610 is configured to report the target quota information to the quota server.
[0146] Through the above steps, in the distributed file system, the metadata server manages the file metadata of the distributed nodes, the quota server manages the file quotas of the distributed nodes, the distributed nodes respond to the target file request initiated by the user to perform the target file operation on the target file, send the target quota request to the metadata server to request the metadata server to detect the current quota information of the target file, receive the initial quota information returned by the metadata server in response to the target quota request, and then convert the initial quota information into the target quota information corresponding to the target file indicating the usage of the target file quota of the target file by the target file operation and the remaining status of the target file quota, and report the target quota information to the quota server. That is, after executing the target file operation corresponding to the target file request, the distributed node will send a target quota request to the metadata server, triggering the metadata server to respond to the target quota request and detect the current quota information of the target file according to the file metadata of the currently recorded target file and the file metadata after the target file executes the target file operation to obtain the initial quota information. The metadata server manages the file metadata of the distributed nodes in the distributed system. The metadata server detects the current quota information of the target file according to the recorded metadata, which can ensure that the file metadata of the currently recorded target file is true and accurate. Therefore, the current quota information and initial quota information of the target file obtained by detection are also accurate. The accuracy of the target quota information obtained by converting the initial quota information from the metadata server is also improved, that is, the accuracy of the target quota information reported to the quota server is improved. Therefore, the problem of low accuracy of the reported quota information in the related technology can be solved, and the effect of improving the accuracy of the reported quota information can be achieved.
[0147] As an optional implementation manner, the first sending module includes:
[0148] A first sending unit is used to send a first synchronization request to the metadata server, wherein the first synchronization request is used to instruct the metadata server to synchronize the file metadata of the target file, and the metadata server is used to detect and return the current quota information of the target file after synchronizing the file metadata of the target file in response to the first synchronization request.
[0149] As an optional implementation manner, the first sending module further includes:
[0150] an acquiring unit, configured to acquire a second synchronization request to be sent to the metadata server, wherein the second synchronization request is used to instruct the metadata server to synchronize file metadata of the target file;
[0151] an adding unit, configured to add the target quota request to the second synchronization request to obtain a third synchronization request;
[0152] The second sending unit is used to send the third synchronization request to the metadata server, wherein the metadata server is used to respond to the target quota request to detect the current quota information of the target file after synchronizing the file metadata of the target file in response to the third synchronization request.
[0153] As an optional implementation, the conversion module includes:
[0154] an extraction unit, configured to extract a quota usage parameter from the initial quota information, wherein the quota usage parameter is used to indicate a usage of a target file quota of the target file by the target file operation;
[0155] A first calculation unit is used to calculate a quota remaining parameter according to the quota usage parameter, the initial size of the target file, and the target size of the target file, wherein the initial size is the file size of the target file before the target file operation is performed, the target size is the file size of the target file after the target file operation is performed, the quota remaining parameter is used to indicate the remaining amount of the target file quota, and the target quota information includes the quota usage parameter and the quota remaining parameter.
[0156] As an optional implementation, the execution module includes:
[0157] A first receiving unit, configured to receive a file write operation initiated by the user, wherein the target file request includes the file write operation, and the file write operation is used to request writing to the target file;
[0158] A third sending unit is used to send a reference quota request to the quota server in response to the file writing operation, wherein the reference quota request is used to request the quota server to allocate a file quota that satisfies the file writing operation;
[0159] A second receiving unit, configured to receive the pre-application quota amount returned by the quota server in response to the reference quota request;
[0160] An execution unit is used to execute the write file operation on the target file according to the pre-applied quota amount, and calculate a reference quota remaining amount according to the consumption of the pre-applied quota amount by the write file operation and the pre-applied quota amount.
[0161] As an optional implementation, the conversion module further includes:
[0162] a second calculation unit, configured to calculate a target quota remaining amount according to a target quota usage amount, wherein the initial quota information includes the target quota usage amount;
[0163] A detection unit, configured to detect whether the target quota remaining amount matches the reference quota remaining amount;
[0164] The correction unit is configured to correct the reference quota remaining amount according to the target quota remaining amount when it is detected that the target quota remaining amount does not match the reference quota remaining amount.
[0165] As an optional implementation manner, the reporting module includes:
[0166] A first reporting unit, configured to report a quota usage parameter to the quota server, wherein the quota usage parameter is used to indicate a usage of a target file quota of the target file by the target file operation;
[0167] The second reporting unit is used to report a quota remaining amount parameter to the quota server, wherein the quota remaining amount parameter is used to indicate the remaining amount of the target file quota.
[0168] As an optional implementation manner, the quota information reporting device further includes:
[0169] A first extraction module, used for extracting the first file metadata of the target file currently recorded through the metadata server;
[0170] A synchronization module, used for synchronizing the file metadata of the target file with the distributed node through the metadata server;
[0171] A second extraction module, used for extracting second file metadata of the target file after synchronization through the metadata server;
[0172] A detection module, configured to detect the current quota information of the target file according to the first file metadata and the second file metadata through the metadata server to obtain the initial quota information;
[0173] The second sending module is used to send the initial quota information to the distributed node through the metadata server.
[0174] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0175] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0176] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0177] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0178] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0179] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.
[0180] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0181] An embodiment of the present application also provides a computer program, which includes computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in any one of the above method embodiments.
[0182] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0183] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0184] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for reporting quota information, It is characterized in that A distributed file system comprises distributed nodes, a metadata server and a quota server, wherein the distributed nodes are connected to the metadata server and the quota server respectively, the distributed nodes are used to process user file requests, the metadata server is used to manage file metadata of the distributed nodes, the quota server is used to manage file quotas of the distributed nodes, and the method is applied to the distributed nodes, and the method comprises: Receive a target file request initiated by a user, and perform a target file operation on the target file in response to the target file request; send a target quota request to the metadata server, wherein the target quota request is used to request the metadata server to detect the current quota information of the target file, and the quota information is used to indicate the usage of the target file quota of the target file by the target file operation; Receiving initial quota information returned by the metadata server in response to the target quota request, wherein the metadata server is used to detect the current quota information of the target file in response to the target quota request according to the currently recorded file metadata of the target file and the file metadata of the target file after the target file operation is performed to obtain the initial quota information; Converting the initial quota information into target quota information corresponding to the target file, wherein the target quota information is used to indicate usage of the target file quota of the target file by the target file operation and remaining status of the target file quota; Report the target quota information to the quota server.
2. The method according to claim 1, It is characterized in that The sending the target quota request to the metadata server includes: A first synchronization request is sent to the metadata server, wherein the first synchronization request is used to instruct the metadata server to synchronize the file metadata of the target file, and the metadata server is used to detect and return the current quota information of the target file after synchronizing the file metadata of the target file in response to the first synchronization request.
3. The method according to claim 1, It is characterized in that The sending the target quota request to the metadata server includes: Acquire a second synchronization request to be sent to the metadata server, wherein the second synchronization request is used to instruct the metadata server to synchronize file metadata of the target file; Adding the target quota request to the second synchronization request to obtain a third synchronization request; The third synchronization request is sent to the metadata server, wherein the metadata server is configured to respond to the target quota request to detect current quota information of the target file after synchronizing file metadata of the target file in response to the third synchronization request.
4. The method according to claim 1, It is characterized in that The converting the initial quota information into target quota information corresponding to the target file includes: Extracting a quota usage parameter from the initial quota information, wherein the quota usage parameter is used to indicate a usage of a target file quota of the target file by the target file operation; A quota remaining parameter is calculated according to the quota usage parameter, the initial size of the target file, and the target size of the target file, wherein the initial size is the file size of the target file before the target file operation is performed, the target size is the file size of the target file after the target file operation is performed, the quota remaining parameter is used to indicate the remaining amount of the target file quota, and the target quota information includes the quota usage parameter and the quota remaining parameter.
5. The method according to claim 1, It is characterized in that The receiving a target file request initiated by a user, and performing a target file operation on the target file in response to the target file request, comprises: receiving a file write operation initiated by the user, wherein the target file request includes the file write operation, and the file write operation is used to request writing to the target file; In response to the file write operation, sending a reference quota request to the quota server, wherein the reference quota request is used to request the quota server to allocate a file quota that satisfies the file write operation; Receiving the pre-application quota amount returned by the quota server in response to the reference quota request; Performing the write file operation on the target file according to the pre-applied quota amount, and calculating the reference quota remaining amount according to the consumption of the pre-applied quota amount by the write file operation and the pre-applied quota amount; The converting the initial quota information into target quota information corresponding to the target file includes: Calculating a target quota remaining amount according to the target quota usage, wherein the initial quota information includes the target quota usage; Detecting whether the target quota remaining amount matches the reference quota remaining amount; In the case where it is detected that the target quota remaining amount does not match the reference quota remaining amount, the reference quota remaining amount is corrected according to the target quota remaining amount.
6. The method according to claim 1, It is characterized in that Reporting the target quota information to the quota server includes: Reporting a quota usage parameter to the quota server, wherein the quota usage parameter is used to indicate a usage of a target file quota of the target file by the target file operation; Reporting a quota remaining parameter to the quota server, wherein the quota remaining parameter is used to indicate the remaining amount of the target file quota.
7. The method according to claim 1, It is characterized in that After sending the target quota request to the metadata server, the method further includes: Extracting the first file metadata of the target file currently recorded through the metadata server; Synchronizing the file metadata of the target file with the distributed nodes through the metadata server; Extracting, through the metadata server, second file metadata of the synchronized target file; Detecting the current quota information of the target file according to the first file metadata and the second file metadata by the metadata server, obtaining the initial quota information; The initial quota information is sent to the distributed nodes through the metadata server.
8. A quota information reporting device, It is characterized in that A distributed file system comprises distributed nodes, a metadata server and a quota server, wherein the distributed nodes are connected to the metadata server and the quota server respectively, the distributed nodes are used to process user file requests, the metadata server is used to manage file metadata of the distributed nodes, the quota server is used to manage file quotas of the distributed nodes, and the device is applied to the distributed nodes, and the device comprises: An execution module, used for receiving a target file request initiated by a user, and performing a target file operation on the target file in response to the target file request; A first sending module is used to send a target quota request to the metadata server, wherein the target quota request is used to request the metadata server to detect the current quota information of the target file, and the quota information is used to indicate the usage of the target file quota of the target file by the target file operation; a receiving module, configured to receive the initial quota information returned by the metadata server in response to the target quota request, wherein the metadata server is configured to detect the current quota information of the target file in response to the target quota request according to the currently recorded file metadata of the target file and the file metadata of the target file after the target file performs the target file operation to obtain the initial quota information; A conversion module, used to convert the initial quota information into target quota information corresponding to the target file, wherein the target quota information is used to indicate the usage of the target file quota of the target file by the target file operation and the remaining status of the target file quota; The reporting module is used to report the target quota information to the quota server.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 7 when executed by a processor.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the steps of the method described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Database index generation method and device and data processing method and device
CN119645931A
Database index generation method and apparatus, data processing method and apparatus
CN119645931B
File quota management method and device, electronic equipment and readable storage medium
CN119719027A
