All Products
Search
Document Center

File Storage NAS:Manage directory quotas

Last Updated:Nov 18, 2024

File Storage NAS (NAS) provides the quota management feature for General-purpose NAS file systems. You can configure a directory quota to limit the number or size of files that can be contained in a directory of a file system. You can also configure a user quota to limit the resources that a specific user can use. You can also configure different resource quotas for multiple users in the same directory.

Prerequisites

  • A General-purpose NAS file system is created. For more information, see Create a file system.

  • A mount target is created. For more information, see Create a mount target.

  • A permission group is created and rules are added to the permission group. For more information, see Procedure.

  • The file system is mounted based on the mounting scenario. A directory is created in the file system. For more information, see Scenarios.

Quota types

Category

Quota type

Application scope

  • Directory quotas for all users: the maximum storage space for files that all users can create in a directory of a file system.

  • Directory quotas for a specific user or user group: the maximum storage space for files that a user or user group can create in a directory of a file system.

Note

Only General-purpose Network File System (NFS) file systems support directory quotas for a specific user or user group.

Quota level

  • Statistical quotas: If you create a statistical quota for a file system, NAS calculates only the usage of storage space in the file system. You can query and view statistical data.

  • Restrictive quotas: If the used storage space for a specified directory in a file system exceeds the quota, you cannot create files or directories, or append data to the files or directories.

Limits

  • File systems

    • General-purpose NFS file systems support directory quotas for all users and directory quotas for a specific user or user group.

    • General-purpose Server Message Block (SMB) file systems support only directory quotas for all users.

    • Extreme NAS file systems do not support directory quotas.

  • Quotas

    For a single file system, you can configure quotas for a maximum of 500 directories. The maximum directory depth is eight levels. For example, the depth of the root directory / is zero level. The depth of the /workspace directory is one level. The depth of the /workspace/dir1 directory is two levels.

    Important
    • If you create a restrictive quota for a directory and the quota is used up, data can no longer be written to the directory. When the quota is used up, you can no longer increase file sizes, create files or directories, or move files to another directory. In addition, an IOError error occurs at the application layer. For information about how to resolve the issue, see Why is the "Disk quota exceeded" error message returned when data is written to a file system?

    • To prevent potential security risks, we recommend that you evaluate and test restrictive quotas before you create the restrictive quotas for core business-related directories.

    • After a quota is created, the quota is automatically initialized and is in the Initializing state. The initialization may take several hours or even longer to complete. The duration of the initialization process depends on the number of files and subdirectories in the directory of your file system. After the quota is initialized, the quota is in the Running state. You can query the status of a directory quota by using the NAS console or by calling the DescribeDirQuotas API operation.

    • The operation to enable a restrictive quota is asynchronously performed at the backend and requires 5 to 15 minutes to take effect.

  • Regions

    • General-purpose NFS file systems support directory quotas in all regions.

    • General-purpose SMB file systems support directory quotas in all regions except China South 1 Finance.

Create a directory quota

  1. Log on to the NAS console

  2. In the left-side navigation pane, choose File System > File System List.

  3. In the top navigation bar, select a region.

  4. Find the file system to which the directory belongs. Then, click the file system ID or click Manage in the Actions column. On the Quota Management page, click Create Directory Quota.

  5. In the Create Directory Quota dialog box, enter the directory path in the Directory Path field.

    Important
    • You can configure quotas only for directories that are created in a General-purpose NAS file system. The directory path of a quota is the absolute path of the directory in the General-purpose NAS file system, rather than the local path on a compute node, such as an ECS instance or a container.

    • The directory path cannot contain Chinese characters.

    For example, a General-purpose NAS file system is mounted at the /mnt directory. The root directory is /, and the General-purpose NAS file system has a level-1 subdirectory /dir0 and a level-2 subdirectory /dir/subdir1. If you want to configure a quota for the root directory, level-1 subdirectory, and level-2 subdirectory, enter the following directory paths:

    • Root directory: /

    • Level-1 subdirectory: /dir0

    • Level-2 subdirectory: /dir/subdir1

    image

  6. Query the status of the quota.

    After a quota is created, the quota is automatically initialized and is in the Initializing state. The initialization may take several hours or even longer to complete. The duration of the initialization process depends on the number of files and subdirectories in the directory of your file system. After the quota is initialized, the quota is in the Running state. In the list of user quotas, a quota for which the user type is All Users and the quota type is Statistical is automatically generated. You can change only the quota type, but not the user type of the user quota.

