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