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.
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.
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 |
A user ID to limit or warn. It can be either a user name from the password file or the UID number.
A group ID to limit or warn. It can be either a group name from the group file or the GID number.
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.
Specifies the GFS file system to which the actions apply.
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.
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 |
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.
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.
Specifies the GFS file system to which the actions apply.
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.
A user name or ID to which the data is associated.
A group name or ID to which the data is associated.
The hard limit set for the user or group. This value is zero if no limit has been set.
The actual amount of disk space used by the user or group.
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.
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.
Synchronizing Quota Information
gfs_quota sync -f MountPoint |
Specifies the GFS file system to which the actions apply.
Tuning the Time Between Synchronizations
gfs_tool settune MountPoint quota_quantum Seconds |
Specifies the GFS file system to which the actions apply.
Specifies the new time period between regular quota-file synchronizations by GFS. Smaller values may increase contention and slow down performance.
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 |
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.)
gfs_tool settune MountPoint quota_enforce {0|1} |
Specifies the GFS file system to which the actions apply.
0 = disabled
1 = enabled
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.
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.
gfs_tool settune MountPoint quota_account {0|1} |
Specifies the GFS file system to which the actions apply.
0 = disabled
1 = enabled
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.
Note | |
---|---|
Initializing the quota file requires scanning the entire file system and may take a long time. |