A space capacity query method, device, equipment and medium

By calculating the target user's total and available capacity using a pre-defined capacity query logic, the problem of clients seeing incorrect capacity was solved, achieving accurate capacity display and improving the user experience.

CN115129672BActive Publication Date: 2025-11-07INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210778295.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-29
Publication Date
2025-11-07
Estimated Expiration
2042-06-29

AI Technical Summary

Technical Problem

In NFSv4 sharing scenarios with multiple users, the available and total capacity seen by the client through the df command is the file system's capacity, not the user's own, which can lead to misleading information and errors.

Method used

The system determines the user group to which the target user belongs by using a preset capacity query logic, and queries the user's capacity quota and used capacity, as well as the user group's capacity quota. Combined with the system's total capacity, it calculates the target user's total capacity and available capacity, and sends them to the client.

Benefits of technology

Accurately providing the total and available capacity to the target user avoids misleading clients and applications, and improves the usability of the storage system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115129672B_ABST
    Figure CN115129672B_ABST
Patent Text Reader

Abstract

The application discloses a space capacity query method applied to a network file system and relates to the technical field of computers, and the method comprises the following steps: after obtaining a target request sent by a target user through a client, determining a target user group in which the target user is located based on preset capacity query logic, and querying a user capacity quota corresponding to the target user, a user used capacity of the target user and a user group capacity quota corresponding to the target user group; querying a system total capacity corresponding to the network file system based on a preset interface provided by the network file system; obtaining a target total capacity and target available capacity corresponding to the target user according to the user capacity quota, the user group capacity quota, the system total capacity and the user used capacity; and sending the target total capacity and the target available capacity to the client. The application can query the target total capacity and the target available capacity possessed by the target user.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a space capacity query method, device, equipment and medium. BACKGROUND

[0002] Currently, after a storage end establishes a file system, a specific directory on the file system is exported as an NFS (Network File System) shared, an NFSv4 service is provided externally, and a client is mounted and accessed on a client supporting the NFSv4.

[0003] In a multi-user access scenario, in order to facilitate the management of the file system storage space, an administrator usually configures different capacity quotas for different users and user groups. However, after the client mounts the NFSv4 shared using its own username on the client, the available capacity and the total capacity seen by the client through the df (disk free) command are still the available capacity and the total capacity of the file system, not the available capacity and the total capacity of the user, which can mislead the client and cause unnecessary errors.

[0004] In summary, how to query the total capacity and the available capacity of the user is a problem to be solved at present. SUMMARY

[0005] Therefore, the purpose of the present application is to provide a space capacity query method, device, equipment and medium, which can obtain the target total capacity and the target available capacity corresponding to a target user. The specific scheme is as follows:

[0006] In a first aspect, the present application discloses a space capacity query method applied to a network file system, comprising:

[0007] After obtaining a target request sent by a target user through a client, a target user group in which the target user is located is determined based on a preset capacity query logic, and a user capacity quota and a user used capacity corresponding to the target user and a user group capacity quota corresponding to the target user group are queried;

[0008] The system total capacity corresponding to the network file system is queried based on a preset interface provided by the network file system;

[0009] The target total capacity and the target available capacity corresponding to the target user are obtained according to the user capacity quota, the user group capacity quota, the system total capacity and the user used capacity;

[0010] The target total capacity and the target available capacity are sent to the client.

[0011] Optionally, the querying the user capacity quota and the used capacity of the target user and the user group capacity quota of the target user group comprises:

[0012] The user capacity quota, the used capacity of the target user and the user group capacity quota of the target user group are queried through a sysctl command.

[0013] Optionally, the obtaining the target total capacity and the target available capacity of the target user according to the user capacity quota, the user group capacity quota, the system total capacity and the used capacity of the target user comprises:

[0014] The target total capacity of the target user is obtained according to the user capacity quota, the user group capacity quota and the system total capacity, and the target available capacity of the target user is obtained according to the target total capacity and the used capacity of the target user.

[0015] Optionally, the obtaining the target total capacity of the target user according to the user capacity quota, the user group capacity quota and the system total capacity comprises:

[0016] The minimum capacity among the user capacity quota, the user group capacity quota and the system total capacity is selected as the target total capacity of the target user.

[0017] Optionally, the obtaining the target available capacity of the target user according to the target total capacity and the used capacity of the target user comprises:

[0018] A target value is calculated by subtracting the used capacity of the target user from the target total capacity;

[0019] If the target value is positive, the target value is taken as the target available capacity of the target user;

[0020] If the target value is negative, the value zero is taken as the target available capacity.

[0021] Optionally, the determining the target user group in which the target user is located based on the preset capacity query logic and querying the user capacity quota and the used capacity of the target user and the user group capacity quota of the target user group comprises:

[0022] Based on the preset capacity query logic, the target user group in which the target user is located is determined according to the user information of the target user, and then the user group information of the target user group is queried;

[0023] query the user capacity quota and the user used capacity corresponding to the target user and the user group capacity quota corresponding to the target user group based on the user information and the user group information.

[0024] Optionally, after obtaining the target request sent by the target user through the client, the target user group in which the target user is located is determined based on preset capacity query logic, and the user capacity quota and the user used capacity corresponding to the target user and the user group capacity quota corresponding to the target user group are queried, including:

[0025] After obtaining the target request sent by the target user through the client, it is detected whether the field value of the target field is set to the numerical value 1.

[0026] If the field value of the target field is set to the numerical value 1, the target user group in which the target user is located is determined based on preset capacity query logic, and the user capacity quota and the user used capacity corresponding to the target user and the user group capacity quota corresponding to the target user group are queried.

[0027] In a second aspect, the present application discloses a space capacity query device applied to a network file system, including:

[0028] The first capacity query module is configured to, after obtaining the target request sent by the target user through the client, determine the target user group in which the target user is located based on preset capacity query logic, and query the user capacity quota and the user used capacity corresponding to the target user and the user group capacity quota corresponding to the target user group.

[0029] The second capacity query module is configured to query the system total capacity corresponding to the network file system based on a preset interface provided by the network file system.

[0030] The target capacity obtaining module is configured to obtain the target total capacity and the target available capacity corresponding to the target user according to the user capacity quota, the user group capacity quota, the system total capacity and the user used capacity.

[0031] The target capacity sending module is configured to send the target total capacity and the target available capacity to the client.

[0032] In a third aspect, the present application discloses an electronic device including a processor and a memory; wherein the processor implements the space capacity query method disclosed above when executing the computer program stored in the memory.

[0033] In a fourth aspect, the present application discloses a computer readable storage medium for storing a computer program; wherein the computer program is executed by a processor to implement the space capacity query method disclosed above.

[0034] It can be seen that, after obtaining the target request sent by the target user through the client, the preset capacity query logic is used to determine the target user group in which the target user is located, and the user capacity quota corresponding to the target user, the user used capacity and the user group capacity quota corresponding to the target user group are queried; the preset interface provided by the network file system is used to query the system total capacity corresponding to the network file system; the target total capacity and the target available capacity corresponding to the target user are obtained according to the user capacity quota, the user group capacity quota, the system total capacity and the user used capacity; the target total capacity and the target available capacity are sent to the client. It can be seen that, the preset capacity query logic is newly added to control the query of the user capacity quota corresponding to the target user, the user used capacity and the user group capacity quota corresponding to the target user group, so as to obtain the target total capacity and the target available capacity corresponding to the target user according to the user capacity quota, the user group capacity quota, the system total capacity and the user used capacity. Therefore, the target total capacity and the target available capacity corresponding to the target user can be sent to the client. BRIEF DESCRIPTION OF DRAWINGS

[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description only constitute a part of the embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of the provided drawings.

[0036] Figure 1 A space capacity query method flowchart is provided for the present application;

[0037] Figure 2 A specific space capacity query method flowchart is provided for the present application;

[0038] Figure 3 A space capacity query device structure diagram is provided for the present application;

[0039] Figure 4 An electronic equipment structure diagram is provided for the present application. DETAILED DESCRIPTION

[0040] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments only constitute a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0041] After the current client mounts the NFSv4 share with own username on the client side, the available capacity and total capacity seen by the df (disk free) command are still the available capacity and total capacity of the file system, not the available capacity and total capacity of the user, which will mislead the client and cause unnecessary errors.

[0042] To overcome the above problems, the application provides a space capacity query scheme, which can obtain target total capacity and target available capacity corresponding to a target user.

