Directory quotas and user quotas limit the number of files and the storage capacity that can be consumed under a directory in a General-purpose NAS file system. Set a quota to monitor how a shared directory is used, or to prevent a single user or user group from filling it.
Prerequisites
-
A General-purpose NAS file system is created. For more information, see Create a file system.
-
A mount target is added. For more information, see Create a mount target.
-
A permission group and rules are created. For more information, see Procedure.
-
The file system is mounted based on the mount scenario and a directory is created in the file system. For more information, see Mounting scenarios.
Quota type
|
Classification |
Quota type |
|
Scope of quota statistics |
Note
Only General-purpose NAS file systems that use the NFS protocol support the user (group) quota feature. |
|
Restriction level of quotas |
|
Limits
-
File system instances
-
General-purpose NAS file systems that use the NFS protocol support directory quota and user (group) quota.
-
General-purpose NAS file systems that use the SMB protocol support the directory quota feature.
-
Extreme NAS does not support the directory quota feature.
-
-
Quotas
-
For a single file system, quotas can be set for up to 500 directories, and the maximum directory depth is 8 levels is supported. (For example, the root directory / has a depth of 0, /workspace has a depth of 1, /workspace/dir1 has a depth of 2, and so on.)
-
For a single directory quota, the maximum number of UID/GID combinations is 500 is supported. If the limit is exceeded, configuration failures or read anomalies may occur.
Important-
After an enforcement quota is set, if file usage exceeds the limit, write operations (including increasing file length, creating files, directories, and moving files to directories) will fail, and the application layer will receive an IOError. You can refer to Why does writing data to the file system return aDisk quota exceedederror message? for handling.
-
Due to the high risk of enforcement quotas, we strongly recommend that you carefully evaluate and test before configuring enforcement quotas on critical business paths.
-
After a directory quota is created, an initialization process occurs and the status is Initializing. The initialization duration depends on the number of files and directories in the file system and can take up to several hours or longer. After initialization is complete, the status changes to Running. You can query the status of directory quotas through the NAS console or by calling the DescribeDirQuotas API.
-
NAS quota settings are executed asynchronously. Therefore, enforcement quotas take effect and expire with a delay (normally 5 to 15 minutes).
-
-
Regions
-
General-purpose NAS file systems that use the NFS protocol: all regions.
-
General-purpose NAS file systems that use the SMB protocol: all regions except China South 1 Finance.
-
Create a directory quota
-
Log on to the NAS console .
-
In the left-side navigation pane, choose .
In the top navigation bar, select the resource group and region where your file system resides.
-
Find the target file system and click the file system ID or click Manage to go to the Quota Management page and click Create Directory Quota.
-
In the Create Directory Quota dialog box, configure the Directory Path to add the directory.
Important-
Quotas can only be set for directories that already exist in the General-purpose NAS file system. The directory path of the quota is the absolute path of the directory in the General-purpose NAS file system, not the local path on a compute node (for example, ECS or container).
-
Directories with Chinese characters in the path name are not supported.
For example, if the local mount path of General-purpose NAS is
/mnt, and in the General-purpose NAS file system, the root directory is/with a first-level subdirectory/dir0and a second-level subdirectory/dir/subdir1, the directory paths for configuring quotas on the root directory, first-level subdirectory, and second-level subdirectory are as follows:-
Root directory:
/ -
First-level subdirectory:
/dir0 -
Second-level subdirectory:
/dir/subdir1
Configure file system ID at the same time, and click OK. NAS quota settings are executed asynchronously. Enforcement quotas take effect and expire with a delay (normally 5 to 15 minutes).
-
-
Query the directory quota status.
After a directory quota is created, an initialization process occurs and the status is Initializing. The initialization duration depends on the number of files and directories in the file system and can take up to several hours or longer. After initialization is complete, the status changes to Running. In addition, a user quota entry with the user type set to All Users and the quota type set to Accounting is automatically generated in the user quota list. This user quota only supports modifying the quota type and does not support modifying the user type.
Add a user quota
When the quota type of a user quota is accounting, it collects the usage and file count of a user (group) in the directory. When the quota type is enforcement, it limits the capacity and file count that a user (group) can use in the directory.
-
Only General-purpose NAS file systems that use the NFS protocol support the user (group) quota feature.
-
Only one quota type can be configured for a single user type.
Procedure
In the Quota Management section, find the target directory path and click Manage Quotas. In the panel that appears, click Assign Quota to User and configure the relevant information in the dialog box. In the Add User Quota dialog box, File System ID and Directory Path are read-only fields. Configure the remaining parameters as needed.
|
Parameter |
Required |
Description |
|
User Type |
Yes |
Specifies the type of user ID, including Uid, Gid, and All Users, which respectively restrict users, user groups, and all users. Under the same path, different quotas can be set for multiple users. |
|
ID |
No |
This parameter must be configured when User Type is set to Uid or Gid. It specifies the user or user group to be restricted. For example:
|
|
Quota Type |
Yes |
|
|
Capacity Limit (GiB) |
No |
This parameter must be configured when Quota Type is set to Restrictive. It specifies the maximum storage capacity of files and directories owned by the quota user under the quota path. Note
|
|
File Limit |
No |
This parameter must be configured when Quota Type is set to Restrictive. It specifies the maximum number of files and directories owned by the quota user under the quota path. Note
|
Delete a single user quota
In the user quota list, find the target quota entry and click Delete.
When you delete a directory that has a configured quota in the file system, NAS also deletes the corresponding entries in the directory quota and user quota lists.
Edit a single user quota
In the user quota list, find the target quota entry and click Edit. The editable options include quota type, capacity limit, and file count limit.
The capacity limit and file count limit can only be edited when the quota type is enforcement, and at least one of them must be edited.
API
The quota management feature provides the following API operations:
FAQ
Why does writing data to the file system return aDisk quota exceedederror message?
-
Cause
The usage or file count of the target directory has exceeded the configured user quota limit. As a result, write operations (including increasing file length, creating files, directories, and moving files to directories) fail and an error message similar to
Disk quota exceededis returned. -
Solution
-
We recommend that you clean up data to free space or increase the capacity limit of the directory as soon as possible. For more information, see Edit a single user quota.
-
After the cleanup is complete, we recommend that you first perform test write operations on the directory with the quota (for example, create and write data to a test file) to trigger asynchronous refresh of the quota cache. Verify that these test write operations succeed before restarting your business.
-