quota.rst 3.3 KB

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