[0043] Referring to Figure 1 As shown in the figure, the embodiment of the application discloses a space capacity query method applied to a network file system, which comprises the following steps:

[0044] Step S11: After obtaining the target request sent by the target user through the client, the target user group in which the target user is located is determined based on a preset capacity query logic, and the user capacity quota and user used capacity corresponding to the target user and the user group capacity quota corresponding to the target user group are queried.

[0045] In the embodiment of the application, the client views the space capacity information through the df (disk free) command, the target request exists in the target message sent by the target user to the client, the target request is the command word GETATTR, at this time, the client sends the command word to the local, and also needs to set the field values of the FATTR4_SPACE_AVAIL and FATTR4_SPACE_TOTAL target fields in the message to 1.

[0046] In the embodiment of the application, the preset capacity query logic can be referred to as a quota processing logic.

[0047] It should be pointed out that after obtaining the target request sent by the target user through the client, it is detected whether the field value of the target field is set to the numerical value 1; if the field value of the target field is set to the numerical value 1, the target user group in which the target user is located is determined based on the preset capacity query logic, and the user capacity quota and user used capacity corresponding to the target user and the user group capacity quota corresponding to the target user group are queried. It should be pointed out that the quota information configured on the file system is usually saved by the file system itself, which includes the quota information of the specified user and the capacity information already used by the user, and the file system will provide a query interface. It should be pointed out that if the field value of the target field is not set to the numerical value 1, the process of directly querying the capacity information (total capacity and available capacity) of the file system is executed, and then returned to the client.

[0048] It should be noted that the user capacity quota and the user group capacity quota are pre-allocated by an administrator, and the size relationship between the user capacity quota, the user group capacity quota and the system total capacity can not be specifically limited. When the administrator does not allocate the user capacity quota and the user group capacity quota for the target user and the target user group, the system total capacity is used as the user capacity quota and the user group capacity quota by default.

[0049] In the embodiment of the present application, the user information (uid) of the target user and the user group information (gid) of the target user group are required to query the user capacity quota and the used capacity of the target user and the user group capacity quota of the target user group. Therefore, first, the preset capacity query logic is based on, and the target user group in which the target user is located is determined according to the user information of the target user, and then the user group information of the target user group is queried. The user capacity quota (quota_usr) and the used capacity (quota_used_by_user) of the target user and the user group capacity quota (quota_group) of the target user group are queried based on the user information and the user group information. It should be noted that the user capacity quota, the used capacity and the user group capacity quota of the target user are respectively queried by the user information of the target user and the user group information of the target user group.

[0050] It should be noted that the query interface provided by the network file system is used to query the user capacity quota and the used capacity of the target user and the user group capacity quota of the target user group through the sysctl command. It should be noted that the sysctl is used to display all system parameters or load system parameters from a specified file, and in addition, the interface for querying the user capacity quota and the used capacity of the target user and the user group capacity quota of the target user group is provided by the network file system.

[0051] Step S12: Query the system total capacity corresponding to the network file system based on the preset interface provided by the network file system.

[0052] In the embodiment of the present application, the process of querying the total capacity information (fs_total) of the original direct file system is performed. It should be noted that the capacity information queried based on the preset interface provided by the network file system includes not only the total capacity information of the file system, but also the current available capacity (fs_ava) and the current used capacity (fs_used) of the file system. However, the current available capacity (fs_ava) and the current used capacity (fs_used) of the file system are not used in the process of obtaining the target available capacity and the target total capacity of the present application.

[0053] Step S13: obtaining the target total capacity and the target available capacity corresponding to the target user according to the user capacity quota, the user group capacity quota, the system total capacity and the user used capacity.

[0054] In the embodiment of the present application, the target total capacity and the target available capacity corresponding to the target user are obtained according to the user capacity quota, the user group capacity quota and the user used capacity obtained by the preset capacity query logic, and the system total capacity obtained by the original logic.

[0055] Step S14: sending the target total capacity and the target available capacity to the client.

[0056] In the embodiment of the present application, after obtaining the target total capacity and the target available capacity corresponding to the target user, the target total capacity and the target available capacity are sent to the client, instead of sending the local system total capacity and the system available capacity, so as to prevent misleading the client and the client application and causing unnecessary errors.

