CN115543953A - Quota control method, device, system, equipment and medium - Google Patents
Quota control method, device, system, equipment and medium Download PDFInfo
- Publication number
- CN115543953A CN115543953A CN202211147560.0A CN202211147560A CN115543953A CN 115543953 A CN115543953 A CN 115543953A CN 202211147560 A CN202211147560 A CN 202211147560A CN 115543953 A CN115543953 A CN 115543953A
- Authority
- CN
- China
- Prior art keywords
- quota
- file
- application
- directory
- written
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 276
- 230000008569 process Effects 0.000 claims abstract description 227
- 230000007717 exclusion Effects 0.000 claims abstract description 60
- 238000012545 processing Methods 0.000 claims description 90
- 238000004590 computer program Methods 0.000 claims description 17
- 230000007246 mechanism Effects 0.000 abstract description 9
- 238000010586 diagram Methods 0.000 description 9
- 238000004891 communication Methods 0.000 description 8
- 230000009286 beneficial effect Effects 0.000 description 6
- 238000005516 engineering process Methods 0.000 description 6
- 230000003993 interaction Effects 0.000 description 4
- 230000003287 optical effect Effects 0.000 description 3
- 230000006870 function Effects 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000008901 benefit Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 239000011521 glass Substances 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000010801 machine learning Methods 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000001953 sensory effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/18—File system types
- G06F16/182—Distributed file systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/13—File access structures, e.g. distributed indices
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/172—Caching, prefetching or hoarding of files
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a quota control method, a quota control device, a quota control system, quota control equipment and quota control media. The method comprises the following steps: acquiring a file to be written, an application quota corresponding to the file to be written, and a directory identifier of a target directory; acquiring an unused application quota corresponding to a target directory from a local quota file through a first file writing process according to a directory identifier, and judging whether the unused application quota is larger than or equal to the application quota or not; if not, acquiring a mutual exclusion lock of the local quota file through a first file writing process, updating the file state of the local quota file into an application state, and sending a quota application request to quota control equipment; and if the prompt information of successful application is received, writing the file to be written into the target directory through a first file writing process, releasing the exclusive lock of the local quota file, and updating the file state to a non-application state. The embodiment of the invention can execute a mechanism of applying quota first and then writing in the process of writing in the file.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a quota control method, apparatus, system, device, and medium.
Background
A distributed storage system may be comprised of multiple clients, quota control devices, and storage devices. A plurality of directories are set in the storage device. A quota is set for each directory. The quota of a directory may be a space quota or a quantity quota. The space quota is an upper limit on the size of the storage space used by the directory. The volume quota is an upper limit on the total number of files written to the directory. The quota control device is used for managing quotas of the directories. Once the size of the storage space used by each directory reaches the space quota or the total number of the files written into the directory reaches the quantity quota, the writing is immediately prohibited, so that the size of the storage space used by each directory does not exceed the space quota of each directory or the total number of the files written into the directory does not exceed the quantity quota of each directory.
In the related art, commonly used quota control schemes are: and each client acquires the available quota of each directory from the quota management module at regular time. The available quota is the size of the available storage space or the total number of files that can be stored. When a client needs to write a file into a specified directory, whether the available quota of the specified directory is enough to store the file is judged. If the available quota of the specified directory is smaller than the size of the storage space or the number of the files required to be occupied by the file, the client determines that the available quota of the specified directory is insufficient, the file cannot be written into the specified directory, and the file writing process fails. And if the available quota of the specified directory is larger than or equal to the size of the storage space or the number of the files required to be occupied, the client determines that the available quota of the specified directory is sufficient, and writes the files into the specified directory.
The related art has disadvantages in that: the mechanism for acquiring the available quota regularly can cause that the client cannot sense the actual situation of the written file in each directory within the interval time for acquiring the available quota of each directory twice. When a plurality of clients write files into a designated directory concurrently, the acquired available quota of the designated directory cannot be accurate in real time, which may cause the size of the storage space used by the designated directory to exceed the space quota of the designated directory, or the total number of files written into the directory by the designated directory to exceed the number quota of the designated directory. For example, after obtaining the size of the available storage space of the designated directory, the multiple clients simultaneously write a file, whose size of the available storage space needs to be occupied is equal to that of the available storage space of the designated directory, into the designated directory, so that the size of the storage space used by the designated directory exceeds the space quota of the designated directory.
Disclosure of Invention
The invention provides a quota control method, a device, a system, equipment and a medium, which are used for solving the problems that when a plurality of clients write files into an appointed directory concurrently, the acquired available quota of the appointed directory cannot be accurate in real time, the size of a storage space used by the appointed directory exceeds the space quota of the appointed directory, or the total number of files written into the directory by the appointed directory exceeds the number quota of the appointed directory in a quota control scheme in the related art.
According to an aspect of the present invention, a quota controlling method is provided, which is applied to a client in a distributed storage system, and includes:
acquiring a file to be written, an application quota corresponding to the file to be written, and a directory identifier of a target directory corresponding to the file to be written;
acquiring an unused application quota corresponding to the target directory from a local quota file through a first file writing process according to the directory identifier, and judging whether the unused application quota is larger than or equal to the application quota;
if the unused application quota is smaller than the application quota, acquiring a mutex lock of the local quota file through the first file write-in process, updating the file state of the local quota file to an application state, and sending a quota application request to quota control equipment, so that the quota control equipment feeds back application success prompt information or application failure prompt information according to the available quota of the target directory;
if the application success prompt message is received, the file to be written is written into the target directory through the first file writing process, the mutual exclusion lock of the local quota file is released, and the file state of the local quota file is updated to a non-application state.
According to another aspect of the present invention, there is provided a quota controlling method applied to a quota controlling device in a distributed storage system, including:
receiving a quota application request sent by a client; the quota application request carries an application quota corresponding to a file to be written in and a directory identifier of a target directory corresponding to the file to be written in;
acquiring a mutex lock of a directory quota file through a first request processing process, acquiring an available quota of the target directory from the directory quota file according to the directory identifier, and judging whether the available quota is greater than or equal to the application quota;
if the available quota is larger than or equal to the application quota, sending application success prompt information to the client through the first request processing process, updating the available quota according to the application quota, and releasing the exclusive lock of the directory quota file.
According to another aspect of the present invention, there is provided a quota controlling apparatus, configured in a client in a distributed storage system, including:
the file acquisition module is used for acquiring a file to be written, an application quota corresponding to the file to be written and a directory identifier of a target directory corresponding to the file to be written;
the quota judging module is used for acquiring an unused application quota corresponding to the target directory from a local quota file through a first file write-in process according to the directory identifier, and judging whether the unused application quota is larger than or equal to the application quota;
a quota application module, configured to obtain a mutex lock of the local quota file through the first file write-in process if the unused application quota is smaller than the application quota, update a file state of the local quota file to an application state, and send a quota application request to quota control equipment, so that the quota control equipment feeds back application success prompt information or application failure prompt information according to the available quota of the target directory;
and the file writing module is used for writing the file to be written into the target directory through the first file writing process if the application success prompt message is received, releasing the mutual exclusion lock of the local quota file, and updating the file state of the local quota file into a non-application state.
According to another aspect of the present invention, there is provided a quota controlling apparatus, configured in a quota controlling device in a distributed storage system, including:
the request receiving module is used for receiving a quota application request sent by a client; the quota application request carries an application quota corresponding to a file to be written in and a directory identifier of a target directory corresponding to the file to be written in;
an available quota judging module, configured to obtain a mutex lock of a directory quota file through a first request processing process, obtain an available quota of the target directory from the directory quota file according to the directory identifier, and judge whether the available quota is greater than or equal to the application quota;
and the first prompt module is used for sending application success prompt information to the client through the first request processing process if the available quota is greater than or equal to the application quota, updating the available quota according to the application quota, and releasing the mutex lock of the directory quota file.
According to another aspect of the present invention, there is provided a quota controlling system, including: a client and a quota control device in the distributed storage system;
the client is used for acquiring a file to be written, an application quota corresponding to the file to be written and a directory identifier of a target directory corresponding to the file to be written; acquiring an unused application quota corresponding to the target directory from a local quota file through a first file writing process according to the directory identifier, and judging whether the unused application quota is larger than or equal to the application quota; if the unused application quota is smaller than the application quota, acquiring a mutex lock of the local quota file through the first file write-in process, updating the file state of the local quota file into an application state, and sending a quota application request to quota control equipment, so that the quota control equipment feeds back application success prompt information or application failure prompt information according to the available quota of the target directory; if the prompt message of successful application is received, writing the file to be written into the target directory through the first file writing process, releasing the mutual exclusion lock of the local quota file, and updating the file state of the local quota file to be a non-application state;
the quota control equipment is used for receiving a quota application request sent by a client; the quota application request carries an application quota corresponding to a file to be written in and a directory identifier of a target directory corresponding to the file to be written in; acquiring a mutual exclusion lock of a directory quota file through a first request processing process, acquiring an available quota of the target directory from the directory quota file according to the directory identifier, and judging whether the available quota is greater than or equal to the application quota; if the available quota is larger than or equal to the application quota, sending application success prompt information to the client through the first request processing process, updating the available quota according to the application quota, and releasing the exclusive lock of the directory quota file.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor;
and a memory communicatively coupled to the at least one processor;
wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the quota controlling method according to any embodiment of the present invention.
According to another aspect of the present invention, there is provided a computer-readable storage medium storing computer instructions for causing a processor to implement the quota controlling method according to any embodiment of the present invention when the computer instructions are executed.
According to the technical scheme of the embodiment of the invention, the following operations are executed through a first file writing process by acquiring the file to be written, the application quota corresponding to the file to be written and the directory identifier of the target directory: acquiring an unused application quota corresponding to a target directory from a local quota file according to the directory identifier, and judging whether the unused application quota is greater than or equal to the application quota; if not, acquiring a mutual exclusion lock of the local quota file through a first file writing process, updating the file state of the local quota file into an application state, and sending a quota application request to quota control equipment; if the prompt information of successful application is received, a file to be written is written into a target directory through a first file writing process, a mutual exclusion lock of a local quota file is released, and the file state is updated to be a non-application state, so that the quota control scheme in the related technology is solved, when a plurality of clients write a file into an appointed directory concurrently, the obtained available quota of the appointed directory cannot be real-timely and accurately, the size of a storage space used by the appointed directory may exceed the space quota of the appointed directory, or the total number of files written into the directory by the appointed directory exceeds the number quota of the appointed directory, a mechanism that the clients apply for quota and then write in the file writing process is obtained, after the size of the storage space or the number of files that the clients apply for the file and need to occupy is determined, the file is written into the appointed directory, and the beneficial effect that the quota used by the clients can be accurately controlled not to exceed the size of the space of each directory or the number of written files to exceed the number of each directory is ensured.
According to the technical scheme of the embodiment of the invention, the local quota file in the client can be managed in a serialized mode based on the file state of the local quota file, and at most one process in the client is ensured to be in a quota application process in the same time.
According to the technical scheme of the embodiment of the invention, when the size of the unused storage space of the client or the number of the files is enough to write the files to be written, the files to be written are quickly written into the target directory, and the size of the unused storage space of the client or the number of the files is updated in time.
The technical scheme of the embodiment of the invention can serialize the available quotas of the management directories based on the mutual exclusion lock, ensure that the quota application request of at most one client is in the processing process in the same time, and ensure that the size of the storage space used by each directory can be accurately controlled not to exceed the space quota of each directory or the number of written files not to exceed the number quota of each directory.
According to the technical scheme of the embodiment of the invention, when the available quota of the directory is not enough to write the file to be written, the application failure prompt information prompts the client, the size of the storage space or the number of the files which need to be occupied by the file to be written is not applied, and the file cannot be written, so that the condition that the size of the storage space used by the directory exceeds the space quota of each directory or the number of the written files exceeds the number quota of each directory is effectively avoided.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present invention, nor do they necessarily limit the scope of the invention. Other features of the present invention will become apparent from the following description.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a flowchart of a quota controlling method according to an embodiment of the present invention.
Fig. 2 is a flowchart of a quota controlling method according to a second embodiment of the present invention.
Fig. 3 is a flowchart of a quota controlling method according to a third embodiment of the present invention.
Fig. 4 is a schematic structural diagram of a quota control apparatus according to a fourth embodiment of the present invention.
Fig. 5 is a schematic structural diagram of a quota control apparatus according to a fifth embodiment of the present invention.
Fig. 6 is a schematic structural diagram of a quota control system according to a sixth embodiment of the present invention.
Fig. 7 is a schematic structural diagram of an electronic device implementing the quota control method according to the embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, shall fall within the protection scope of the present invention.
It should be noted that the terms "object," "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in other sequences than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example one
Fig. 1 is a flowchart of a quota control method according to an embodiment of the present invention. The embodiment can be applied to the situation that the size of the storage space used by each directory does not exceed the space quota of each directory or the total number of the files written into the directory does not exceed the number quota of each directory in the process that the client writes the files into the designated directory in the distributed storage system. The method may be performed by a quota controlling apparatus, which may be implemented in hardware and/or software, and which may be configured in a client in a distributed storage system.
A distributed storage system may be comprised of multiple clients, a quota management device, and a storage device. Information interaction can be carried out between the client and the quota management device. Information interaction can be carried out between the client and the storage device. The client may access the storage device and write the file to a directory in the storage device.
A storage device is an electronic device for storing files. Such as a server for storing files. A plurality of directories are set in the storage device. A directory can be viewed as a virtual container that holds files. The file written in the directory is the file under the directory. A quota is set for each directory. The quota of a directory may be a space quota or a volume quota. The space quota is the upper limit of the storage space used by the directory. The volume quota is an upper limit on the total number of files written to the directory.
The client is used for interacting with a user, acquiring a file which is specified by the user and needs to be stored in the directory, and writing the file into the specified directory.
The quota management device is an electronic device for managing quotas of directories in the distributed storage system. For example, a server for managing quotas for directories. The quota management device is used for managing quotas of the directories, and ensuring that the size of storage space used by the directories does not exceed the space quota of the directories or the total number of files written into the directories does not exceed the number quota of the directories.
As shown in fig. 1, the method includes:
Optionally, the file to be written is one or more files that need to be written into the target directory. And the application quota corresponding to the file to be written is the size of the storage space or the number of files required to be occupied by the file to be written. And the target directory corresponding to the file to be written is the directory to which the file to be written needs to be written. The target directory is a directory set in the storage device. The directory identification is identification information for uniquely identifying a directory. Different directories correspond to different directory identifiers.
Optionally, the user uploads a file to be written, an application quota corresponding to the file to be written, and a directory identifier of a target directory corresponding to the file to be written to the client. The client acquires a file to be written, an application quota corresponding to the file to be written, and a directory identifier of a target directory corresponding to the file to be written.
Optionally, the quota of the target directory may be a space quota of the target directory. The space quota is an upper limit on the size of the storage space used by the directory. And the application quota corresponding to the file to be written is the size of the storage space occupied by the file to be written. The available quota of the target directory is the size of the available storage space. The available storage space size is the size of storage space that the remaining target directory may use. The available storage size of the target directory is the difference between the space quota of the target directory and the used storage size of the target directory. The used storage space size is the size of the storage space used by the target directory, i.e., the size of the storage space occupied by all files written to the directory. For example, the space quota of the directory is 10G, the application quota corresponding to the file to be written is 3G, and the size of the used storage space of the directory is 2G. The available storage space size of the directory may be determined to be 8G.
Optionally, the quota of the target directory may be a quota of the number of target directories. The volume quota is an upper limit on the total number of files written to the directory. The application quota corresponding to the file to be written is the number of files that the file to be written needs to occupy, that is, the number of files contained in the file to be written. The available quota of the target directory is the total number of files that can be stored. The total number of storable files is the number of files remaining that can be written to the target directory. The total number of files that can be stored in the target directory is the difference between the quota of the number of target directories and the total number of files that can be stored in the target directory. The total number of stored files is the total number of files that have been written to the target directory. For example, the quota of the number of directories is 2000, the application quota corresponding to the file to be written is 300, and the total number of stored files is 400. The total number of storable files for the directory may be determined to be 1600.
And step 102, acquiring an unused application quota corresponding to the target directory from a local quota file through a first file writing process according to the directory identifier, and judging whether the unused application quota is larger than or equal to the application quota.
Optionally, the client includes a plurality of file writing processes. The file writing process is a process written by a developer and arranged in a client for writing a file into a specified directory.
Optionally, the client may invoke a file writing process, and execute the following operations through the file writing process: acquiring an unused application quota corresponding to a directory from a local quota file according to a directory identifier of the directory corresponding to the file, and judging whether the unused application quota is larger than or equal to the application quota corresponding to the file or not; if the unused application quota is smaller than the application quota, acquiring a mutual exclusion lock of the local quota file, updating the file state of the local quota file to be an application state, and sending a quota application request to quota control equipment, so that the quota control equipment feeds back application success prompt information or application failure prompt information according to the available quota of the directory; if the prompt message of successful application is received, writing the file into a directory, releasing a mutual exclusion lock of the local quota file, and updating the file state of the local quota file into a non-application state; if the application failure prompt message is received, determining that the file writing process fails, releasing a mutual exclusion lock of the local quota file, and updating the file state of the local quota file to be a non-application state; and if the unused application quota is more than or equal to the application quota, writing the file into the directory, and updating the unused application quota according to the application quota.
Optionally, the first file writing process is a process for writing the file to be written into the target directory. After acquiring a file to be written, an application quota corresponding to the file to be written, and a directory identifier of a target directory corresponding to the file to be written, a client randomly determines a file writing process in an unrecalled file writing process as a first file writing process, and calls the first file writing process.
Optionally, the obtaining, by the first file writing process and according to the directory identifier, an unused application quota corresponding to the target directory from the local quota file includes: the following operations are performed by the first file write process: determining a file state of a local quota file; the local quota file is used for storing quotas of all directories and unused application quotas of the client; the file state is an application state or a non-application state; if the file state is a non-application state, acquiring an unused application quota corresponding to the target directory from an unused application quota of the client stored in the local quota file according to the directory identifier; the unused application quota of the client comprises unused application quotas corresponding to all directories; and if the file state is an application state, determining that acquisition of the unused application quota corresponding to the target directory fails.
Therefore, based on the file state of the local quota file, the local quota file in the management client side is serialized, and at most one process in the client side is ensured to be in a quota application process in the same time.
Optionally, the local quota file is a file used for storing quotas of the directories and unused application quotas of the clients.
Optionally, the quota of each directory is a space quota or a quantity quota of each directory. The space quota is an upper limit on the amount of storage space used by the directory. The volume quota is an upper limit on the total number of files written to the directory. The local quota file correspondingly stores the directory identification and quota of each directory.
Optionally, the unused application quota of the client includes an unused application quota corresponding to each directory. The unused application quota corresponding to each directory is the size of the storage space or the number of files which are not used by the client after the client applies for the file from each directory. The local quota file correspondingly stores the directory identification of each directory and the unused application quota corresponding to each directory.
Optionally, after acquiring the quota of each directory input by the user, the quota management device creates a file, and stores the quota of each directory and the unused application quota of the client in the initial state in the file, so as to obtain a local quota file. And then the quota management device sends the local quota file to each client. In the initial state, all the unused application quotas corresponding to the directories and contained in the unused application quotas of the client are 0. And when the unused application quota corresponding to each directory changes, the client updates the available quota of each directory.
Optionally, each client receives a local quota file sent by the quota management device, stores the local quota file in a local database of the client, and creates a mutual exclusion lock of the local quota file.
The mutual exclusion lock of the local quota file can be acquired by at most one process in the same time, and only after the process which acquires the mutual exclusion lock of the local quota file releases the mutual exclusion lock of the local quota file, other processes can acquire the mutual exclusion lock of the local quota file. After a process acquires the mutual exclusion lock of the local quota file, only the process can read or modify data in the local quota file. Other processes need to wait until the processes release the mutual exclusion lock of the local quota file before reading or modifying the data in the local quota file.
Optionally, the file state of the local quota file is information, which is set in the client and used for characterizing whether a process is in a quota application process, and acquiring a mutual exclusion lock of the local quota file. The application state is used for representing that a process is in a quota application process, a mutual exclusion lock of the local quota file is acquired, and other processes cannot read or modify data in the local quota file. The non-application state is used for representing that no process is in the quota application process and acquires the mutual exclusion lock of the local quota file, and other processes cannot read or modify data in the local quota file.
Optionally, if the file state is a non-application state, which indicates that no process is in the quota application process and that a mutex lock of the local quota file has been acquired, and data in the local quota file may be read or modified, an unused application quota corresponding to the target directory is acquired in an unused application quota of the client stored in the local quota file according to the directory identifier. The unused application quotas of the client comprise the unused application quotas corresponding to the directories.
Optionally, in the directory identifier of each directory stored in the local quota file, a target directory identifier that is the same as the directory identifier of the target directory is queried. And then determining the unused application quota corresponding to the inquired target directory identifier as the unused application quota corresponding to the target directory. And the unused application quota corresponding to the directory identifier of the target directory is the unused application quota corresponding to the target directory. The unused application quota corresponding to the target directory is the size of the unused storage space or the number of files after the client applies from the target directory.
Optionally, if the target directory identifier that is the same as the directory identifier of the target directory is not queried, it is determined that acquisition of the unused application quota corresponding to the target directory fails, and the file writing process is ended.
Optionally, if the file state is an application state, it indicates that a process is in a quota application process, and a mutex lock of the local quota file is acquired, and data in the local quota file cannot be read or modified. For example, a second file write process in the client acquires a mutual exclusion lock of the local quota file, updates a file state of the local quota file to an application state, and sends a quota application request to quota control equipment. The second file writing process is in the quota applying process and acquires the mutual exclusion lock of the local quota file. The first file write process cannot read or modify data in the local quota file. Therefore, if the file state is the application state, it is determined that the acquisition of the unused application quota corresponding to the target directory fails, and the current file writing process is ended.
Optionally, the quota of the target directory is a space quota of the target directory. And the unused application quota corresponding to the target directory is the size of the unused storage space after the client applies for the target directory. And the application quota corresponding to the file to be written is the size of the storage space occupied by the file to be written. And judging whether the unused application quota is larger than or equal to the application quota, namely judging whether the size of the unused storage space is larger than or equal to the size of the storage space occupied by the file to be written after the client applies from the target directory.
If the unused application quota is larger than or equal to the application quota, that is, after the client applies for the file from the target directory, the size of the unused storage space is larger than or equal to the size of the storage space occupied by the file to be written. Therefore, after the client applies for the file from the target directory, the size of the unused storage space is determined to be enough to write the file to be written, and the file to be written can be directly written into the target directory.
If the unused application quota is smaller than the application quota, that is, after the client applies for the unused application quota from the target directory, the size of the unused storage space is smaller than the size of the storage space occupied by the file to be written. Therefore, after the client applies for the file from the target directory, the size of the unused storage space is determined to be not enough to write the file to be written, and then quota application is continued.
Optionally, the quota of the target directory is a quota of the number of the target directories. And the unused application quota corresponding to the target directory is the number of files which are not used after the client applies for the target directory. And the application quota corresponding to the file to be written is the number of files required to be occupied by the file to be written. And judging whether the unused application quota is larger than or equal to the application quota, namely judging whether the number of the files which are not used after the client applies from the target directory is larger than or equal to the number of the files which need to be occupied by the files to be written.
If the unused application quota is larger than or equal to the application quota, that is, after the client applies for the file from the target directory, the number of the files which are not used yet is larger than or equal to the number of the files which need to be occupied by the file to be written. Therefore, the number of the unused files is enough to be written into the file to be written after the client applies for the file from the target directory, and the file to be written can be directly written into the target directory.
If the unused application quota is smaller than the application quota, that is, after the client applies for the unused file from the target directory, the number of the unused files is smaller than the number of the files to be occupied by the file to be written. Therefore, after the client applies for the file from the target directory, the number of the unused files is determined to be not enough to write the file to be written, and then quota application is continued.
Optionally, after the first file writing process acquires the mutual exclusion lock of the local quota file, only the first file writing process may read or modify data in the local quota file. And other processes need to wait for the first file writing process to complete the quota application process, and can read or modify the data in the local quota file after the mutual exclusion lock of the local quota file is released. Therefore, based on the mutual exclusion lock and the file state of the local quota file, the local quota file in the management client is serialized, and only the first file writing process in the client is ensured to be in the quota application process at the current moment.
Optionally, the quota application request is a request for applying for a quota corresponding to the file to be written. And the application quota corresponding to the file to be written is the size of the storage space or the number of files required to be occupied by the file to be written.
Optionally, the quota control device receives a quota application request sent by the client; the quota application request carries an application quota corresponding to a file to be written in and a directory identifier of a target directory corresponding to the file to be written in; the quota control equipment acquires a mutual exclusion lock of a directory quota file through a first request processing process, acquires an available quota of the target directory from the directory quota file according to the directory identifier, and judges whether the available quota is greater than or equal to the application quota; if the available quota is larger than or equal to the application quota, the quota control device sends application success prompt information to the client through the first request processing process, updates the available quota according to the application quota, and releases a mutual exclusion lock of the directory quota file; and if the available quota is smaller than the application quota, sending application failure prompt information to the client through the first request processing process, and releasing the mutual exclusion lock of the directory quota file.
Optionally, the quota controlling device includes a plurality of request processing processes. The request processing process is a process which is written by a developer and arranged in the quota control device and is used for processing a quota application request sent by the client and determining whether the client can apply for a quota corresponding to a file to be written.
Optionally, the quota controlling device may invoke the request processing process, and execute the following operations through the request processing process: acquiring a mutual exclusion lock of the directory quota file, acquiring an available quota of the target directory from the directory quota file according to the directory identifier, and judging whether the available quota is greater than or equal to the application quota; if the available quota is larger than or equal to the application quota, sending application success prompt information to the client, updating the available quota according to the application quota, and releasing a mutual exclusion lock of the directory quota file; and if the available quota is smaller than the application quota, sending application failure prompt information to the client through the first request processing process, and releasing the mutual exclusion lock of the directory quota file.
Optionally, the first request processing process is a process for processing the quota application request and determining whether the client can apply for a quota application corresponding to the file to be written. After receiving the quota application request sent by the client, the quota control device randomly determines a request processing process in the request processing processes which are not called, and the request processing process serves as a first request processing process, and calls the first request processing process.
Optionally, the directory quota file is a file for storing an available quota of each directory. The available quota of each directory is the size of the available storage space of each directory or the total number of files that can be stored. The available storage size is the size of the storage space available for the remaining directories. The total number of storable files is the number of files remaining that can be written to the directory. After acquiring the quota of each directory input by the user, the quota management device creates a file, and correspondingly stores the directory identifier of each directory and the available quota in the initial state into the file to obtain a directory quota file. In the initial state, the available quota of each directory is equal to the quota of each directory. When the available quota of each directory changes, the quota management device updates the available quota of each directory.
Optionally, the quota management device stores the directory quota file in a local database of the quota management device, and creates a mutually exclusive lock of the directory quota file. The exclusive lock of the directory quota file can be acquired by only one process at most in the same time, and only after the process which acquires the exclusive lock of the directory quota file releases the exclusive lock of the directory quota file, other processes can acquire the exclusive lock of the directory quota file. After a process acquires the mutual exclusion lock of the directory quota file, only the process can read or modify the data in the directory quota file. Other processes need to wait until the processes release the mutual exclusion lock of the directory quota file before reading or modifying the data in the directory quota file.
Optionally, after the first request processing process obtains the mutex lock of the directory quota file, only the first request processing process may read or modify data in the directory quota file. The other processes need to wait for the first request processing process to complete the request processing process, and can read or modify the data in the directory quota file after releasing the mutual exclusion lock of the directory quota file. Therefore, based on the mutual exclusion lock and the file state of the directory quota file, the directory quota file in the client is managed in a serialized mode, and only the first request processing process in the client is ensured to be in the request processing process at the current moment.
Optionally, the quota control device obtains a mutex lock of the directory quota file through the first request processing process, and obtains an available quota of the target directory from the directory quota file according to the directory identifier.
Optionally, in the directory identifier of each directory stored in the directory quota file, a target directory identifier that is the same as the directory identifier of the target directory is queried. And then determining the available quota corresponding to the inquired target directory identifier as the available quota corresponding to the target directory. And the available quota corresponding to the directory identifier of the target directory is the available quota corresponding to the target directory.
Optionally, the quota of the target directory is a space quota of the target directory. The unused application quota corresponding to the target directory is the size of the unused storage space after the client applies from the target directory. And the application quota corresponding to the file to be written is the size of the storage space occupied by the file to be written. The unused application quota is smaller than the application quota, that is, after the client applies for the file from the target directory, the size of the unused storage space is smaller than the size of the storage space occupied by the file to be written, which indicates that after the client applies for the file from the target directory, the size of the unused storage space is not enough to write the file to be written, and the quota application needs to be continued.
Therefore, the client acquires the exclusive lock of the local quota file through the first file writing process, updates the file state of the local quota file to the application state, and sends a quota application request to the quota control device. And the quota application request is used for applying for the size of the storage space occupied by the file to be written. And the quota application request carries the size of the storage space occupied by the file to be written and the directory identifier of the target directory corresponding to the file to be written.
And the quota control equipment acquires a mutual exclusion lock of a directory quota file through a first request processing process, acquires the size of the available storage space of the target directory from the directory quota file according to the directory identifier, and judges whether the size of the available storage space is larger than or equal to the size of the storage space occupied by the file to be written. And if the size of the available storage space is larger than or equal to the size of the storage space occupied by the file to be written, the quota control equipment sends application success prompt information to the client through the first request processing process, updates the size of the available storage space according to the size of the storage space occupied by the file to be written, and releases the exclusive lock of the directory quota file. And if the size of the available storage space is smaller than that of the storage space occupied by the file to be written, sending application failure prompt information to the client through the first request processing process, and releasing the exclusive lock of the directory quota file.
Optionally, the application success notification message is a preset message for prompting that the quota application request is successfully applied. And the client determines the size of the storage space required to be occupied by the file to be written in the file to be successfully applied according to the application success prompt information.
Optionally, the application failure prompt message is a preset message for prompting that the quota application request fails to apply. And the target client does not apply for the size of the storage space occupied by the file to be written according to the application failure prompt information.
Optionally, updating the size of the available storage space according to the size of the storage space that needs to be occupied by the file to be written, including: and subtracting the size of the storage space occupied by the file to be written from the size of the available storage space of the target directory stored in the directory quota file.
Optionally, the quota of the target directory is a quota of the number of target directories. And the unused application quota corresponding to the target directory is the number of files which are not used after the client applies for the target directory. And the application quota corresponding to the file to be written is the number of files required to be occupied by the file to be written. The unused application quota is smaller than the application quota, that is, after the client applies for the file from the target directory, the number of the unused files is smaller than the number of the files to be written in, which indicates that after the client applies for the file from the target directory, the number of the unused files is not enough to be written in the file to be written in, and the quota application needs to be continued.
Therefore, the client acquires the exclusive lock of the local quota file through the first file writing process, updates the file state of the local quota file to the application state, and sends a quota application request to the quota control device. And the quota application request is used for applying for the number of the files to be occupied by the file to be written. And the quota application request carries the number of files required to be occupied by the file to be written and the directory identifier of the target directory corresponding to the file to be written.
And the quota control equipment acquires a mutual exclusion lock of the directory quota file through a first request processing process, acquires the total number of the files which can be stored in the target directory from the directory quota file according to the directory identifier, and judges whether the total number of the files which can be stored is greater than or equal to the number of the files which need to be occupied by the files to be written. If the total number of the files which can be stored is larger than or equal to the number of the files which need to be occupied by the file to be written, the quota control equipment sends application success prompt information to the client through the first request processing process, updates the total number of the files which can be stored according to the number of the files which need to be occupied by the file to be written, and releases the exclusive lock of the directory quota file. And if the total number of the files which can be stored is less than the number of the files which need to be occupied by the file to be written, sending application failure prompt information to the client through the first request processing process, and releasing the exclusive lock of the directory quota file.
Optionally, the application success prompt message is a preset message for prompting that the quota application request is successfully applied. And the client determines the number of files required to be occupied when the file to be written is successfully applied according to the application success prompt information.
Optionally, the application failure prompt message is a preset message for prompting that the quota application request fails to apply. And the target client does not apply for the number of files to be occupied by the file to be written according to the application failure prompt information.
Optionally, updating the total number of the files that can be stored according to the number of the files that need to be occupied by the file to be written includes: and subtracting the number of files occupied by the file to be written from the total number of the files of the target directory stored in the directory quota file.
And step 104, if the prompt message of successful application is received, writing the file to be written into the target directory through the first file writing process, releasing the mutual exclusion lock of the local quota file, and updating the file state of the local quota file to be a non-application state.
Optionally, if the application success prompt message is received, the file to be written is written into the target directory through the first file writing process, the mutex lock of the local quota file is released, and the file state of the local quota file is updated to a non-application state. And if the application success prompt information is received and indicates that the application is successful and the number of the files occupied by the to-be-written file is required, the client writes the to-be-written file into the target directory through a first file writing process, releases the mutual exclusion lock of the local quota file, and updates the file state of the local quota file to be in a non-application state, thereby completing a quota application process and a file writing process.
Optionally, if the application failure prompt information is received, the mutex lock of the local quota file is released through a first file write-in process, and the file state of the local quota file is updated to a non-application state. If the application failure prompt message is received, the fact that the number of the files which need to be occupied by the to-be-written file is not applied is indicated, the to-be-written file cannot be written into the target directory, and the file writing process fails, the client releases the mutual exclusion lock of the local quota file through a first file writing process, the file state of the local quota file is updated to be a non-application state, and therefore the quota application process and the file writing process are finished.
Optionally, after determining whether the unused application quota is greater than or equal to the application quota, the method further includes: if the unused application quota is larger than or equal to the application quota, the file to be written is written into the target directory through the first file writing process, and the unused application quota is updated according to the application quota.
If the unused application quota is larger than or equal to the application quota, the size of the unused storage space is larger than or equal to the size of the storage space occupied by the file to be written after the client applies from the target directory, or the number of the unused files is larger than or equal to the number of the files occupied by the file to be written after the client applies from the target directory. Therefore, after the client applies for the file from the target directory, the size of the unused storage space or the number of the files is determined to be enough to write the file to be written, and the file to be written can be directly written into the target directory.
Optionally, updating the unused application quota according to the application quota includes: subtracting the application quota from the unused application quota corresponding to the target directory stored in the local quota file.
Therefore, when the size of the unused storage space or the number of files of the client is enough to write the file to be written, the file to be written is quickly written into the target directory, and the size of the unused storage space or the number of files of the client is updated in time.
According to the technical scheme of the embodiment of the invention, the following operations are executed through a first file writing process by acquiring the file to be written, the application quota corresponding to the file to be written and the directory identifier of the target directory: acquiring an unused application quota corresponding to a target directory from a local quota file according to the directory identifier, and judging whether the unused application quota is greater than or equal to the application quota; if not, acquiring a mutual exclusion lock of the local quota file through the first file writing process, updating the file state of the local quota file into an application state, and sending a quota application request to quota control equipment; if the application success prompt message is received, a file to be written is written into a target directory through a first file writing process, a mutex lock of a local quota file is released, and the file state is updated to a non-application state, so that the quota control scheme in the related technology is solved, when a plurality of clients write a file into an appointed directory concurrently, the problem that the size of a storage space used by the appointed directory exceeds the space quota of the appointed directory or the total number of files written into the directory by the appointed directory exceeds the number quota of the appointed directory due to the fact that the obtained available quota of the appointed directory cannot be accurate in real time is solved, a mechanism that the client applies for quota and then writes in the file writing process is obtained, after the size of the storage space required to be occupied by the file or the number of files is determined by the client, the file is written into the appointed directory, and the advantage that the quota used by each directory cannot be accurately controlled to exceed the size of the space of each directory or the number of written files to exceed the number of each directory is ensured.
Example two
Fig. 2 is a flowchart of a quota controlling method according to a second embodiment of the present invention. The embodiment can be applied to the situation that the size of the storage space used by each directory does not exceed the space quota of each directory or the total number of the files written into the directory does not exceed the number quota of each directory in the process that the client writes the files into the designated directory in the distributed storage system. The method may be performed by a quota control apparatus, which may be implemented in hardware and/or software, and which may be configured in a quota management device in a distributed storage system.
As shown in fig. 2, the method includes:
The quota application request carries an application quota corresponding to a file to be written in and a directory identifier of a target directory corresponding to the file to be written in.
Optionally, the quota application request is a request for applying for a quota corresponding to the file to be written. The application quota corresponding to the file to be written is the size of the storage space or the number of files required to be occupied by the file to be written.
Optionally, the quota controlling device includes a plurality of request processing processes. The request processing process is a process which is compiled by a developer and is arranged in the quota control device and used for processing a quota application request sent by the client and determining whether the client can apply for a quota application corresponding to a file to be written.
Optionally, the quota controlling device may invoke the request processing process, and execute the following operations through the request processing process: acquiring a mutual exclusion lock of the directory quota file, acquiring an available quota of the target directory from the directory quota file according to the directory identifier, and judging whether the available quota is greater than or equal to the application quota; if the available quota is larger than or equal to the application quota, sending application success prompt information to the client, updating the available quota according to the application quota, and releasing a mutual exclusion lock of the directory quota file; and if the available quota is smaller than the application quota, sending application failure prompt information to the client through the first request processing process, and releasing the mutual exclusion lock of the directory quota file.
Optionally, the first request processing process is a process for processing the quota application request and determining whether the client can apply for a quota application corresponding to the file to be written. After receiving the quota application request sent by the client, the quota control device randomly determines a request processing process in the non-invoked request processing processes as a first request processing process, and invokes the first request processing process.
Optionally, the directory quota file is a file for storing an available quota of each directory. The available quota of each directory is the size of the available storage space of each directory or the total number of files that can be stored. The available storage size is the size of the storage space available for the remaining directories. The total number of storable files is the number of files remaining that can be written to the directory. After acquiring the quota of each directory input by the user, the quota management device creates a file, and correspondingly stores the directory identifier of each directory and the available quota in the initial state into the file to obtain a directory quota file. In the initial state, the available quota of each directory is equal to the quota of each directory. When the available quota of each directory changes, the quota management device updates the available quota of each directory.
Optionally, the quota management device stores the directory quota file in a local database of the quota management device, and creates a mutual exclusion lock of the directory quota file. The exclusive lock of the directory quota file can be acquired by only one process at most in the same time, and only after the process which acquires the exclusive lock of the directory quota file releases the exclusive lock of the directory quota file, other processes can acquire the exclusive lock of the directory quota file. After a process acquires the mutual exclusion lock of the directory quota file, only the process can read or modify the data in the directory quota file. Other processes need to wait until the processes release the mutual exclusion lock of the directory quota file before reading or modifying the data in the directory quota file.
Optionally, after the first request processing process obtains the mutex lock of the directory quota file, only the first request processing process may read or modify data in the directory quota file. The other processes need to wait for the first request processing process to complete the request processing process, and can read or modify the data in the directory quota file after releasing the mutual exclusion lock of the directory quota file. Therefore, based on the mutual exclusion lock and the file state of the directory quota file, the directory quota file in the client is managed in a serialized mode, and only the first request processing process in the client is ensured to be in the request processing process at the current moment.
Optionally, the quota control device obtains a mutual exclusion lock of the directory quota file through the first request processing process, and obtains an available quota of the target directory from the directory quota file according to the directory identifier.
Optionally, in the directory identifier of each directory stored in the directory quota file, a target directory identifier that is the same as the directory identifier of the target directory is queried. And then determining the available quota corresponding to the inquired target directory identifier as the available quota corresponding to the target directory. And the available quota corresponding to the directory identifier of the target directory is the available quota corresponding to the target directory.
Optionally, the quota of the target directory is a space quota of the target directory. The unused application quota corresponding to the target directory is the size of the unused storage space after the client applies from the target directory. And the application quota corresponding to the file to be written is the size of the storage space occupied by the file to be written. The unused application quota is smaller than the application quota, that is, after the client applies for the file from the target directory, the size of the unused storage space is smaller than the size of the storage space occupied by the file to be written, which indicates that after the client applies for the file from the target directory, the size of the unused storage space is not enough to write the file to be written, and the quota application needs to be continued.
Therefore, the client acquires the exclusive lock of the local quota file through the first file writing process, updates the file state of the local quota file to the application state, and sends a quota application request to the quota control device. And the quota application request is used for applying for the size of the storage space occupied by the file to be written. And the quota application request carries the size of the storage space required to be occupied by the file to be written and the directory identifier of the target directory corresponding to the file to be written.
And the quota control equipment acquires a mutual exclusion lock of a directory quota file through a first request processing process, acquires the size of the available storage space of the target directory from the directory quota file according to the directory identifier, and judges whether the size of the available storage space is larger than or equal to the size of the storage space occupied by the file to be written.
Optionally, the quota of the target directory is a quota of the number of the target directories. And the unused application quota corresponding to the target directory is the number of files which are not used after the client applies for the target directory. And the application quota corresponding to the file to be written is the number of files required to be occupied by the file to be written. The unused application quota is smaller than the application quota, that is, after the client applies for the file from the target directory, the number of the unused files is smaller than the number of the files to be occupied by the file to be written, which indicates that after the client applies for the file from the target directory, the number of the unused files is not enough to write the file to be written, and the quota application needs to be continued.
Therefore, the client acquires the exclusive lock of the local quota file through the first file writing process, updates the file state of the local quota file to the application state, and sends a quota application request to the quota control device. And the quota application request is used for applying the number of the files to be written in, which need to be occupied. And the quota application request carries the number of files required to be occupied by the file to be written and the directory identifier of the target directory corresponding to the file to be written.
And the quota control equipment acquires a mutual exclusion lock of the directory quota file through a first request processing process, acquires the total number of the files which can be stored in the target directory from the directory quota file according to the directory identifier, and judges whether the total number of the files which can be stored is greater than or equal to the number of the files which need to be occupied by the files to be written.
Optionally, after determining whether the available quota is greater than or equal to the application quota, the method further includes: and if the available quota is smaller than the application quota, sending application failure prompt information to the client through the first request processing process, and releasing the exclusive lock of the directory quota file.
Therefore, when the available quota of the directory is not enough to write the file to be written, the application failure prompt information prompts the client, the size of the storage space or the number of the files which need to be occupied by the file to be written is not applied, and the file cannot be written, so that the condition that the size of the storage space used by the directory exceeds the space quota of each directory or the number of the written files exceeds the number quota of each directory is effectively avoided.
Optionally, if the size of the available storage space is greater than or equal to the size of the storage space that needs to be occupied by the file to be written, the quota control device sends application success prompt information to the client through the first request processing process, updates the size of the available storage space according to the size of the storage space that needs to be occupied by the file to be written, and releases the exclusive lock of the directory quota file. And if the size of the available storage space is smaller than the size of the storage space occupied by the file to be written, sending application failure prompt information to the client through the first request processing process, and releasing the exclusive lock of the directory quota file.
Optionally, the application success prompt message is a preset message for prompting that the quota application request is successfully applied. And the client determines the size of the storage space required to be occupied by the file to be written in the file to be successfully applied according to the application success prompt information.
Optionally, the application failure prompt message is a preset message for prompting that the quota application request fails to apply. And the target client does not apply for the size of the storage space occupied by the file to be written according to the application failure prompt information.
Optionally, updating the size of the available storage space according to the size of the storage space that needs to be occupied by the file to be written, including: and subtracting the size of the storage space occupied by the file to be written from the size of the available storage space of the target directory stored in the directory quota file.
Optionally, if the total number of the storable files is greater than or equal to the number of files that needs to be occupied by the file to be written, the quota control device sends application success prompt information to the client through the first request processing process, updates the total number of the storable files according to the number of files that needs to be occupied by the file to be written, and releases the exclusive lock of the directory quota file. And if the total number of the files which can be stored is less than the number of the files which need to be occupied by the file to be written, sending application failure prompt information to the client through the first request processing process, and releasing the exclusive lock of the directory quota file.
Optionally, the application success prompt message is a preset message for prompting that the quota application request is successfully applied. And the client determines the number of files required to be occupied when the file to be written is successfully applied according to the application success prompt information.
Optionally, the application failure prompt message is a preset message for prompting that the quota application request fails to apply. And the target client does not apply for the number of files to be occupied by the file to be written according to the application failure prompt information.
Optionally, updating the total number of the files that can be stored according to the number of the files that need to be occupied by the file to be written, includes: and subtracting the number of files occupied by the file to be written from the total number of the files of the target directory stored in the directory quota file.
According to the technical scheme of the embodiment of the invention, a quota application request sent by a client is received; then, through a first request processing process, obtaining a mutual exclusion lock of a directory quota file, obtaining an available quota of the target directory from the directory quota file according to the directory identifier, and judging whether the available quota is greater than or equal to the application quota; when the available quota is larger than or equal to the application quota, sending application success prompt information to the client through the first request processing process, updating the available quota according to the application quota, and releasing a mutually exclusive lock of the directory quota file, so that a quota control scheme in the related technology is solved, when a plurality of clients concurrently write files into a specified directory, because the obtained available quota of the specified directory cannot be real-time accurate, the size of a storage space used by the specified directory may exceed the space quota of the specified directory, or the total number of files written into the directory by the specified directory exceeds the quantity quota of the specified directory, the available quota of the managed directory based on the mutually exclusive lock is obtained, the quota application request of at most one client is ensured to be in the processing process in the same time, a mechanism that the client applies the quota first and then writes the file in the file writing process can be controlled, and the client writes the file into the specified directory after determining that the storage space size or the number of files required to be occupied by the file applied from a quota control device is not more than the quota application quota, and the beneficial effect that the quota of controlling the storage space size of each directory by the client or the number of files written in the quota does not exceed the file is ensured.
EXAMPLE III
Fig. 3 is a flowchart of a quota controlling method provided in the third embodiment of the present invention, including the following steps:
The quota application request carries an application quota corresponding to a file to be written in and a directory identifier of a target directory corresponding to the file to be written in.
According to the technical scheme of the embodiment of the invention, the quota control equipment is obtained, the available quotas of the management directories are serialized on the basis of the mutex lock, the quota application request of at most one client is ensured to be in the processing process in the same time, the client can execute a mechanism of firstly applying for the quotas and then writing in the file writing process, and the client writes the files into the specified directories after determining the size of the storage space or the number of the files required to be occupied by the files applied from the quota control equipment, so that the beneficial effect that the size of the storage space used by each directory can be accurately controlled not to exceed the space quota of each directory or the number of the written files does not exceed the number quota of each directory is ensured.
Example four
Fig. 4 is a schematic structural diagram of a quota controlling apparatus according to a fourth embodiment of the present invention. The apparatus may be configured in a client in a distributed storage system. As shown in fig. 4, the apparatus includes: a file acquisition module 401, a quota judging module 402, a quota applying module 403, and a file writing module 404.
The file acquisition module 401 is configured to acquire a file to be written, an application quota corresponding to the file to be written, and a directory identifier of a target directory corresponding to the file to be written; a quota determining module 402, configured to obtain, through a first file write-in process, an unused application quota corresponding to the target directory from a local quota file according to the directory identifier, and determine whether the unused application quota is greater than or equal to the application quota; a quota application module 403, configured to obtain, through the first file write-in process, a mutex lock of the local quota file, update a file state of the local quota file to an application state, and send a quota application request to quota control equipment, so that the quota control equipment feeds back application success prompt information or application failure prompt information according to an available quota of the target directory; a file writing module 404, configured to write the file to be written into the target directory through the first file writing process if the application success prompt information is received, release the exclusive lock of the local quota file, and update a file state of the local quota file to a non-application state.
According to the technical scheme of the embodiment of the invention, the following operations are executed through a first file writing process by acquiring the file to be written, the application quota corresponding to the file to be written and the directory identifier of the target directory: acquiring an unused application quota corresponding to a target directory from a local quota file according to the directory identifier, and judging whether the unused application quota is greater than or equal to the application quota; if not, acquiring a mutual exclusion lock of the local quota file through a first file writing process, updating the file state of the local quota file into an application state, and sending a quota application request to quota control equipment; if the prompt information of successful application is received, a file to be written is written into a target directory through a first file writing process, a mutual exclusion lock of a local quota file is released, and the file state is updated to be a non-application state, so that the quota control scheme in the related technology is solved, when a plurality of clients write a file into an appointed directory concurrently, the obtained available quota of the appointed directory cannot be real-timely and accurately, the size of a storage space used by the appointed directory may exceed the space quota of the appointed directory, or the total number of files written into the directory by the appointed directory exceeds the number quota of the appointed directory, a mechanism that the clients apply for quota and then write in the file writing process is obtained, after the size of the storage space or the number of files that the clients apply for the file and need to occupy is determined, the file is written into the appointed directory, and the beneficial effect that the quota used by the clients can be accurately controlled not to exceed the size of the space of each directory or the number of written files to exceed the number of each directory is ensured.
In an optional implementation manner of the embodiment of the present invention, optionally, when performing an operation of obtaining, according to the directory identifier, an unused quota application corresponding to the target directory from a local quota file through a first file write process, quota determining module 402 is specifically configured to: the following operations are performed by the first file writing process: determining a file state of a local quota file; the local quota file is used for storing quotas of all directories and unused application quotas of the client; the file state is an application state or a non-application state; if the file state is a non-application state, acquiring an unused application quota corresponding to the target directory from an unused application quota of the client stored in the local quota file according to the directory identifier; the unused application quota of the client comprises unused application quotas corresponding to all directories; and if the file state is an application state, determining that acquisition of the unused application quota corresponding to the target directory fails.
In an optional implementation manner of the embodiment of the present invention, optionally, the quota controlling apparatus further includes: and the quota updating module is used for writing the file to be written into the target directory through the first file writing process if the unused application quota is greater than or equal to the application quota, and updating the unused application quota according to the application quota.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
EXAMPLE five
Fig. 5 is a schematic structural diagram of a quota controlling apparatus according to a fifth embodiment of the present invention. The apparatus may be configured in a quota controlling device in a distributed storage system. As shown in fig. 5, the apparatus includes: a request receiving module 501, an available quota judging module 502 and a first prompting module 503.
The request receiving module 501 is configured to receive a quota application request sent by a client; the quota application request carries an application quota corresponding to a file to be written in and a directory identifier of a target directory corresponding to the file to be written in; an available quota determining module 502, configured to obtain a mutex lock of a directory quota file through a first request processing process, obtain an available quota of the target directory from the directory quota file according to the directory identifier, and determine whether the available quota is greater than or equal to the application quota; a first prompt module 503, configured to send a request success prompt message to the client through the first request processing process if the available quota is greater than or equal to the application quota, update the available quota according to the application quota, and release the mutex lock of the directory quota file.
According to the technical scheme of the embodiment of the invention, a quota application request sent by a client is received; then, through a first request processing process, obtaining a mutex lock of a directory quota file, obtaining an available quota of the target directory from the directory quota file according to the directory identifier, and judging whether the available quota is greater than or equal to the application quota; when the available quota is larger than or equal to the application quota, sending application success prompt information to the client through the first request processing process, updating the available quota according to the application quota, and releasing a mutually exclusive lock of the directory quota file, so that a quota control scheme in the related technology is solved, when a plurality of clients concurrently write files into a specified directory, because the obtained available quota of the specified directory cannot be real-time accurate, the size of a storage space used by the specified directory may exceed the space quota of the specified directory, or the total number of files written into the directory by the specified directory exceeds the quantity quota of the specified directory, the available quota of the managed directory based on the mutually exclusive lock is obtained, the quota application request of at most one client is ensured to be in the processing process in the same time, a mechanism that the client applies the quota first and then writes the file in the file writing process can be controlled, and the client writes the file into the specified directory after determining that the storage space size or the number of files required to be occupied by the file applied from a quota control device is not more than the quota application quota, and the beneficial effect that the quota of controlling the storage space size of each directory by the client or the number of files written in the quota does not exceed the file is ensured.
In an optional implementation manner of the embodiment of the present invention, optionally, the quota controlling apparatus further includes: and the second prompt module is used for sending application failure prompt information to the client through the first request processing process and releasing the exclusive lock of the directory quota file if the available quota is smaller than the application quota.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
EXAMPLE six
Fig. 6 is a schematic structural diagram of a quota control system according to a sixth embodiment of the present invention. As shown in fig. 6, the system includes: a client 601 and a quota controlling device 602 in a distributed storage system.
The client 601 is configured to obtain a file to be written, an application quota corresponding to the file to be written, and a directory identifier of a target directory corresponding to the file to be written; acquiring an unused application quota corresponding to the target directory from a local quota file through a first file writing process according to the directory identifier, and judging whether the unused application quota is larger than or equal to the application quota; if the unused application quota is smaller than the application quota, acquiring a mutex lock of the local quota file through the first file write-in process, updating a file state of the local quota file to an application state, and sending a quota application request to quota control equipment 602, so that the quota control equipment 602 feeds back application success prompt information or application failure prompt information according to the available quota of the target directory; and if the prompt message of successful application is received, writing the file to be written into the target directory through the first file writing process, releasing the mutual exclusion lock of the local quota file, and updating the file state of the local quota file to be a non-application state.
The quota control device 602 is configured to receive a quota application request sent by the client 601; the quota application request carries an application quota corresponding to a file to be written in and a directory identifier of a target directory corresponding to the file to be written in; acquiring a mutex lock of a directory quota file through a first request processing process, acquiring an available quota of the target directory from the directory quota file according to the directory identifier, and judging whether the available quota is greater than or equal to the application quota; if the available quota is larger than or equal to the application quota, sending application success prompt information to the client 601 through the first request processing process, updating the available quota according to the application quota, and releasing the exclusive lock of the directory quota file.
According to the technical scheme of the embodiment of the invention, the quota control equipment is obtained, the available quotas of the management directories are serialized on the basis of the mutex lock, the quota application request of at most one client is ensured to be in the processing process in the same time, the client can execute a mechanism of firstly applying for the quotas and then writing in the file writing process, and the client writes the files into the specified directories after determining the size of the storage space or the number of the files required to be occupied by the files applied from the quota control equipment, so that the beneficial effect that the size of the storage space used by each directory can be accurately controlled not to exceed the space quota of each directory or the number of the written files does not exceed the number quota of each directory is ensured.
EXAMPLE seven
Fig. 7 shows a schematic structural diagram of an electronic device 10 that may be used to implement the quota controlling method according to the embodiment of the present invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 7, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, and the like, wherein the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various suitable actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program built from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data necessary for the operation of the electronic apparatus 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
A number of components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, or the like; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, or the like. Processor 11 performs the various methods and processes described above, such as the quota control method.
In some embodiments, the quota control method may be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is built into the RAM 13 and executed by the processor 11, one or more steps of the quota controlling method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the quota control method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for implementing the quota control method of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be performed. A computer program can execute entirely on a machine, partly on a machine, as a stand-alone software package partly on a machine and partly on a remote machine or entirely on a remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the Internet.
The computing system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical host and VPS service are overcome.
It should be understood that various forms of the flows shown above, reordering, adding or deleting steps, may be used. For example, the steps described in the present invention may be executed in parallel, sequentially, or in different orders, and are not limited herein as long as the desired result of the technical solution of the present invention can be achieved.
The above-described embodiments should not be construed as limiting the scope of the invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (10)
1. A quota control method is applied to a client in a distributed storage system, and comprises the following steps:
acquiring a file to be written, an application quota corresponding to the file to be written, and a directory identifier of a target directory corresponding to the file to be written;
acquiring an unused application quota corresponding to the target directory from a local quota file through a first file writing process according to the directory identifier, and judging whether the unused application quota is larger than or equal to the application quota;
if the unused application quota is smaller than the application quota, acquiring a mutex lock of the local quota file through the first file write-in process, updating the file state of the local quota file to an application state, and sending a quota application request to quota control equipment, so that the quota control equipment feeds back application success prompt information or application failure prompt information according to the available quota of the target directory;
and if the prompt message of successful application is received, writing the file to be written into the target directory through the first file writing process, releasing the mutual exclusion lock of the local quota file, and updating the file state of the local quota file to be a non-application state.
2. The method according to claim 1, wherein the obtaining, by the first file write process and according to the directory identifier, an unused application quota corresponding to the target directory from a local quota file comprises:
the following operations are performed by the first file writing process:
determining a file state of a local quota file; the local quota file is used for storing quotas of all directories and unused application quotas of the client; the file state is an application state or a non-application state;
if the file state is a non-application state, acquiring an unused application quota corresponding to the target directory from the unused application quota of the client stored in the local quota file according to the directory identifier; the unused application quota of the client comprises unused application quotas corresponding to all directories;
and if the file state is an application state, determining that acquisition of the unused application quota corresponding to the target directory fails.
3. The method of claim 1, wherein after determining whether the unused application quota is greater than or equal to the application quota, further comprising:
if the unused application quota is larger than or equal to the application quota, the file to be written is written into the target directory through the first file writing process, and the unused application quota is updated according to the application quota.
4. A quota control method is applied to quota control equipment in a distributed storage system, and comprises the following steps:
receiving a quota application request sent by a client; the quota application request carries an application quota corresponding to a file to be written in and a directory identifier of a target directory corresponding to the file to be written in;
acquiring a mutex lock of a directory quota file through a first request processing process, acquiring an available quota of the target directory from the directory quota file according to the directory identifier, and judging whether the available quota is greater than or equal to the application quota;
if the available quota is larger than or equal to the application quota, sending application success prompt information to the client through the first request processing process, updating the available quota according to the application quota, and releasing the exclusive lock of the directory quota file.
5. The method of claim 4, wherein after determining whether the available quota is greater than or equal to the application quota, further comprising:
and if the available quota is smaller than the application quota, sending application failure prompt information to the client through the first request processing process, and releasing the exclusive lock of the directory quota file.
6. A quota control apparatus, configured in a client in a distributed storage system, comprising:
the file acquisition module is used for acquiring a file to be written, an application quota corresponding to the file to be written and a directory identifier of a target directory corresponding to the file to be written;
the quota judging module is used for acquiring an unused application quota corresponding to the target directory from a local quota file through a first file write-in process according to the directory identifier, and judging whether the unused application quota is larger than or equal to the application quota;
a quota application module, configured to obtain a mutex lock of the local quota file through the first file write-in process if the unused application quota is smaller than the application quota, update a file state of the local quota file to an application state, and send a quota application request to quota control equipment, so that the quota control equipment feeds back application success prompt information or application failure prompt information according to the available quota of the target directory;
and the file writing module is used for writing the file to be written into the target directory through the first file writing process if the prompt message of successful application is received, releasing the exclusive lock of the local quota file, and updating the file state of the local quota file to a non-application state.
7. A quota control apparatus, configured in a quota control device in a distributed storage system, comprising:
the request receiving module is used for receiving a quota application request sent by a client; the quota application request carries an application quota corresponding to a file to be written in and a directory identifier of a target directory corresponding to the file to be written in;
the available quota judging module is used for acquiring a mutex lock of a directory quota file through a first request processing process, acquiring an available quota of the target directory from the directory quota file according to the directory identifier, and judging whether the available quota is greater than or equal to the application quota;
and the first prompt module is used for sending application success prompt information to the client through the first request processing process if the available quota is greater than or equal to the application quota, updating the available quota according to the application quota, and releasing the mutex lock of the directory quota file.
8. A quota control system, comprising: a client and a quota control device in the distributed storage system;
wherein the client is configured to execute the quota controlling method of any of claims 1-3;
the quota controlling device is configured to execute the quota controlling method of any of claims 4-5.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor;
and a memory communicatively coupled to the at least one processor;
wherein the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform the quota controlling method of any of claims 1-3, or the quota controlling method of any of claims 4-5.
10. A computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions for causing a processor to implement the quota controlling method of any of claims 1-3, or the quota controlling method of any of claims 4-5, when executed.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211147560.0A CN115543953A (en) | 2022-09-19 | 2022-09-19 | Quota control method, device, system, equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211147560.0A CN115543953A (en) | 2022-09-19 | 2022-09-19 | Quota control method, device, system, equipment and medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115543953A true CN115543953A (en) | 2022-12-30 |
Family
ID=84727899
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211147560.0A Pending CN115543953A (en) | 2022-09-19 | 2022-09-19 | Quota control method, device, system, equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115543953A (en) |
-
2022
- 2022-09-19 CN CN202211147560.0A patent/CN115543953A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112905314A (en) | Asynchronous processing method and device, electronic equipment, storage medium and road side equipment | |
CN115631273A (en) | Big data duplicate removal method, device, equipment and medium | |
CN115580645A (en) | Service switching method and device, electronic equipment and storage medium | |
CN115220876A (en) | Virtual resource creating method, device, program product, medium and electronic equipment | |
CN109828830B (en) | Method and apparatus for managing containers | |
CN110532225A (en) | Storage engines switching method, device, electronic equipment and medium | |
CN116483274A (en) | Online migration method, device, equipment and medium for distributed block storage volume | |
CN115543953A (en) | Quota control method, device, system, equipment and medium | |
CN115309558A (en) | Resource scheduling management system, method, computer equipment and storage medium | |
CN114070889B (en) | Configuration method, traffic forwarding device, storage medium, and program product | |
CN112884382B (en) | Resource quota management method, device and equipment of cloud platform and storage medium | |
CN113641628A (en) | Data quality detection method, device, equipment and storage medium | |
CN112434013A (en) | Data table migration method and device, electronic equipment and storage medium | |
CN114546705B (en) | Operation response method, operation response device, electronic apparatus, and storage medium | |
CN114676093B (en) | File management method and device, electronic equipment and storage medium | |
CN115913954A (en) | Cluster management information interaction method, device, equipment and storage medium | |
CN116775171B (en) | Architecture switching method and device, electronic equipment and storage medium | |
CN115309568A (en) | Method, device, equipment and medium for realizing multi-process file sharing | |
CN115934246A (en) | Virtual machine creating method, device, equipment and medium | |
CN114978601A (en) | Authority management method, device, equipment and medium | |
CN117298599A (en) | Game version scheduling method, system, equipment and storage medium | |
CN114861142A (en) | Method, device and equipment for determining user risk information and readable storage medium | |
CN116680080A (en) | Memory management method and device, electronic equipment and storage medium | |
CN117609150A (en) | Data migration method, device, equipment and medium | |
CN115576720A (en) | RPC timeout duration configuration method and device, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |