<< Back to man.ChinaUnix.net

9.4. GFS Quota Management

File system quotas are used to limit the amount of file-system space a user or group can use. A user or group does not have a quota limit until one is set. GFS keeps track of the space used by each user and group even when there are no limits in place. GFS updates quota information in a transactional way so system crashes do not require quota usages to be reconstructed.

To prevent a performance slowdown, a GFS node synchronizes updates to the quota file only periodically. The "fuzzy" quota accounting can allow users or groups to slightly exceed the set limit. To minimize this, GFS dynamically reduces the synchronization period as a "hard" quota limit is approached.

GFS uses its gfs_quota command to manage quotas. Other Linux quota facilities cannot be used with GFS.

9.4.1. Setting Quotas

Two quota settings are available for each user ID (UID) or group ID (GID): a hard limit and a warn limit.

A hard limit is the amount space that can be used. The file system will not let the user or group use more than that amount of disk space. A hard limit value of zero means that no limit is enforced.

A warn limit is usually a value less than the hard limit. The file system will notify the user or group when the warn limit is reached to warn them of the amount of space they are using. A warn limit value of zero means that no limit is enforced.

Limits are set using the gfs_quota command. The command only needs to be run on a single node where GFS is mounted.

9.4.1.1. Usage

Setting Quotas, Hard Limit

gfs_quota limit -u User -l Size -f MountPoint 
gfs_quota limit -g Group -l Size -f MountPoint 

Setting Quotas, Warn Limit

gfs_quota warn -u User -l Size -f MountPoint
gfs_quota warn -g Group -l Size -f MountPoint

User

A user ID to limit or warn. It can be either a user name from the password file or the UID number.

Group

A group ID to limit or warn. It can be either a group name from the group file or the GID number.

Size

Specifies the new value to limit or warn. By default, the value is in units of megabytes. The additional -k, -s and -b flags change the units to kilobytes, sectors, and file-system blocks, respectively.

MountPoint

Specifies the GFS file system to which the actions apply.

9.4.1.2. Examples

This example sets the hard limit for user Bert to 1024 megabytes (1 gigabyte) on file system /gfs.

gfs_quota limit -u Bert -l 1024 -f /gfs

This example sets the warn limit for group ID 21 to 50 kilobytes on file system /gfs.

gfs_quota warn -g 21 -l 50 -k -f /gfs

9.4.2. Displaying Quota Limits and Usage

Quota limits and current usage can be displayed for a specific user or group using the gfs_quota get command. The entire contents of the quota file can also be displayed using the gfs_quota list command, in which case all IDs with a non-zero hard limit, warn limit, or value are listed.

9.4.2.1. Usage

Displaying Quota Limits for a User

gfs_quota get -u User -f MountPoint

Displaying Quota Limits for a Group

gfs_quota get -g Group -f MountPoint

Displaying Entire Quota File

gfs_quota list -f MountPoint

User

A user ID to display information about a specific user. It can be either a user name from the password file or the UID number.

Group

A group ID to display information about a specific group. It can be either a group name from the group file or the GID number.

MountPoint

Specifies the GFS file system to which the actions apply.

9.4.2.2. Command Output

GFS quota information from the gfs_quota command is displayed as follows:

user User: limit:LimitSize warn:WarnSize value:Value

group Group: limit:LimitSize warn:WarnSize value:Value

The LimitSize, WarnSize, and Value numbers (values) are in units of megabytes by default. Adding the -k, -s, or -b flags to the command line change the units to kilobytes, sectors, or file system blocks, respectively.

User

A user name or ID to which the data is associated.

Group

A group name or ID to which the data is associated.

LimitSize

The hard limit set for the user or group. This value is zero if no limit has been set.

Value

The actual amount of disk space used by the user or group.

9.4.2.3. Comments

When displaying quota information, the gfs_quota command does not resolve UIDs and GIDs into names if the -n option is added to the command line.

Space allocated to GFS's hidden files can be left out of displayed values for the root UID and GID by adding the -d option to the command line. This is useful when trying to match the numbers from gfs_quota with the results of a du command.

9.4.2.4. Examples

This example displays quota information for all users and groups that have a limit set or are using any disk space on file system /gfs.

gfs_quota list -f /gfs