[0057] It should be noted that when the target request in the target message sent by the client is obtained, and the task in the target message is to query the capacity related information, the preset quota query logic is added to query the target total capacity and the target available capacity corresponding to the target user, and the target total capacity and the target available capacity are sent to the client. In the original method, when the available capacity and the total capacity of the mounted directory are queried, the system total capacity and the system available capacity are queried.

[0058] It can be seen that, after obtaining the target request sent by the target user through the client, the target user group in which the target user is located is determined based on preset capacity query logic, and the user capacity quota corresponding to the target user, the user used capacity and the user group capacity quota corresponding to the target user group are queried. The system total capacity corresponding to the network file system is queried based on the preset interface provided by the network file system. The target total capacity and the target available capacity corresponding to the target user are obtained according to the user capacity quota, the user group capacity quota, the system total capacity and the user used capacity. The target total capacity and the target available capacity are sent to the client. It can be seen that, the preset capacity query logic is newly added in the application to control the query of the user capacity quota corresponding to the target user, the user used capacity and the user group capacity quota corresponding to the target user group, so as to obtain the target total capacity and the target available capacity corresponding to the target user according to the user capacity quota, the user group capacity quota, the system total capacity and the user used capacity. Therefore, the target total capacity and the target available capacity corresponding to the target user can be sent to the client.

[0059] Referring to Figure 2 As shown in the drawings, the embodiment of the application discloses a specific space capacity query method, applied to a network file system, the method comprises:

[0060] Step S21: After obtaining the target request sent by the target user through the client, the target user group in which the target user is located is determined based on preset capacity query logic, and the user capacity quota corresponding to the target user, the user used capacity and the user group capacity quota corresponding to the target user group are queried.

[0061] In the embodiment of the application, the client views the space capacity information through the df command, the target request exists in the target message sent by the target user to the client, the target request is the command word GETATTR, at this time, the client sends the command word to the local, and also needs to set the field values of the FATTR4_SPACE_AVAIL and FATTR4_SPACE_TOTAL target fields in the message to 1.

[0062] In the embodiment of the application, the preset capacity query logic can be called quota processing logic.

[0063] It is to be noted that after obtaining the target request sent by the target user through the client, it is detected whether the field value of the target field is set to the numerical value 1; if the field value of the target field is set to the numerical value 1, the target user group in which the target user is located is determined based on the preset capacity query logic, and the user capacity quota corresponding to the target user, the user used capacity and the user group capacity quota corresponding to the target user group are queried. It is to be noted that the quota information configured on the file system is usually saved by the file system itself, wherein there is quota information of a specified user and capacity information already used by the user, and the file system provides a query interface. It is to be noted that if the field value of the target field is not set to the numerical value 1, the process of returning the capacity information (total capacity and available capacity) of the file system to the client after directly querying the capacity information of the file system is performed.

[0064] It is to be noted that the user capacity quota and the user group capacity quota are pre-allocated by an administrator, and the size relationship of the user capacity quota, the user group capacity quota and the system total capacity can not be specifically limited, and when the administrator does not allocate the user capacity quota and the user group capacity quota, the system total capacity is used as the user capacity quota and the user group capacity quota by default.

[0065] In the embodiment of the application, the user information (uid) of the target user and the user group information (gid) of the target user group are required to query the user capacity quota corresponding to the target user, the user used capacity and the user group capacity quota corresponding to the target user group, therefore, first, the target user group in which the target user is located is determined based on the preset capacity query logic and according to the user information of the target user, and then the user group information of the target user group is queried; the user capacity quota (quota_usr) corresponding to the target user, the user used capacity (quota_used_by_user) and the user group capacity quota (quota_group) corresponding to the target user group are queried based on the user information and the user group information. It is to be noted that the user information of the target user and the user group information of the target user group are used to respectively query the user capacity quota, the user used capacity and the user group capacity quota of the target user by the application.

[0066] It is to be noted that the user information of the target user and the user group information of the target user group are used to respectively query the user capacity quota, the user used capacity and the user group capacity quota of the target user by the application. It is to be noted that the sysctl is used to display all system parameters or load system parameters from a specified file, and in addition, the interface for querying the user capacity quota corresponding to the target user, the user used capacity and the user group capacity quota corresponding to the target user group is provided by the network file system.

