Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GPL-2.0
0002 
0003 ===============
0004 Quota subsystem
0005 ===============
0006 
0007 Quota subsystem allows system administrator to set limits on used space and
0008 number of used inodes (inode is a filesystem structure which is associated with
0009 each file or directory) for users and/or groups. For both used space and number
0010 of used inodes there are actually two limits. The first one is called softlimit
0011 and the second one hardlimit.  A user can never exceed a hardlimit for any
0012 resource (unless he has CAP_SYS_RESOURCE capability). User is allowed to exceed
0013 softlimit but only for limited period of time. This period is called "grace
0014 period" or "grace time". When grace time is over, user is not able to allocate
0015 more space/inodes until he frees enough of them to get below softlimit.
0016 
0017 Quota limits (and amount of grace time) are set independently for each
0018 filesystem.
0019 
0020 For more details about quota design, see the documentation in quota-tools package
0021 (https://sourceforge.net/projects/linuxquota).
0022 
0023 Quota netlink interface
0024 =======================
0025 When user exceeds a softlimit, runs out of grace time or reaches hardlimit,
0026 quota subsystem traditionally printed a message to the controlling terminal of
0027 the process which caused the excess. This method has the disadvantage that
0028 when user is using a graphical desktop he usually cannot see the message.
0029 Thus quota netlink interface has been designed to pass information about
0030 the above events to userspace. There they can be captured by an application
0031 and processed accordingly.
0032 
0033 The interface uses generic netlink framework (see
0034 https://lwn.net/Articles/208755/ and http://www.infradead.org/~tgr/libnl/ for
0035 more details about this layer). The name of the quota generic netlink interface
0036 is "VFS_DQUOT". Definitions of constants below are in <linux/quota.h>.  Since
0037 the quota netlink protocol is not namespace aware, quota netlink messages are
0038 sent only in initial network namespace.
0039 
0040 Currently, the interface supports only one message type QUOTA_NL_C_WARNING.
0041 This command is used to send a notification about any of the above mentioned
0042 events. Each message has six attributes. These are (type of the argument is
0043 in parentheses):
0044 
0045         QUOTA_NL_A_QTYPE (u32)
0046           - type of quota being exceeded (one of USRQUOTA, GRPQUOTA)
0047         QUOTA_NL_A_EXCESS_ID (u64)
0048           - UID/GID (depends on quota type) of user / group whose limit
0049             is being exceeded.
0050         QUOTA_NL_A_CAUSED_ID (u64)
0051           - UID of a user who caused the event
0052         QUOTA_NL_A_WARNING (u32)
0053           - what kind of limit is exceeded:
0054 
0055                 QUOTA_NL_IHARDWARN
0056                     inode hardlimit
0057                 QUOTA_NL_ISOFTLONGWARN
0058                     inode softlimit is exceeded longer
0059                     than given grace period
0060                 QUOTA_NL_ISOFTWARN
0061                     inode softlimit
0062                 QUOTA_NL_BHARDWARN
0063                     space (block) hardlimit
0064                 QUOTA_NL_BSOFTLONGWARN
0065                     space (block) softlimit is exceeded
0066                     longer than given grace period.
0067                 QUOTA_NL_BSOFTWARN
0068                     space (block) softlimit
0069 
0070           - four warnings are also defined for the event when user stops
0071             exceeding some limit:
0072 
0073                 QUOTA_NL_IHARDBELOW
0074                     inode hardlimit
0075                 QUOTA_NL_ISOFTBELOW
0076                     inode softlimit
0077                 QUOTA_NL_BHARDBELOW
0078                     space (block) hardlimit
0079                 QUOTA_NL_BSOFTBELOW
0080                     space (block) softlimit
0081 
0082         QUOTA_NL_A_DEV_MAJOR (u32)
0083           - major number of a device with the affected filesystem
0084         QUOTA_NL_A_DEV_MINOR (u32)
0085           - minor number of a device with the affected filesystem