dqblk_xfs.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */
  2. /*
  3. * Copyright (c) 1995-2001,2004 Silicon Graphics, Inc. All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public License
  7. * as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesset General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef _LINUX_DQBLK_XFS_H
  19. #define _LINUX_DQBLK_XFS_H
  20. #include <linux/types.h>
  21. /*
  22. * Disk quota - quotactl(2) commands for the XFS Quota Manager (XQM).
  23. */
  24. #define XQM_CMD(x) (('X'<<8)+(x)) /* note: forms first QCMD argument */
  25. #define XQM_COMMAND(x) (((x) & (0xff<<8)) == ('X'<<8)) /* test if for XFS */
  26. #define XQM_USRQUOTA 0 /* system call user quota type */
  27. #define XQM_GRPQUOTA 1 /* system call group quota type */
  28. #define XQM_PRJQUOTA 2 /* system call project quota type */
  29. #define XQM_MAXQUOTAS 3
  30. #define Q_XQUOTAON XQM_CMD(1) /* enable accounting/enforcement */
  31. #define Q_XQUOTAOFF XQM_CMD(2) /* disable accounting/enforcement */
  32. #define Q_XGETQUOTA XQM_CMD(3) /* get disk limits and usage */
  33. #define Q_XSETQLIM XQM_CMD(4) /* set disk limits */
  34. #define Q_XGETQSTAT XQM_CMD(5) /* get quota subsystem status */
  35. #define Q_XQUOTARM XQM_CMD(6) /* free disk space used by dquots */
  36. #define Q_XQUOTASYNC XQM_CMD(7) /* delalloc flush, updates dquots */
  37. #define Q_XGETQSTATV XQM_CMD(8) /* newer version of get quota */
  38. #define Q_XGETNEXTQUOTA XQM_CMD(9) /* get disk limits and usage >= ID */
  39. /*
  40. * fs_disk_quota structure:
  41. *
  42. * This contains the current quota information regarding a user/proj/group.
  43. * It is 64-bit aligned, and all the blk units are in BBs (Basic Blocks) of
  44. * 512 bytes.
  45. */
  46. #define FS_DQUOT_VERSION 1 /* fs_disk_quota.d_version */
  47. typedef struct fs_disk_quota {
  48. __s8 d_version; /* version of this structure */
  49. __s8 d_flags; /* FS_{USER,PROJ,GROUP}_QUOTA */
  50. __u16 d_fieldmask; /* field specifier */
  51. __u32 d_id; /* user, project, or group ID */
  52. __u64 d_blk_hardlimit;/* absolute limit on disk blks */
  53. __u64 d_blk_softlimit;/* preferred limit on disk blks */
  54. __u64 d_ino_hardlimit;/* maximum # allocated inodes */
  55. __u64 d_ino_softlimit;/* preferred inode limit */
  56. __u64 d_bcount; /* # disk blocks owned by the user */
  57. __u64 d_icount; /* # inodes owned by the user */
  58. __s32 d_itimer; /* zero if within inode limits */
  59. /* if not, we refuse service */
  60. __s32 d_btimer; /* similar to above; for disk blocks */
  61. __u16 d_iwarns; /* # warnings issued wrt num inodes */
  62. __u16 d_bwarns; /* # warnings issued wrt disk blocks */
  63. __s32 d_padding2; /* padding2 - for future use */
  64. __u64 d_rtb_hardlimit;/* absolute limit on realtime blks */
  65. __u64 d_rtb_softlimit;/* preferred limit on RT disk blks */
  66. __u64 d_rtbcount; /* # realtime blocks owned */
  67. __s32 d_rtbtimer; /* similar to above; for RT disk blks */
  68. __u16 d_rtbwarns; /* # warnings issued wrt RT disk blks */
  69. __s16 d_padding3; /* padding3 - for future use */
  70. char d_padding4[8]; /* yet more padding */
  71. } fs_disk_quota_t;
  72. /*
  73. * These fields are sent to Q_XSETQLIM to specify fields that need to change.
  74. */
  75. #define FS_DQ_ISOFT (1<<0)
  76. #define FS_DQ_IHARD (1<<1)
  77. #define FS_DQ_BSOFT (1<<2)
  78. #define FS_DQ_BHARD (1<<3)
  79. #define FS_DQ_RTBSOFT (1<<4)
  80. #define FS_DQ_RTBHARD (1<<5)
  81. #define FS_DQ_LIMIT_MASK (FS_DQ_ISOFT | FS_DQ_IHARD | FS_DQ_BSOFT | \
  82. FS_DQ_BHARD | FS_DQ_RTBSOFT | FS_DQ_RTBHARD)
  83. /*
  84. * These timers can only be set in super user's dquot. For others, timers are
  85. * automatically started and stopped. Superusers timer values set the limits
  86. * for the rest. In case these values are zero, the DQ_{F,B}TIMELIMIT values
  87. * defined below are used.
  88. * These values also apply only to the d_fieldmask field for Q_XSETQLIM.
  89. */
  90. #define FS_DQ_BTIMER (1<<6)
  91. #define FS_DQ_ITIMER (1<<7)
  92. #define FS_DQ_RTBTIMER (1<<8)
  93. #define FS_DQ_TIMER_MASK (FS_DQ_BTIMER | FS_DQ_ITIMER | FS_DQ_RTBTIMER)
  94. /*
  95. * Warning counts are set in both super user's dquot and others. For others,
  96. * warnings are set/cleared by the administrators (or automatically by going
  97. * below the soft limit). Superusers warning values set the warning limits
  98. * for the rest. In case these values are zero, the DQ_{F,B}WARNLIMIT values
  99. * defined below are used.
  100. * These values also apply only to the d_fieldmask field for Q_XSETQLIM.
  101. */
  102. #define FS_DQ_BWARNS (1<<9)
  103. #define FS_DQ_IWARNS (1<<10)
  104. #define FS_DQ_RTBWARNS (1<<11)
  105. #define FS_DQ_WARNS_MASK (FS_DQ_BWARNS | FS_DQ_IWARNS | FS_DQ_RTBWARNS)
  106. /*
  107. * Accounting values. These can only be set for filesystem with
  108. * non-transactional quotas that require quotacheck(8) in userspace.
  109. */
  110. #define FS_DQ_BCOUNT (1<<12)
  111. #define FS_DQ_ICOUNT (1<<13)
  112. #define FS_DQ_RTBCOUNT (1<<14)
  113. #define FS_DQ_ACCT_MASK (FS_DQ_BCOUNT | FS_DQ_ICOUNT | FS_DQ_RTBCOUNT)
  114. /*
  115. * Various flags related to quotactl(2).
  116. */
  117. #define FS_QUOTA_UDQ_ACCT (1<<0) /* user quota accounting */
  118. #define FS_QUOTA_UDQ_ENFD (1<<1) /* user quota limits enforcement */
  119. #define FS_QUOTA_GDQ_ACCT (1<<2) /* group quota accounting */
  120. #define FS_QUOTA_GDQ_ENFD (1<<3) /* group quota limits enforcement */
  121. #define FS_QUOTA_PDQ_ACCT (1<<4) /* project quota accounting */
  122. #define FS_QUOTA_PDQ_ENFD (1<<5) /* project quota limits enforcement */
  123. #define FS_USER_QUOTA (1<<0) /* user quota type */
  124. #define FS_PROJ_QUOTA (1<<1) /* project quota type */
  125. #define FS_GROUP_QUOTA (1<<2) /* group quota type */
  126. /*
  127. * fs_quota_stat is the struct returned in Q_XGETQSTAT for a given file system.
  128. * Provides a centralized way to get meta information about the quota subsystem.
  129. * eg. space taken up for user and group quotas, number of dquots currently
  130. * incore.
  131. */
  132. #define FS_QSTAT_VERSION 1 /* fs_quota_stat.qs_version */
  133. /*
  134. * Some basic information about 'quota files'.
  135. */
  136. typedef struct fs_qfilestat {
  137. __u64 qfs_ino; /* inode number */
  138. __u64 qfs_nblks; /* number of BBs 512-byte-blks */
  139. __u32 qfs_nextents; /* number of extents */
  140. } fs_qfilestat_t;
  141. typedef struct fs_quota_stat {
  142. __s8 qs_version; /* version number for future changes */
  143. __u16 qs_flags; /* FS_QUOTA_{U,P,G}DQ_{ACCT,ENFD} */
  144. __s8 qs_pad; /* unused */
  145. fs_qfilestat_t qs_uquota; /* user quota storage information */
  146. fs_qfilestat_t qs_gquota; /* group quota storage information */
  147. __u32 qs_incoredqs; /* number of dquots incore */
  148. __s32 qs_btimelimit; /* limit for blks timer */
  149. __s32 qs_itimelimit; /* limit for inodes timer */
  150. __s32 qs_rtbtimelimit;/* limit for rt blks timer */
  151. __u16 qs_bwarnlimit; /* limit for num warnings */
  152. __u16 qs_iwarnlimit; /* limit for num warnings */
  153. } fs_quota_stat_t;
  154. /*
  155. * fs_quota_statv is used by Q_XGETQSTATV for a given file system. It provides
  156. * a centralized way to get meta information about the quota subsystem. eg.
  157. * space taken up for user, group, and project quotas, number of dquots
  158. * currently incore.
  159. *
  160. * This version has proper versioning support with appropriate padding for
  161. * future expansions, and ability to expand for future without creating any
  162. * backward compatibility issues.
  163. *
  164. * Q_XGETQSTATV uses the passed in value of the requested version via
  165. * fs_quota_statv.qs_version to determine the return data layout of
  166. * fs_quota_statv. The kernel will fill the data fields relevant to that
  167. * version.
  168. *
  169. * If kernel does not support user space caller specified version, EINVAL will
  170. * be returned. User space caller can then reduce the version number and retry
  171. * the same command.
  172. */
  173. #define FS_QSTATV_VERSION1 1 /* fs_quota_statv.qs_version */
  174. /*
  175. * Some basic information about 'quota files' for Q_XGETQSTATV command
  176. */
  177. struct fs_qfilestatv {
  178. __u64 qfs_ino; /* inode number */
  179. __u64 qfs_nblks; /* number of BBs 512-byte-blks */
  180. __u32 qfs_nextents; /* number of extents */
  181. __u32 qfs_pad; /* pad for 8-byte alignment */
  182. };
  183. struct fs_quota_statv {
  184. __s8 qs_version; /* version for future changes */
  185. __u8 qs_pad1; /* pad for 16bit alignment */
  186. __u16 qs_flags; /* FS_QUOTA_.* flags */
  187. __u32 qs_incoredqs; /* number of dquots incore */
  188. struct fs_qfilestatv qs_uquota; /* user quota information */
  189. struct fs_qfilestatv qs_gquota; /* group quota information */
  190. struct fs_qfilestatv qs_pquota; /* project quota information */
  191. __s32 qs_btimelimit; /* limit for blks timer */
  192. __s32 qs_itimelimit; /* limit for inodes timer */
  193. __s32 qs_rtbtimelimit;/* limit for rt blks timer */
  194. __u16 qs_bwarnlimit; /* limit for num warnings */
  195. __u16 qs_iwarnlimit; /* limit for num warnings */
  196. __u64 qs_pad2[8]; /* for future proofing */
  197. };
  198. #endif /* _LINUX_DQBLK_XFS_H */