[0067] Step S22: querying the total capacity of the network file system based on the preset interface provided by the network file system.

[0068] In the embodiment of the present application, the process of querying the total capacity information (fs_total) of the original file system is executed. It should be noted that the capacity information queried based on the preset interface provided by the network file system includes not only the total capacity information of the file system, but also the current available capacity (fs_ava) and the current used capacity (fs_used) of the file system. However, the current available capacity (fs_ava) and the current used capacity (fs_used) of the file system are not used in the process of obtaining the target available capacity and the target total capacity of the present application.

[0069] Step S23: obtaining the target total capacity corresponding to the target user according to the user capacity quota, the user group capacity quota and the total capacity of the system, and obtaining the target available capacity corresponding to the target user according to the target total capacity and the used capacity of the user.

[0070] In the embodiment of the present application, the specific process of obtaining the target total capacity corresponding to the target user according to the user capacity quota, the user group capacity quota and the total capacity of the system is as follows: selecting the minimum capacity among the user capacity quota, the user group capacity quota and the total capacity of the system as the target total capacity corresponding to the target user, for example, total = min (quota_usr, quota_group, fs_total), wherein total represents the target total capacity, and min represents the minimum value.

[0071] It should be noted that the target total capacity corresponding to the target user is jointly affected by the user capacity quota, the user group capacity quota and the total capacity of the system, and is the minimum value among the user capacity quota, the user group capacity quota and the total capacity of the system. For example, when the system capacity quota is greater than the user capacity quota, and the user capacity quota is greater than the user group capacity quota, the size of the target total capacity corresponding to the target user is the size of the user group capacity quota; when the user group capacity quota is greater than the user capacity quota, and the user capacity quota is greater than the total capacity of the system, the size of the target total capacity corresponding to the target user is the size of the total capacity of the system.

[0072] In the embodiment of the present application, the specific process of obtaining the target available capacity corresponding to the target user according to the target total capacity and the user used capacity is: calculating a target value by subtracting the user used capacity from the target total capacity; if the target value is positive, taking the target value as the target available capacity corresponding to the target user; if the target value is negative, taking the value zero as the target available capacity. For example, max(0, total-quota_used_by_user); wherein, max represents taking the maximum value. It should be noted that there is a case that the target available capacity of the target user is less than the user used capacity of the target user.

[0073] In an embodiment, when no quota is allocated for the target user and the target user group, taking the system total capacity as the user group capacity quota and the user capacity quota, in this case, the space capacity used by the target user is the first capacity (user used capacity), then allocating quota for the target user and the target user group, determining the target total capacity according to the quota allocated for the target user and the target user group and the system total capacity, if the quota allocated for the target user is less than the system total capacity, then the target total capacity is equal to the quota allocated for the target user, when the allocated quota is less than the first capacity (user used capacity), the calculated target value is negative, and the value zero is taken as the target available capacity.

[0074] Step S24: sending the target total capacity and the target available capacity to the client.

[0075] In the embodiment of the present application, after obtaining the target total capacity and the target available capacity corresponding to the target user, the target total capacity and the target available capacity are sent to the client, instead of sending the local system total capacity and the system available capacity, so as to prevent misleading the client and the client application and causing unnecessary errors, and improve the ease of use of the storage system.

[0076] It should be noted that when the target request in the target message sent by the client is obtained, and the task in the target message is to query the capacity related information, the preset quota query logic is added, so as to query the target total capacity and the target available capacity corresponding to the target user, and to send the target total capacity and the target available capacity to the client. In the original method, when the available capacity and the total capacity of the mounted directory are queried, the system total capacity and the system available capacity are queried.

[0077] It can be seen that, after obtaining the target request sent by the target user through the client, the preset capacity query logic is used to determine the target user group in which the target user is located, and the user capacity quota corresponding to the target user, the user used capacity, and the user group capacity quota corresponding to the target user group are queried. The system total capacity corresponding to the network file system is queried based on the preset interface provided by the network file system. The target total capacity corresponding to the target user is obtained according to the user capacity quota, the user group capacity quota, and the system total capacity, and the target available capacity corresponding to the target user is obtained according to the target total capacity and the user used capacity. The target total capacity and the target available capacity are sent to the client. It can be seen that, the preset capacity query logic is newly added to control the query of the user capacity quota corresponding to the target user, the user used capacity, and the user group capacity quota corresponding to the target user group, so as to obtain the target total capacity and the target available capacity corresponding to the target user according to the user capacity quota, the user group capacity quota, the system total capacity, and the user used capacity. Therefore, the target total capacity and the target available capacity corresponding to the target user can be sent to the client.

