^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ===============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) Quota subsystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) ===============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) Quota subsystem allows system administrator to set limits on used space and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) number of used inodes (inode is a filesystem structure which is associated with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) each file or directory) for users and/or groups. For both used space and number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) of used inodes there are actually two limits. The first one is called softlimit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) and the second one hardlimit. A user can never exceed a hardlimit for any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) resource (unless he has CAP_SYS_RESOURCE capability). User is allowed to exceed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) softlimit but only for limited period of time. This period is called "grace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) period" or "grace time". When grace time is over, user is not able to allocate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) more space/inodes until he frees enough of them to get below softlimit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) Quota limits (and amount of grace time) are set independently for each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) filesystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) For more details about quota design, see the documentation in quota-tools package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) (https://sourceforge.net/projects/linuxquota).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) Quota netlink interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) =======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) When user exceeds a softlimit, runs out of grace time or reaches hardlimit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) quota subsystem traditionally printed a message to the controlling terminal of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) the process which caused the excess. This method has the disadvantage that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) when user is using a graphical desktop he usually cannot see the message.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) Thus quota netlink interface has been designed to pass information about
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) the above events to userspace. There they can be captured by an application
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) and processed accordingly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) The interface uses generic netlink framework (see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) https://lwn.net/Articles/208755/ and http://www.infradead.org/~tgr/libnl/ for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) more details about this layer). The name of the quota generic netlink interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) is "VFS_DQUOT". Definitions of constants below are in <linux/quota.h>. Since
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) the quota netlink protocol is not namespace aware, quota netlink messages are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) sent only in initial network namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) Currently, the interface supports only one message type QUOTA_NL_C_WARNING.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) This command is used to send a notification about any of the above mentioned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) events. Each message has six attributes. These are (type of the argument is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) in parentheses):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) QUOTA_NL_A_QTYPE (u32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) - type of quota being exceeded (one of USRQUOTA, GRPQUOTA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) QUOTA_NL_A_EXCESS_ID (u64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) - UID/GID (depends on quota type) of user / group whose limit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) is being exceeded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) QUOTA_NL_A_CAUSED_ID (u64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) - UID of a user who caused the event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) QUOTA_NL_A_WARNING (u32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) - what kind of limit is exceeded:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) QUOTA_NL_IHARDWARN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) inode hardlimit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) QUOTA_NL_ISOFTLONGWARN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) inode softlimit is exceeded longer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) than given grace period
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) QUOTA_NL_ISOFTWARN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) inode softlimit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) QUOTA_NL_BHARDWARN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) space (block) hardlimit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) QUOTA_NL_BSOFTLONGWARN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) space (block) softlimit is exceeded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) longer than given grace period.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) QUOTA_NL_BSOFTWARN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) space (block) softlimit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) - four warnings are also defined for the event when user stops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) exceeding some limit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) QUOTA_NL_IHARDBELOW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) inode hardlimit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) QUOTA_NL_ISOFTBELOW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) inode softlimit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) QUOTA_NL_BHARDBELOW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) space (block) hardlimit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) QUOTA_NL_BSOFTBELOW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) space (block) softlimit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) QUOTA_NL_A_DEV_MAJOR (u32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) - major number of a device with the affected filesystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) QUOTA_NL_A_DEV_MINOR (u32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) - minor number of a device with the affected filesystem