xref: /linux/include/uapi/linux/dqblk_xfs.h (revision 8be98d2f2a0a262f8bf8a0bc1fdf522b3c7aab17)
1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */
2607ca46eSDavid Howells /*
3607ca46eSDavid Howells  * Copyright (c) 1995-2001,2004 Silicon Graphics, Inc.  All Rights Reserved.
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  * This program is free software; you can redistribute it and/or
6607ca46eSDavid Howells  * modify it under the terms of the GNU Lesser General Public License
7607ca46eSDavid Howells  * as published by the Free Software Foundation.
8607ca46eSDavid Howells  *
9607ca46eSDavid Howells  * This program is distributed in the hope that it will be useful,
10607ca46eSDavid Howells  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11607ca46eSDavid Howells  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12607ca46eSDavid Howells  * GNU Lesser General Public License for more details.
13607ca46eSDavid Howells  *
14607ca46eSDavid Howells  * You should have received a copy of the GNU Lesset General Public License
15607ca46eSDavid Howells  * along with this program; if not, write to the Free Software Foundation,
16607ca46eSDavid Howells  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17607ca46eSDavid Howells  */
18607ca46eSDavid Howells #ifndef _LINUX_DQBLK_XFS_H
19607ca46eSDavid Howells #define _LINUX_DQBLK_XFS_H
20607ca46eSDavid Howells 
21607ca46eSDavid Howells #include <linux/types.h>
22607ca46eSDavid Howells 
23607ca46eSDavid Howells /*
24607ca46eSDavid Howells  * Disk quota - quotactl(2) commands for the XFS Quota Manager (XQM).
25607ca46eSDavid Howells  */
26607ca46eSDavid Howells 
27607ca46eSDavid Howells #define XQM_CMD(x)	(('X'<<8)+(x))	/* note: forms first QCMD argument */
28607ca46eSDavid Howells #define XQM_COMMAND(x)	(((x) & (0xff<<8)) == ('X'<<8))	/* test if for XFS */
29607ca46eSDavid Howells 
30607ca46eSDavid Howells #define XQM_USRQUOTA	0	/* system call user quota type */
31607ca46eSDavid Howells #define XQM_GRPQUOTA	1	/* system call group quota type */
32607ca46eSDavid Howells #define XQM_PRJQUOTA	2	/* system call project quota type */
33607ca46eSDavid Howells #define XQM_MAXQUOTAS	3
34607ca46eSDavid Howells 
35607ca46eSDavid Howells #define Q_XQUOTAON	XQM_CMD(1)	/* enable accounting/enforcement */
36607ca46eSDavid Howells #define Q_XQUOTAOFF	XQM_CMD(2)	/* disable accounting/enforcement */
37607ca46eSDavid Howells #define Q_XGETQUOTA	XQM_CMD(3)	/* get disk limits and usage */
38607ca46eSDavid Howells #define Q_XSETQLIM	XQM_CMD(4)	/* set disk limits */
39607ca46eSDavid Howells #define Q_XGETQSTAT	XQM_CMD(5)	/* get quota subsystem status */
40607ca46eSDavid Howells #define Q_XQUOTARM	XQM_CMD(6)	/* free disk space used by dquots */
41607ca46eSDavid Howells #define Q_XQUOTASYNC	XQM_CMD(7)	/* delalloc flush, updates dquots */
42af30cb44SChandra Seetharaman #define Q_XGETQSTATV	XQM_CMD(8)	/* newer version of get quota */
438b375249SEric Sandeen #define Q_XGETNEXTQUOTA	XQM_CMD(9)	/* get disk limits and usage >= ID */
44607ca46eSDavid Howells 
45607ca46eSDavid Howells /*
46607ca46eSDavid Howells  * fs_disk_quota structure:
47607ca46eSDavid Howells  *
48607ca46eSDavid Howells  * This contains the current quota information regarding a user/proj/group.
49607ca46eSDavid Howells  * It is 64-bit aligned, and all the blk units are in BBs (Basic Blocks) of
50607ca46eSDavid Howells  * 512 bytes.
51607ca46eSDavid Howells  */
52607ca46eSDavid Howells #define FS_DQUOT_VERSION	1	/* fs_disk_quota.d_version */
53607ca46eSDavid Howells typedef struct fs_disk_quota {
54607ca46eSDavid Howells 	__s8		d_version;	/* version of this structure */
55607ca46eSDavid Howells 	__s8		d_flags;	/* FS_{USER,PROJ,GROUP}_QUOTA */
56607ca46eSDavid Howells 	__u16		d_fieldmask;	/* field specifier */
57607ca46eSDavid Howells 	__u32		d_id;		/* user, project, or group ID */
58607ca46eSDavid Howells 	__u64		d_blk_hardlimit;/* absolute limit on disk blks */
59607ca46eSDavid Howells 	__u64		d_blk_softlimit;/* preferred limit on disk blks */
60607ca46eSDavid Howells 	__u64		d_ino_hardlimit;/* maximum # allocated inodes */
61607ca46eSDavid Howells 	__u64		d_ino_softlimit;/* preferred inode limit */
62607ca46eSDavid Howells 	__u64		d_bcount;	/* # disk blocks owned by the user */
63607ca46eSDavid Howells 	__u64		d_icount;	/* # inodes owned by the user */
64d1c10767SJan Kara 	__s32		d_itimer;	/* Zero if within inode limits. If
65d1c10767SJan Kara 					 * not, we refuse service at this time
66d1c10767SJan Kara 					 * (in seconds since Unix epoch) */
67607ca46eSDavid Howells 	__s32		d_btimer;	/* similar to above; for disk blocks */
68607ca46eSDavid Howells 	__u16	  	d_iwarns;       /* # warnings issued wrt num inodes */
69607ca46eSDavid Howells 	__u16	  	d_bwarns;       /* # warnings issued wrt disk blocks */
70ad47ff33SDarrick J. Wong 	__s8		d_itimer_hi;	/* upper 8 bits of timer values */
71ad47ff33SDarrick J. Wong 	__s8		d_btimer_hi;
72ad47ff33SDarrick J. Wong 	__s8		d_rtbtimer_hi;
73ad47ff33SDarrick J. Wong 	__s8		d_padding2;	/* padding2 - for future use */
74607ca46eSDavid Howells 	__u64		d_rtb_hardlimit;/* absolute limit on realtime blks */
75607ca46eSDavid Howells 	__u64		d_rtb_softlimit;/* preferred limit on RT disk blks */
76607ca46eSDavid Howells 	__u64		d_rtbcount;	/* # realtime blocks owned */
77607ca46eSDavid Howells 	__s32		d_rtbtimer;	/* similar to above; for RT disk blks */
78607ca46eSDavid Howells 	__u16	  	d_rtbwarns;     /* # warnings issued wrt RT disk blks */
79607ca46eSDavid Howells 	__s16		d_padding3;	/* padding3 - for future use */
80607ca46eSDavid Howells 	char		d_padding4[8];	/* yet more padding */
81607ca46eSDavid Howells } fs_disk_quota_t;
82607ca46eSDavid Howells 
83607ca46eSDavid Howells /*
84607ca46eSDavid Howells  * These fields are sent to Q_XSETQLIM to specify fields that need to change.
85607ca46eSDavid Howells  */
86607ca46eSDavid Howells #define FS_DQ_ISOFT	(1<<0)
87607ca46eSDavid Howells #define FS_DQ_IHARD	(1<<1)
88607ca46eSDavid Howells #define FS_DQ_BSOFT	(1<<2)
89607ca46eSDavid Howells #define FS_DQ_BHARD 	(1<<3)
90607ca46eSDavid Howells #define FS_DQ_RTBSOFT	(1<<4)
91607ca46eSDavid Howells #define FS_DQ_RTBHARD	(1<<5)
92607ca46eSDavid Howells #define FS_DQ_LIMIT_MASK	(FS_DQ_ISOFT | FS_DQ_IHARD | FS_DQ_BSOFT | \
93607ca46eSDavid Howells 				 FS_DQ_BHARD | FS_DQ_RTBSOFT | FS_DQ_RTBHARD)
94607ca46eSDavid Howells /*
95607ca46eSDavid Howells  * These timers can only be set in super user's dquot. For others, timers are
96607ca46eSDavid Howells  * automatically started and stopped. Superusers timer values set the limits
97607ca46eSDavid Howells  * for the rest.  In case these values are zero, the DQ_{F,B}TIMELIMIT values
98607ca46eSDavid Howells  * defined below are used.
99607ca46eSDavid Howells  * These values also apply only to the d_fieldmask field for Q_XSETQLIM.
100607ca46eSDavid Howells  */
101607ca46eSDavid Howells #define FS_DQ_BTIMER	(1<<6)
102607ca46eSDavid Howells #define FS_DQ_ITIMER	(1<<7)
103607ca46eSDavid Howells #define FS_DQ_RTBTIMER 	(1<<8)
104607ca46eSDavid Howells #define FS_DQ_TIMER_MASK	(FS_DQ_BTIMER | FS_DQ_ITIMER | FS_DQ_RTBTIMER)
105607ca46eSDavid Howells 
106607ca46eSDavid Howells /*
107607ca46eSDavid Howells  * Warning counts are set in both super user's dquot and others. For others,
108607ca46eSDavid Howells  * warnings are set/cleared by the administrators (or automatically by going
109607ca46eSDavid Howells  * below the soft limit).  Superusers warning values set the warning limits
110607ca46eSDavid Howells  * for the rest.  In case these values are zero, the DQ_{F,B}WARNLIMIT values
111607ca46eSDavid Howells  * defined below are used.
112607ca46eSDavid Howells  * These values also apply only to the d_fieldmask field for Q_XSETQLIM.
113607ca46eSDavid Howells  */
114607ca46eSDavid Howells #define FS_DQ_BWARNS	(1<<9)
115607ca46eSDavid Howells #define FS_DQ_IWARNS	(1<<10)
116607ca46eSDavid Howells #define FS_DQ_RTBWARNS	(1<<11)
117607ca46eSDavid Howells #define FS_DQ_WARNS_MASK	(FS_DQ_BWARNS | FS_DQ_IWARNS | FS_DQ_RTBWARNS)
118607ca46eSDavid Howells 
119607ca46eSDavid Howells /*
120607ca46eSDavid Howells  * Accounting values.  These can only be set for filesystem with
121607ca46eSDavid Howells  * non-transactional quotas that require quotacheck(8) in userspace.
122607ca46eSDavid Howells  */
123607ca46eSDavid Howells #define FS_DQ_BCOUNT		(1<<12)
124607ca46eSDavid Howells #define FS_DQ_ICOUNT		(1<<13)
125607ca46eSDavid Howells #define FS_DQ_RTBCOUNT		(1<<14)
126607ca46eSDavid Howells #define FS_DQ_ACCT_MASK		(FS_DQ_BCOUNT | FS_DQ_ICOUNT | FS_DQ_RTBCOUNT)
127607ca46eSDavid Howells 
128607ca46eSDavid Howells /*
129ad47ff33SDarrick J. Wong  * Quota expiration timestamps are 40-bit signed integers, with the upper 8
130ad47ff33SDarrick J. Wong  * bits encoded in the _hi fields.
131ad47ff33SDarrick J. Wong  */
132ad47ff33SDarrick J. Wong #define FS_DQ_BIGTIME		(1<<15)
133ad47ff33SDarrick J. Wong 
134ad47ff33SDarrick J. Wong /*
135607ca46eSDavid Howells  * Various flags related to quotactl(2).
136607ca46eSDavid Howells  */
137607ca46eSDavid Howells #define FS_QUOTA_UDQ_ACCT	(1<<0)  /* user quota accounting */
138607ca46eSDavid Howells #define FS_QUOTA_UDQ_ENFD	(1<<1)  /* user quota limits enforcement */
139607ca46eSDavid Howells #define FS_QUOTA_GDQ_ACCT	(1<<2)  /* group quota accounting */
140607ca46eSDavid Howells #define FS_QUOTA_GDQ_ENFD	(1<<3)  /* group quota limits enforcement */
141607ca46eSDavid Howells #define FS_QUOTA_PDQ_ACCT	(1<<4)  /* project quota accounting */
142607ca46eSDavid Howells #define FS_QUOTA_PDQ_ENFD	(1<<5)  /* project quota limits enforcement */
143607ca46eSDavid Howells 
144607ca46eSDavid Howells #define FS_USER_QUOTA		(1<<0)	/* user quota type */
145607ca46eSDavid Howells #define FS_PROJ_QUOTA		(1<<1)	/* project quota type */
146607ca46eSDavid Howells #define FS_GROUP_QUOTA		(1<<2)	/* group quota type */
147607ca46eSDavid Howells 
148607ca46eSDavid Howells /*
149607ca46eSDavid Howells  * fs_quota_stat is the struct returned in Q_XGETQSTAT for a given file system.
150607ca46eSDavid Howells  * Provides a centralized way to get meta information about the quota subsystem.
151607ca46eSDavid Howells  * eg. space taken up for user and group quotas, number of dquots currently
152607ca46eSDavid Howells  * incore.
153607ca46eSDavid Howells  */
154607ca46eSDavid Howells #define FS_QSTAT_VERSION	1	/* fs_quota_stat.qs_version */
155607ca46eSDavid Howells 
156607ca46eSDavid Howells /*
157607ca46eSDavid Howells  * Some basic information about 'quota files'.
158607ca46eSDavid Howells  */
159607ca46eSDavid Howells typedef struct fs_qfilestat {
160607ca46eSDavid Howells 	__u64		qfs_ino;	/* inode number */
161607ca46eSDavid Howells 	__u64		qfs_nblks;	/* number of BBs 512-byte-blks */
162607ca46eSDavid Howells 	__u32		qfs_nextents;	/* number of extents */
163607ca46eSDavid Howells } fs_qfilestat_t;
164607ca46eSDavid Howells 
165607ca46eSDavid Howells typedef struct fs_quota_stat {
166607ca46eSDavid Howells 	__s8		qs_version;	/* version number for future changes */
167607ca46eSDavid Howells 	__u16		qs_flags;	/* FS_QUOTA_{U,P,G}DQ_{ACCT,ENFD} */
168607ca46eSDavid Howells 	__s8		qs_pad;		/* unused */
169607ca46eSDavid Howells 	fs_qfilestat_t	qs_uquota;	/* user quota storage information */
170607ca46eSDavid Howells 	fs_qfilestat_t	qs_gquota;	/* group quota storage information */
171607ca46eSDavid Howells 	__u32		qs_incoredqs;	/* number of dquots incore */
172607ca46eSDavid Howells 	__s32		qs_btimelimit;  /* limit for blks timer */
173607ca46eSDavid Howells 	__s32		qs_itimelimit;  /* limit for inodes timer */
174607ca46eSDavid Howells 	__s32		qs_rtbtimelimit;/* limit for rt blks timer */
175607ca46eSDavid Howells 	__u16		qs_bwarnlimit;	/* limit for num warnings */
176607ca46eSDavid Howells 	__u16		qs_iwarnlimit;	/* limit for num warnings */
177607ca46eSDavid Howells } fs_quota_stat_t;
178607ca46eSDavid Howells 
179af30cb44SChandra Seetharaman /*
180af30cb44SChandra Seetharaman  * fs_quota_statv is used by Q_XGETQSTATV for a given file system. It provides
181af30cb44SChandra Seetharaman  * a centralized way to get meta information about the quota subsystem. eg.
182af30cb44SChandra Seetharaman  * space taken up for user, group, and project quotas, number of dquots
183af30cb44SChandra Seetharaman  * currently incore.
184af30cb44SChandra Seetharaman  *
185af30cb44SChandra Seetharaman  * This version has proper versioning support with appropriate padding for
186af30cb44SChandra Seetharaman  * future expansions, and ability to expand for future without creating any
187af30cb44SChandra Seetharaman  * backward compatibility issues.
188af30cb44SChandra Seetharaman  *
189af30cb44SChandra Seetharaman  * Q_XGETQSTATV uses the passed in value of the requested version via
190af30cb44SChandra Seetharaman  * fs_quota_statv.qs_version to determine the return data layout of
191af30cb44SChandra Seetharaman  * fs_quota_statv.  The kernel will fill the data fields relevant to that
192af30cb44SChandra Seetharaman  * version.
193af30cb44SChandra Seetharaman  *
194af30cb44SChandra Seetharaman  * If kernel does not support user space caller specified version, EINVAL will
195af30cb44SChandra Seetharaman  * be returned. User space caller can then reduce the version number and retry
196af30cb44SChandra Seetharaman  * the same command.
197af30cb44SChandra Seetharaman  */
198af30cb44SChandra Seetharaman #define FS_QSTATV_VERSION1	1	/* fs_quota_statv.qs_version */
199af30cb44SChandra Seetharaman /*
200af30cb44SChandra Seetharaman  * Some basic information about 'quota files' for Q_XGETQSTATV command
201af30cb44SChandra Seetharaman  */
202af30cb44SChandra Seetharaman struct fs_qfilestatv {
203af30cb44SChandra Seetharaman 	__u64		qfs_ino;	/* inode number */
204af30cb44SChandra Seetharaman 	__u64		qfs_nblks;	/* number of BBs 512-byte-blks */
205af30cb44SChandra Seetharaman 	__u32		qfs_nextents;	/* number of extents */
206af30cb44SChandra Seetharaman 	__u32		qfs_pad;	/* pad for 8-byte alignment */
207af30cb44SChandra Seetharaman };
208af30cb44SChandra Seetharaman 
209af30cb44SChandra Seetharaman struct fs_quota_statv {
210af30cb44SChandra Seetharaman 	__s8			qs_version;	/* version for future changes */
211af30cb44SChandra Seetharaman 	__u8			qs_pad1;	/* pad for 16bit alignment */
212af30cb44SChandra Seetharaman 	__u16			qs_flags;	/* FS_QUOTA_.* flags */
213af30cb44SChandra Seetharaman 	__u32			qs_incoredqs;	/* number of dquots incore */
214af30cb44SChandra Seetharaman 	struct fs_qfilestatv	qs_uquota;	/* user quota information */
215af30cb44SChandra Seetharaman 	struct fs_qfilestatv	qs_gquota;	/* group quota information */
216af30cb44SChandra Seetharaman 	struct fs_qfilestatv	qs_pquota;	/* project quota information */
217af30cb44SChandra Seetharaman 	__s32			qs_btimelimit;  /* limit for blks timer */
218af30cb44SChandra Seetharaman 	__s32			qs_itimelimit;  /* limit for inodes timer */
219af30cb44SChandra Seetharaman 	__s32			qs_rtbtimelimit;/* limit for rt blks timer */
220af30cb44SChandra Seetharaman 	__u16			qs_bwarnlimit;	/* limit for num warnings */
221af30cb44SChandra Seetharaman 	__u16			qs_iwarnlimit;	/* limit for num warnings */
222*f998d7d5SDarrick J. Wong 	__u16			qs_rtbwarnlimit;/* limit for rt blks warnings */
223*f998d7d5SDarrick J. Wong 	__u16			qs_pad3;
224*f998d7d5SDarrick J. Wong 	__u32			qs_pad4;
225*f998d7d5SDarrick J. Wong 	__u64			qs_pad2[7];	/* for future proofing */
226af30cb44SChandra Seetharaman };
227af30cb44SChandra Seetharaman 
228607ca46eSDavid Howells #endif	/* _LINUX_DQBLK_XFS_H */
229