[0078] Referring to Figure 3 It is shown that the embodiment of the application discloses a space capacity query device applied to a network file system, comprising:

[0079] The first capacity query module 11 is used to, after obtaining the target request sent by the target user through the client, determine the target user group in which the target user is located based on the preset capacity query logic, and query the user capacity quota corresponding to the target user, the user used capacity, and the user group capacity quota corresponding to the target user group.

[0080] The second capacity query module 12 is used to query the system total capacity corresponding to the network file system based on the preset interface provided by the network file system.

[0081] The target capacity obtaining module 13 is used to obtain the target total capacity and the target available capacity corresponding to the target user according to the user capacity quota, the user group capacity quota, the system total capacity, and the user used capacity.

[0082] The target capacity sending module 14 is used to send the target total capacity and the target available capacity to the client.

[0083] It can be seen that the preset capacity query logic is newly added in the application to control the query of the user capacity quota corresponding to the target user, the used user capacity, and the user group capacity quota corresponding to the target user group, so as to obtain the target total capacity and the target available capacity corresponding to the target user according to the user capacity quota, the user group capacity quota, the system total capacity, and the used user capacity. Thus, the target total capacity and the target available capacity corresponding to the target user can be sent to the client.

[0084] In some embodiments, the first capacity query module 11 comprises:

[0085] a first capacity query unit configured to query the user capacity quota corresponding to the target user, the used user capacity, and the user group capacity quota corresponding to the target user group by using a sysctl command.

[0086] It should be noted that the sysctl command is used to display all system parameters or load system parameters from a specified file.

[0087] In some embodiments, the target capacity obtaining module 13 comprises:

[0088] a target capacity obtaining unit configured to obtain the target total capacity corresponding to the target user according to the user capacity quota, the user group capacity quota, and the system total capacity, and obtain the target available capacity corresponding to the target user according to the target total capacity and the used user capacity.

[0089] The target capacity obtaining unit comprises:

[0090] a target total capacity obtaining unit configured to select the minimum capacity among the user capacity quota, the user group capacity quota, and the system total capacity as the target total capacity corresponding to the target user.

[0091] It should be noted that the target total capacity corresponding to the target user is jointly affected by the user capacity quota, the user group capacity quota, and the system total capacity, and is the minimum value among the user capacity quota, the user group capacity quota, and the system total capacity. For example, when the system capacity quota is greater than the user capacity quota, and the user capacity quota is greater than the user group capacity quota, the size of the target total capacity corresponding to the target user is the size of the user group capacity quota. When the user group capacity quota is greater than the user capacity quota, and the user capacity quota is greater than the system total capacity, the size of the target total capacity corresponding to the target user is the size of the system total capacity.

[0092] The target capacity obtaining unit comprises:

[0093] a calculation unit configured to calculate a target value by subtracting the used capacity of the target user from the target total capacity;

[0094] a first available capacity determination unit configured to, if the target value is positive, determine the target available capacity of the target user as the target value;

[0095] It should be noted that, in an embodiment, when no quota is allocated to the target user and the target user group, the total capacity of the system is taken as the user group capacity quota and the user capacity quota, in which case the space capacity used by the target user is the first capacity (used capacity of the target user), and then the quota is allocated to the target user and the target user group, and the target total capacity is determined according to the quota allocated to the target user and the target user group and the total capacity of the system, if the quota allocated to the target user is less than the total capacity of the system, then the target total capacity at this time is equal to the quota allocated to the target user, and when the allocated quota is less than the first capacity (used capacity of the target user), the target value calculated is negative, in which case the value zero is taken as the target available capacity;

[0096] a second available capacity determination unit configured to, if the target value is negative, determine the target available capacity as the value zero;

[0097] In some embodiments, the first capacity query module 11 comprises:

[0098] a user group information query unit configured to determine the target user group in which the target user is located according to the user information of the target user based on a preset capacity query logic, and then query the user group information of the target user group;

