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