This example displays quota information in sectors for group users on file system /gfs.

gfs_quota get -g users -f /gfs -s

9.4.3. Synchronizing Quotas

GFS stores all quota information in its own internal file on disk. A GFS node does not update this quota file for every file-system write; rather, it updates the quota file once every 60 seconds. This is necessary to avoid contention among nodes writing to the quota file, which would cause a slowdown in performance.

As a user or group approaches their quota limit, GFS dynamically reduces the time between its quota-file updates to prevent the limit from being exceeded. The normal time period between quota synchronizations is a tunable parameter, quota_quantum, and can be changed using the gfs_tool command. By default, the time period is 60 seconds. Also, the quota_quantum parameter must be set on each node and each time the file system is mounted. (Changes to the quota_quantum parameter are not persistent across unmounts.)

You can use the gfs_quota sync command to synchronize the quota information from a node to the on-disk quota file between the automatic updates performed by GFS.

9.4.3.1. Usage

Synchronizing Quota Information

gfs_quota sync -f MountPoint

MountPoint

Specifies the GFS file system to which the actions apply.

Tuning the Time Between Synchronizations

gfs_tool settune MountPoint quota_quantum Seconds

MountPoint

Specifies the GFS file system to which the actions apply.

Seconds

Specifies the new time period between regular quota-file synchronizations by GFS. Smaller values may increase contention and slow down performance.

9.4.3.2. Examples

This example synchronizes the quota information from the node it is run on to file system /gfs.

gfs_quota sync -f /gfs

This example changes the default time period between regular quota-file updates to one hour (3600 seconds) for file system /gfs on a single node.

gfs_tool settune /gfs quota_quantum 3600

9.4.4. Disabling/Enabling Quota Enforcement

Enforcement of quotas can be disabled for a file system without clearing the limits set for all users and groups. Enforcement can also be enabled. Disabling and enabling of quota enforcement is done by changing a tunable parameter, quota_enforce, with the gfs_tool command. The quota_enforce parameter must be disabled or enabled on each node where quota enforcement should be disabled/enabled. Each time the file system is mounted, enforcement is enabled by default. (Disabling is not persistent across unmounts.)

9.4.4.1. Usage

gfs_tool settune MountPoint quota_enforce {0|1}

MountPoint

Specifies the GFS file system to which the actions apply.

quota_enforce {0|1}

0 = disabled

1 = enabled

9.4.4.2. Comments

A value of 0 disables enforcement. Enforcement can be enabled by running the command with a value of 1 (instead of 0) as the final command line parameter. Even when GFS is not enforcing quotas, it still keeps track of the file system usage for all users and groups so that quota-usage information does not require rebuilding after re-enabling quotas.

9.4.4.3. Examples

This example disables quota enforcement on file system /gfs.

gfs_tool settune /gfs quota_enforce 0

This example enables quota enforcement on file system /gfs.

gfs_tool settune /gfs quota_enforce 1

9.4.5. Disabling/Enabling Quota Accounting

By default, GFS keeps track of disk usage for every user and group even when no quota limits have been set. This accounting incurs some overhead that is unnecessary if quotas are not used. This quota accounting can be completely disabled by setting the quota_account tunable parameter to 0. This must be done on each node and after each mount. (The 0 setting is not persistent across unmounts.) Quota accounting can be enabled by setting the quota_account tunable parameter to 1.

9.4.5.1. Usage

gfs_tool settune MountPoint quota_account {0|1}

MountPoint

Specifies the GFS file system to which the actions apply.

quota_account {0|1}

0 = disabled

1 = enabled

9.4.5.2. Comments

To enable quota accounting on a file system, the quota_account parameter must be set back to 1. Afterward, the GFS quota file must be initialized to account for all current disk usage for users and groups on the file system. The quota file is initialized by running: gfs_quota init -f MountPoint.

NoteNote
 

Initializing the quota file requires scanning the entire file system and may take a long time.

9.4.5.3. Examples

This example disables quota accounting on file system /gfs on a single node.

gfs_tool settune /gfs quota_account 0

This example enables quota accounting on file system /gfs on a single node and initializes the quota file.

gfs_tool settune /gfs quota_account 1

gfs_quota init -f /gfs