[0099] a capacity quota acquisition unit configured to query the user capacity quota and the used capacity of the target user and the user group capacity quota of the target user group based on the user information and the user group information;

[0100] In some embodiments, the first capacity query module 11 comprises:

[0101] a field value detection unit configured to, after obtaining the target request sent by the target user through the client, detect whether the field value of the target field is set to the value 1;

[0102] a first field value result unit configured to, if the field value of the target field is set to the value 1, determine the target user group in which the target user is located based on a preset capacity query logic, and query the user capacity quota and the used capacity of the target user and the user group capacity quota of the target user group;

[0103] In some embodiments, the first capacity query module 11 further comprises:

[0104] a second field value result unit, configured to, if the field value of the target field is not set as the numerical value 1, perform the original process of querying the capacity information (total capacity and available capacity) of the file system and returning the process to the client;

[0105] In some embodiments, the space capacity querying apparatus further comprises:

[0106] a quota allocation unit, configured to, when no user capacity quota and user group capacity quota are allocated to the target user and the target user group respectively, default the system total capacity as the user group capacity quota corresponding to the target user group and the user group capacity quota corresponding to the target user.

[0107] Further, the embodiment of the present application further provides an electronic device, Figure 4 is an electronic device 20 structure diagram shown according to an exemplary embodiment, the contents in the figure cannot be considered as any limitation on the use range of the present application.

[0108] Figure 4 An electronic device 20 structure diagram provided by the embodiment of the present application. The electronic device 20, specifically can include: at least one processor 21, at least one memory 22, power supply 23, input output interface 24, communication interface 25 and communication bus 26. Wherein, the memory 22 is used for storing computer program, the computer program is loaded and executed by the processor 21, to realize the related steps of the space capacity querying method disclosed by the foregoing any embodiment.

[0109] In the embodiment, the power supply 23 is used for providing working voltage for each hardware device on the electronic device 20; the communication interface 25 can create data transmission channel between the electronic device 20 and external device, and the communication protocol followed by the communication interface 25 is any communication protocol applicable to the technical solution of the present application, which is not specifically limited here; the input output interface 24 is used for obtaining external input data or outputting data to the outside, and the specific interface type can be selected according to the specific application needs, which is not specifically limited here.

[0110] In addition, the memory 22 as the carrier of resource storage can be read-only memory, random access memory, disk or optical disk, etc., the memory 22 can include random access memory as running memory and non-volatile memory for external memory storage, and the storage resources thereon include operating system 221, computer program 222, etc., and the storage mode can be temporary storage or permanent storage.

[0111] The operating system 221 is used to manage and control each hardware device on the electronic device 20 and the computer program 222, and can be Windows, Unix, Linux, etc. The computer program 222 can further include computer programs capable of completing other specific work in addition to the computer programs capable of completing the space capacity query method disclosed by the electronic device 20 in any of the foregoing embodiments.

[0112] In the embodiment, the input and output interface 24 can include, but is not limited to, a USB interface, a hard disk reading interface, a serial interface, a voice input interface, a fingerprint input interface, etc.

[0113] Further, the embodiment of the application further discloses a computer readable storage medium for storing a computer program, wherein the computer program is executed by a processor to implement the space capacity query method disclosed above.

[0114] The specific steps of the method can refer to the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0115] The computer readable storage medium mentioned herein includes a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a magnetic disk or an optical disk, or any other form of storage medium known in the technical field. The computer program is executed by a processor to implement the space capacity query method disclosed above. The specific steps of the method can refer to the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0116] Each embodiment in the specification is described in a progressive manner, and each embodiment focuses on the difference from other embodiments. The same or similar parts of each embodiment can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the space capacity query method disclosed in the embodiment, the description is relatively simple, and the relevant part can refer to the method part.

[0117] Those skilled in the art will further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the embodiments disclosed herein can be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality, without referring to a specific sequence of operations for implementing the functions. The order of various illustrative blocks, modules, circuits, and steps may be re-arranged or otherwise implemented without departing from the spirit of the application, which is limited only by the claims that follow.

[0118] The steps of a method, process, or algorithm described in connection with the embodiments disclosed herein can be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module can reside in RAM, flash memory, ROM, electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such that the processor can read information from, and write information to, the storage medium. In the alternative, hard disk can be used as a storage medium.

