Blame view
include/linux/quotaops.h
9.22 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 |
/* * Definitions for diskquota-operations. When diskquota is configured these * macros expand to the right source-code. * * Author: Marco van Wieringen <mvw@planets.elm.net> |
1da177e4c Linux-2.6.12-rc2 |
6 7 8 |
*/ #ifndef _LINUX_QUOTAOPS_ #define _LINUX_QUOTAOPS_ |
1da177e4c Linux-2.6.12-rc2 |
9 |
#include <linux/fs.h> |
56246f9ae quota: use flags ... |
10 11 |
#define DQUOT_SPACE_WARN 0x1 #define DQUOT_SPACE_RESERVE 0x2 |
0e05842bc quota: add the op... |
12 |
#define DQUOT_SPACE_NOFAIL 0x4 |
56246f9ae quota: use flags ... |
13 |
|
03b063436 quota: convert ma... |
14 15 16 17 |
static inline struct quota_info *sb_dqopt(struct super_block *sb) { return &sb->s_dquot; } |
74abb9890 quota: move funct... |
18 |
|
12755627b quota: unify quot... |
19 20 21 22 23 24 25 |
/* i_mutex must being held */ static inline bool is_quota_modification(struct inode *inode, struct iattr *ia) { return (ia->ia_valid & ATTR_SIZE && ia->ia_size != inode->i_size) || (ia->ia_valid & ATTR_UID && ia->ia_uid != inode->i_uid) || (ia->ia_valid & ATTR_GID && ia->ia_gid != inode->i_gid); } |
1da177e4c Linux-2.6.12-rc2 |
26 |
#if defined(CONFIG_QUOTA) |
fb5ffb0e1 quota: Change quo... |
27 28 |
#define quota_error(sb, fmt, args...) \ __quota_error((sb), __func__, fmt , ## args) |
b9075fa96 treewide: use __p... |
29 |
extern __printf(3, 4) |
055adcbd7 quota: Use %pV an... |
30 31 |
void __quota_error(struct super_block *sb, const char *func, const char *fmt, ...); |
fb5ffb0e1 quota: Change quo... |
32 |
|
1da177e4c Linux-2.6.12-rc2 |
33 34 35 |
/* * declaration of quota_function calls in kernel. */ |
c469070ae quota: manage res... |
36 37 38 |
void inode_add_rsv_space(struct inode *inode, qsize_t number); void inode_claim_rsv_space(struct inode *inode, qsize_t number); void inode_sub_rsv_space(struct inode *inode, qsize_t number); |
871a29315 dquot: cleanup dq... |
39 |
void dquot_initialize(struct inode *inode); |
9f7547580 dquot: cleanup dq... |
40 |
void dquot_drop(struct inode *inode); |
3d9ea253a quota: Add helper... |
41 42 |
struct dquot *dqget(struct super_block *sb, unsigned int id, int type); void dqput(struct dquot *dquot); |
12c77527e quota: Implement ... |
43 44 45 |
int dquot_scan_active(struct super_block *sb, int (*fn)(struct dquot *dquot, unsigned long priv), unsigned long priv); |
7d9056ba2 quota: Export dqu... |
46 47 |
struct dquot *dquot_alloc(struct super_block *sb, int type); void dquot_destroy(struct dquot *dquot); |
b85f4b87a quota: rename quo... |
48 |
|
56246f9ae quota: use flags ... |
49 50 |
int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags); void __dquot_free_space(struct inode *inode, qsize_t number, int flags); |
b85f4b87a quota: rename quo... |
51 |
|
63936ddaa dquot: cleanup in... |
52 |
int dquot_alloc_inode(const struct inode *inode); |
740d9dcd9 quota: Add quota ... |
53 |
|
5dd4056db dquot: cleanup sp... |
54 |
int dquot_claim_space_nodirty(struct inode *inode, qsize_t number); |
63936ddaa dquot: cleanup in... |
55 |
void dquot_free_inode(const struct inode *inode); |
b85f4b87a quota: rename quo... |
56 |
|
0f0dd62fd quota: kill the v... |
57 58 59 60 61 62 63 |
int dquot_disable(struct super_block *sb, int type, unsigned int flags); /* Suspend quotas on remount RO */ static inline int dquot_suspend(struct super_block *sb, int type) { return dquot_disable(sb, type, DQUOT_SUSPENDED); } int dquot_resume(struct super_block *sb, int type); |
b85f4b87a quota: rename quo... |
64 65 66 67 68 |
int dquot_commit(struct dquot *dquot); int dquot_acquire(struct dquot *dquot); int dquot_release(struct dquot *dquot); int dquot_commit_info(struct super_block *sb, int type); int dquot_mark_dquot_dirty(struct dquot *dquot); |
907f4554e dquot: move dquot... |
69 |
int dquot_file_open(struct inode *inode, struct file *file); |
287a80958 quota: rename def... |
70 |
int dquot_enable(struct inode *inode, int type, int format_id, |
f55abc0fb quota: Allow to s... |
71 |
unsigned int flags); |
f00c9e44a quota: Fix deadlo... |
72 |
int dquot_quota_on(struct super_block *sb, int type, int format_id, |
77e69dac3 [PATCH] fix races... |
73 |
struct path *path); |
287a80958 quota: rename def... |
74 |
int dquot_quota_on_mount(struct super_block *sb, char *qf_name, |
b85f4b87a quota: rename quo... |
75 |
int format_id, int type); |
287a80958 quota: rename def... |
76 77 78 79 80 |
int dquot_quota_off(struct super_block *sb, int type); int dquot_quota_sync(struct super_block *sb, int type, int wait); int dquot_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); int dquot_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); int dquot_get_dqblk(struct super_block *sb, int type, qid_t id, |
b9b2dd36c quota: unify ->ge... |
81 |
struct fs_disk_quota *di); |
287a80958 quota: rename def... |
82 |
int dquot_set_dqblk(struct super_block *sb, int type, qid_t id, |
c472b4327 quota: unify ->se... |
83 |
struct fs_disk_quota *di); |
b85f4b87a quota: rename quo... |
84 |
|
bc8e5f073 quota: Refactor d... |
85 |
int __dquot_transfer(struct inode *inode, struct dquot **transfer_to); |
b43fa8284 dquot: cleanup dq... |
86 |
int dquot_transfer(struct inode *inode, struct iattr *iattr); |
1da177e4c Linux-2.6.12-rc2 |
87 |
|
03b063436 quota: convert ma... |
88 89 90 91 |
static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) { return sb_dqopt(sb)->info + type; } |
74abb9890 quota: move funct... |
92 93 94 95 |
/* * Functions for checking status of quota */ |
ad1e6e8da quota: sb_quota s... |
96 |
static inline bool sb_has_quota_usage_enabled(struct super_block *sb, int type) |
03b063436 quota: convert ma... |
97 |
{ |
f55abc0fb quota: Allow to s... |
98 99 |
return sb_dqopt(sb)->flags & dquot_state_flag(DQUOT_USAGE_ENABLED, type); |
03b063436 quota: convert ma... |
100 |
} |
74abb9890 quota: move funct... |
101 |
|
ad1e6e8da quota: sb_quota s... |
102 |
static inline bool sb_has_quota_limits_enabled(struct super_block *sb, int type) |
03b063436 quota: convert ma... |
103 |
{ |
f55abc0fb quota: Allow to s... |
104 105 |
return sb_dqopt(sb)->flags & dquot_state_flag(DQUOT_LIMITS_ENABLED, type); |
03b063436 quota: convert ma... |
106 |
} |
74abb9890 quota: move funct... |
107 |
|
ad1e6e8da quota: sb_quota s... |
108 |
static inline bool sb_has_quota_suspended(struct super_block *sb, int type) |
03b063436 quota: convert ma... |
109 |
{ |
f55abc0fb quota: Allow to s... |
110 111 |
return sb_dqopt(sb)->flags & dquot_state_flag(DQUOT_SUSPENDED, type); |
03b063436 quota: convert ma... |
112 |
} |
74abb9890 quota: move funct... |
113 |
|
ad1e6e8da quota: sb_quota s... |
114 |
static inline unsigned sb_any_quota_suspended(struct super_block *sb) |
03b063436 quota: convert ma... |
115 |
{ |
ad1e6e8da quota: sb_quota s... |
116 117 118 119 |
unsigned type, tmsk = 0; for (type = 0; type < MAXQUOTAS; type++) tmsk |= sb_has_quota_suspended(sb, type) << type; return tmsk; |
03b063436 quota: convert ma... |
120 |
} |
74abb9890 quota: move funct... |
121 |
|
f55abc0fb quota: Allow to s... |
122 |
/* Does kernel know about any quota information for given sb + type? */ |
ad1e6e8da quota: sb_quota s... |
123 |
static inline bool sb_has_quota_loaded(struct super_block *sb, int type) |
f55abc0fb quota: Allow to s... |
124 125 126 127 |
{ /* Currently if anything is on, then quota usage is on as well */ return sb_has_quota_usage_enabled(sb, type); } |
ad1e6e8da quota: sb_quota s... |
128 |
static inline unsigned sb_any_quota_loaded(struct super_block *sb) |
f55abc0fb quota: Allow to s... |
129 |
{ |
ad1e6e8da quota: sb_quota s... |
130 131 132 133 |
unsigned type, tmsk = 0; for (type = 0; type < MAXQUOTAS; type++) tmsk |= sb_has_quota_loaded(sb, type) << type; return tmsk; |
f55abc0fb quota: Allow to s... |
134 |
} |
ad1e6e8da quota: sb_quota s... |
135 |
static inline bool sb_has_quota_active(struct super_block *sb, int type) |
f55abc0fb quota: Allow to s... |
136 137 138 139 |
{ return sb_has_quota_loaded(sb, type) && !sb_has_quota_suspended(sb, type); } |
1da177e4c Linux-2.6.12-rc2 |
140 141 142 |
/* * Operations supported for diskquotas. */ |
61e225dc3 const: make struc... |
143 |
extern const struct dquot_operations dquot_operations; |
287a80958 quota: rename def... |
144 |
extern const struct quotactl_ops dquot_quotactl_ops; |
0ff5af834 quota: quota core... |
145 |
|
1da177e4c Linux-2.6.12-rc2 |
146 |
#else |
f55abc0fb quota: Allow to s... |
147 |
static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type) |
03b063436 quota: convert ma... |
148 149 150 |
{ return 0; } |
f55abc0fb quota: Allow to s... |
151 |
static inline int sb_has_quota_limits_enabled(struct super_block *sb, int type) |
03b063436 quota: convert ma... |
152 153 154 155 156 157 158 159 160 161 162 163 164 |
{ return 0; } static inline int sb_has_quota_suspended(struct super_block *sb, int type) { return 0; } static inline int sb_any_quota_suspended(struct super_block *sb) { return 0; } |
74abb9890 quota: move funct... |
165 |
|
f55abc0fb quota: Allow to s... |
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
/* Does kernel know about any quota information for given sb + type? */ static inline int sb_has_quota_loaded(struct super_block *sb, int type) { return 0; } static inline int sb_any_quota_loaded(struct super_block *sb) { return 0; } static inline int sb_has_quota_active(struct super_block *sb, int type) { return 0; } |
871a29315 dquot: cleanup dq... |
181 |
static inline void dquot_initialize(struct inode *inode) |
50f8c370e quota: convert st... |
182 183 |
{ } |
9f7547580 dquot: cleanup dq... |
184 |
static inline void dquot_drop(struct inode *inode) |
50f8c370e quota: convert st... |
185 186 |
{ } |
63936ddaa dquot: cleanup in... |
187 |
static inline int dquot_alloc_inode(const struct inode *inode) |
50f8c370e quota: convert st... |
188 189 190 |
{ return 0; } |
63936ddaa dquot: cleanup in... |
191 |
static inline void dquot_free_inode(const struct inode *inode) |
50f8c370e quota: convert st... |
192 193 |
{ } |
b43fa8284 dquot: cleanup dq... |
194 |
static inline int dquot_transfer(struct inode *inode, struct iattr *iattr) |
50f8c370e quota: convert st... |
195 196 197 |
{ return 0; } |
5dd4056db dquot: cleanup sp... |
198 |
static inline int __dquot_alloc_space(struct inode *inode, qsize_t number, |
56246f9ae quota: use flags ... |
199 |
int flags) |
1da177e4c Linux-2.6.12-rc2 |
200 |
{ |
56246f9ae quota: use flags ... |
201 |
if (!(flags & DQUOT_SPACE_RESERVE)) |
5dd4056db dquot: cleanup sp... |
202 |
inode_add_bytes(inode, number); |
1da177e4c Linux-2.6.12-rc2 |
203 204 |
return 0; } |
5dd4056db dquot: cleanup sp... |
205 |
static inline void __dquot_free_space(struct inode *inode, qsize_t number, |
56246f9ae quota: use flags ... |
206 |
int flags) |
1da177e4c Linux-2.6.12-rc2 |
207 |
{ |
56246f9ae quota: use flags ... |
208 |
if (!(flags & DQUOT_SPACE_RESERVE)) |
5dd4056db dquot: cleanup sp... |
209 |
inode_sub_bytes(inode, number); |
1da177e4c Linux-2.6.12-rc2 |
210 |
} |
5dd4056db dquot: cleanup sp... |
211 |
static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number) |
1da177e4c Linux-2.6.12-rc2 |
212 |
{ |
5dd4056db dquot: cleanup sp... |
213 |
inode_add_bytes(inode, number); |
1da177e4c Linux-2.6.12-rc2 |
214 215 |
return 0; } |
0f0dd62fd quota: kill the v... |
216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
static inline int dquot_disable(struct super_block *sb, int type, unsigned int flags) { return 0; } static inline int dquot_suspend(struct super_block *sb, int type) { return 0; } static inline int dquot_resume(struct super_block *sb, int type) { return 0; |
1da177e4c Linux-2.6.12-rc2 |
230 |
} |
871a29315 dquot: cleanup dq... |
231 |
#define dquot_file_open generic_file_open |
5dd4056db dquot: cleanup sp... |
232 233 234 |
#endif /* CONFIG_QUOTA */ static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr) |
1da177e4c Linux-2.6.12-rc2 |
235 |
{ |
56246f9ae quota: use flags ... |
236 |
return __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN); |
1da177e4c Linux-2.6.12-rc2 |
237 |
} |
0e05842bc quota: add the op... |
238 239 240 |
static inline void dquot_alloc_space_nofail(struct inode *inode, qsize_t nr) { __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN|DQUOT_SPACE_NOFAIL); |
43d2932d8 quota: Use mark_i... |
241 |
mark_inode_dirty_sync(inode); |
1da177e4c Linux-2.6.12-rc2 |
242 |
} |
5dd4056db dquot: cleanup sp... |
243 |
static inline int dquot_alloc_space(struct inode *inode, qsize_t nr) |
f18df2289 quota: Add quota ... |
244 |
{ |
5dd4056db dquot: cleanup sp... |
245 246 247 |
int ret; ret = dquot_alloc_space_nodirty(inode, nr); |
d530148ae dquot: do full in... |
248 249 250 251 |
if (!ret) { /* * Mark inode fully dirty. Since we are allocating blocks, inode * would become fully dirty soon anyway and it reportedly |
250df6ed2 fs: protect inode... |
252 |
* reduces lock contention. |
d530148ae dquot: do full in... |
253 254 255 |
*/ mark_inode_dirty(inode); } |
5dd4056db dquot: cleanup sp... |
256 |
return ret; |
f18df2289 quota: Add quota ... |
257 |
} |
5dd4056db dquot: cleanup sp... |
258 |
static inline int dquot_alloc_block_nodirty(struct inode *inode, qsize_t nr) |
740d9dcd9 quota: Add quota ... |
259 |
{ |
5dd4056db dquot: cleanup sp... |
260 |
return dquot_alloc_space_nodirty(inode, nr << inode->i_blkbits); |
740d9dcd9 quota: Add quota ... |
261 |
} |
0e05842bc quota: add the op... |
262 263 264 265 |
static inline void dquot_alloc_block_nofail(struct inode *inode, qsize_t nr) { dquot_alloc_space_nofail(inode, nr << inode->i_blkbits); } |
5dd4056db dquot: cleanup sp... |
266 |
static inline int dquot_alloc_block(struct inode *inode, qsize_t nr) |
740d9dcd9 quota: Add quota ... |
267 |
{ |
5dd4056db dquot: cleanup sp... |
268 |
return dquot_alloc_space(inode, nr << inode->i_blkbits); |
740d9dcd9 quota: Add quota ... |
269 |
} |
5dd4056db dquot: cleanup sp... |
270 |
static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr) |
1da177e4c Linux-2.6.12-rc2 |
271 |
{ |
56246f9ae quota: use flags ... |
272 |
return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0); |
1da177e4c Linux-2.6.12-rc2 |
273 |
} |
5dd4056db dquot: cleanup sp... |
274 |
static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr) |
1da177e4c Linux-2.6.12-rc2 |
275 |
{ |
5dd4056db dquot: cleanup sp... |
276 |
int ret; |
1da177e4c Linux-2.6.12-rc2 |
277 |
|
5dd4056db dquot: cleanup sp... |
278 279 |
ret = dquot_prealloc_block_nodirty(inode, nr); if (!ret) |
43d2932d8 quota: Use mark_i... |
280 |
mark_inode_dirty_sync(inode); |
5dd4056db dquot: cleanup sp... |
281 |
return ret; |
03f6e92bd quota: various st... |
282 |
} |
5dd4056db dquot: cleanup sp... |
283 |
static inline int dquot_reserve_block(struct inode *inode, qsize_t nr) |
03f6e92bd quota: various st... |
284 |
{ |
56246f9ae quota: use flags ... |
285 286 |
return __dquot_alloc_space(inode, nr << inode->i_blkbits, DQUOT_SPACE_WARN|DQUOT_SPACE_RESERVE); |
03f6e92bd quota: various st... |
287 |
} |
5dd4056db dquot: cleanup sp... |
288 |
static inline int dquot_claim_block(struct inode *inode, qsize_t nr) |
03f6e92bd quota: various st... |
289 |
{ |
5dd4056db dquot: cleanup sp... |
290 |
int ret; |
03f6e92bd quota: various st... |
291 |
|
5dd4056db dquot: cleanup sp... |
292 293 |
ret = dquot_claim_space_nodirty(inode, nr << inode->i_blkbits); if (!ret) |
43d2932d8 quota: Use mark_i... |
294 |
mark_inode_dirty_sync(inode); |
5dd4056db dquot: cleanup sp... |
295 |
return ret; |
03f6e92bd quota: various st... |
296 |
} |
5dd4056db dquot: cleanup sp... |
297 |
static inline void dquot_free_space_nodirty(struct inode *inode, qsize_t nr) |
f18df2289 quota: Add quota ... |
298 |
{ |
5dd4056db dquot: cleanup sp... |
299 |
__dquot_free_space(inode, nr, 0); |
f18df2289 quota: Add quota ... |
300 |
} |
5dd4056db dquot: cleanup sp... |
301 |
static inline void dquot_free_space(struct inode *inode, qsize_t nr) |
740d9dcd9 quota: Add quota ... |
302 |
{ |
5dd4056db dquot: cleanup sp... |
303 |
dquot_free_space_nodirty(inode, nr); |
43d2932d8 quota: Use mark_i... |
304 |
mark_inode_dirty_sync(inode); |
740d9dcd9 quota: Add quota ... |
305 |
} |
5dd4056db dquot: cleanup sp... |
306 |
static inline void dquot_free_block_nodirty(struct inode *inode, qsize_t nr) |
740d9dcd9 quota: Add quota ... |
307 |
{ |
5dd4056db dquot: cleanup sp... |
308 |
dquot_free_space_nodirty(inode, nr << inode->i_blkbits); |
740d9dcd9 quota: Add quota ... |
309 |
} |
5dd4056db dquot: cleanup sp... |
310 |
static inline void dquot_free_block(struct inode *inode, qsize_t nr) |
03f6e92bd quota: various st... |
311 |
{ |
5dd4056db dquot: cleanup sp... |
312 |
dquot_free_space(inode, nr << inode->i_blkbits); |
03f6e92bd quota: various st... |
313 |
} |
5dd4056db dquot: cleanup sp... |
314 315 |
static inline void dquot_release_reservation_block(struct inode *inode, qsize_t nr) |
03f6e92bd quota: various st... |
316 |
{ |
56246f9ae quota: use flags ... |
317 |
__dquot_free_space(inode, nr << inode->i_blkbits, DQUOT_SPACE_RESERVE); |
03f6e92bd quota: various st... |
318 |
} |
1da177e4c Linux-2.6.12-rc2 |
319 320 |
#endif /* _LINUX_QUOTAOPS_ */ |