All Products
Search
Document Center

Apsara File Storage NAS:Manage directory quotas

Last Updated:Apr 03, 2024

If you need to limit the number or size of files that a directory in a General-purpose Apsara File Storage NAS (NAS) file system can contain, or the resources that a user can use, you can configure directory quotas or user quotas by using the quota management feature. You can also configure different resource quotas for multiple users in the same directory.

Prerequisites

  • A 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.

  • Restricted 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.

  • 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 restricted 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 restricted quotas before you create the restricted quotas for core business-related directories.

    • The operation to enable a restricted 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 do not support directory quotas in the Australia (Sydney) region and the China South 1 Finance region.

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, for example, /dir/subdir1.

    Note
    • You can configure quotas only for directories that have been created in a NAS file system.

    • Each quota is associated with a directory. The directory that you specify in this step is the absolute path of the directory in the NAS file system.

  6. Query the status of the quota.

    After the quota is created, the quota is automatically initialized and is in the In initialization state. The duration of the initialization process varies depending on the number of files and subdirectories in the directory of the 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 restricted 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 and choose Manage Quotas > 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

Type of User

Yes

The user type. Valid values: Uid, Gid, and AllUsers. The value Uid indicates a user. The value Gid indicates a user group. The value AllUsers indicates all users. You can assign different quotas to multiple users for a directory.

ID

No

This parameter is required if you set the Type of User 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 Type of User 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 Type of User 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.

  • Restricted: If you set this parameter to Restricted and the restricted 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 Restricted. 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 Restricted. 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

On the Quota Management page, find the quota that you want to delete, and click Delete.

Note

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

On the Quota Management page, find the quota that you want to modify, and click Edit. 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 restricted quotas. You must modify at least one of the two parameters.

API operations

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 quota of the directory. 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.