[0119] Finally, it should be noted that the terms "comprises", "comprising", or other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises... a" does not, without more constraints, exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the element.

[0120] The above provides a detailed introduction to the spatial capacity query method, device, equipment and medium provided by the application. The principles and implementation manners of the application are described by using specific examples. The above example descriptions are only used to help understand the method and core idea of the application. Meanwhile, for those skilled in the art, according to the idea of the application, the specific implementation manner and application range can be changed. The above description should not be understood as a limitation of the application.

Claims

1. A method of spatial capacity query, characterized by, Applied to a network file system, comprising: After obtaining a target request sent by a target user through a client, determining a target user group in which the target user is located based on preset capacity query logic, and querying a user capacity quota corresponding to the target user, a user used capacity corresponding to the target user, and a user group capacity quota corresponding to the target user group; Querying a system total capacity corresponding to the network file system based on a preset interface provided by the network file system; Selecting a minimum capacity among the user capacity quota, the user group capacity quota, and the system total capacity as a target total capacity corresponding to the target user, calculating a target value obtained by subtracting the user used capacity from the target total capacity, and if the target value is positive, taking the target value as a target available capacity corresponding to the target user, and if the target value is negative, taking a value zero as the target available capacity; Sending the target total capacity and the target available capacity to the client.

2. The space capacity inquiry method according to claim 1, characterized by, The querying of the user capacity quota corresponding to the target user, the user used capacity corresponding to the target user, and the user group capacity quota corresponding to the target user group comprises: Querying the user capacity quota corresponding to the target user, the user used capacity corresponding to the target user, and the user group capacity quota corresponding to the target user group through a sysctl command.

3. The method of claim 1, wherein, The determining of the target user group in which the target user is located based on the preset capacity query logic, and the querying of the user capacity quota corresponding to the target user, the user used capacity corresponding to the target user, and the user group capacity quota corresponding to the target user group comprise: Determining the target user group in which the target user is located based on preset capacity query logic and according to user information of the target user, and then querying user group information of the target user group; Querying the user capacity quota corresponding to the target user, the user used capacity corresponding to the target user, and the user group capacity quota corresponding to the target user group based on the user information and the user group information.

4. The space capacity inquiry method according to any one of claims 1 to 3, characterized by, The determining of the target user group in which the target user is located based on the preset capacity query logic, and the querying of the user capacity quota corresponding to the target user, the user used capacity corresponding to the target user, and the user group capacity quota corresponding to the target user group comprise: After obtaining the target request sent by the target user through the client, detecting whether a field value of a target field is set to a value 1; If the field value of the target field is set to the value 1, determining the target user group in which the target user is located based on the preset capacity query logic, and querying the user capacity quota corresponding to the target user, the user used capacity corresponding to the target user, and the user group capacity quota corresponding to the target user group.

5. A spatial capacity query apparatus, characterized by, Applied to a network file system, comprising: A first capacity query module, configured to, after obtaining a target request sent by a target user through a client, determine a target user group in which the target user is located based on preset capacity query logic, and query a user capacity quota corresponding to the target user, a user used capacity corresponding to the target user, and a user group capacity quota corresponding to the target user group; A second capacity query module, configured to query a system total capacity corresponding to the network file system based on a preset interface provided by the network file system; The target capacity obtaining module is configured to select the minimum capacity among the user capacity quota, the user group capacity quota and the system total capacity as a target total capacity corresponding to the target user; calculate a target value by subtracting the used capacity of the user from the target total capacity; if the target value is positive, take the target value as a target available capacity corresponding to the target user; if the target value is negative, take the value zero as the target available capacity; The target capacity sending module is configured to send the target total capacity and the target available capacity to the client.

6. An electronic device, comprising: The computer program product comprises a processor and a memory; wherein the processor implements the spatial capacity query method according to any one of claims 1 to 4 when executing the computer program stored in the memory.

7. A computer readable storage medium characterized in that, The computer program product comprises a processor and a memory; wherein the processor implements the spatial capacity query method according to any one of claims 1 to 4 when executing the computer program stored in the memory.

Citation Information

Patent Citations

  • Interaction method and device for distributed file system

    CN107870734A