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