Assign a directory quota to a user

For a statistical quota, you can view the size and number of files that are used by a user or user group in a directory. For a restrictive quota, you can limit the size and number of files that a user or user group can create in a directory.

Note
  • Only General-purpose NFS file systems support directory quotas for a specific user or user group.

  • Only one type of quota can be configured for each user type.

Procedure

On the Quota Management page, find the directory path and click Manage Quotas in the Actions column. In the panel that appears, click Assign Quota to User. In the Assign Quota to User dialog box, configure the parameters. The following table describes the parameters. add_user_quota

Parameter

Required

Description

User Type

Yes

The user type. Valid values: UID, GID, and All Users. The value UID indicates a user. The value GID indicates a user group. The value All Users indicates all users. You can assign different quotas to multiple users for a directory.

ID

No

This parameter is required if you set the User Type parameter to UID or GID. This parameter specifies the ID of a user or the group ID (GID) of a user group.

Examples:

  • If you want to assign a quota to a user whose ID is 500, set the User Type parameter to UID and set the ID parameter to 500.

  • If you want to assign a quota to a user group whose ID is 100, set the User Type parameter to GID and set the ID parameter to 100.

Quota Type

Yes

  • Statistical: If you set this parameter to Statistical, NAS calculates only the usage of storage space in a specified directory of the file system.

  • Restrictive: If you set this parameter to Restrictive and the restrictive quota is used up, I/O operations can no longer be performed.

Capacity Limit (GiB)

No

This parameter is required if you set the Quota Type parameter to Restrictive. This parameter specifies the maximum size of files that a user can create in a directory.

Note
  • The minimum storage capacity is 0 GiB and the maximum storage capacity is 10,000,000 GiB.

  • You must configure at least one of the Capacity Limit (GiB) and File Limit parameters.

File Limit

No

This parameter is required if you set the Quota Type parameter to Restrictive. This parameter specifies the maximum number of files and subdirectories that a user can create in a directory.

Note
  • You must configure at least one of the Capacity Limit (GiB) and File Limit parameters.

  • The minimum number of files is 1 and the maximum number of files is 1,000,000,000.

Delete a directory quota that is assigned to a user

In the list of quotas, find the quota that you want to delete, and click Delete in the Actions column.

Important

When you delete a directory from a file system, all directory quotas and user quotas configured for the directory are also deleted.

Modify a directory quota that is assigned to a user

In the list of quotas, find the quota that you want to modify, and click Edit in the Actions column. You can modify the quota type, capacity limit, and file limit of the quota.

Note

The Capacity Limit and File Limit parameters are available only for restrictive quotas. You must modify at least one of the two parameters.

API

You can call the following API operations to manage directory quotas:

FAQ

Why is the Disk quota exceeded error message returned when data is written to a file system?

  • Cause

    The size or number of files in a directory exceeds the specified user quota. As a result, write operations such as increasing file sizes, creating files or directories, and moving files to another directory fail. The Disk quota exceeded error message is returned.

  • Solution

    1. We recommend that you clear data at your earliest opportunity to free up space, or increase the capacity limit of the directory quota. For more information, see Modify a directory quota that is assigned to a user.

    2. After you clear data, we recommend that you perform test write operations on the directory configured with quotas, for example, creating and writing data to a test file, to trigger asynchronous refresh of the quota cache. Then, restart your service after the test write operations are successful.