diff options
Diffstat (limited to 'include/linux/quotaops.h')
-rw-r--r-- | include/linux/quotaops.h | 114 |
1 files changed, 61 insertions, 53 deletions
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 370abb1e99cb..aa36793b48bd 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h | |||
@@ -9,6 +9,10 @@ | |||
9 | 9 | ||
10 | #include <linux/fs.h> | 10 | #include <linux/fs.h> |
11 | 11 | ||
12 | #define DQUOT_SPACE_WARN 0x1 | ||
13 | #define DQUOT_SPACE_RESERVE 0x2 | ||
14 | #define DQUOT_SPACE_NOFAIL 0x4 | ||
15 | |||
12 | static inline struct quota_info *sb_dqopt(struct super_block *sb) | 16 | static inline struct quota_info *sb_dqopt(struct super_block *sb) |
13 | { | 17 | { |
14 | return &sb->s_dquot; | 18 | return &sb->s_dquot; |
@@ -41,15 +45,22 @@ int dquot_scan_active(struct super_block *sb, | |||
41 | struct dquot *dquot_alloc(struct super_block *sb, int type); | 45 | struct dquot *dquot_alloc(struct super_block *sb, int type); |
42 | void dquot_destroy(struct dquot *dquot); | 46 | void dquot_destroy(struct dquot *dquot); |
43 | 47 | ||
44 | int __dquot_alloc_space(struct inode *inode, qsize_t number, | 48 | int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags); |
45 | int warn, int reserve); | 49 | void __dquot_free_space(struct inode *inode, qsize_t number, int flags); |
46 | void __dquot_free_space(struct inode *inode, qsize_t number, int reserve); | ||
47 | 50 | ||
48 | int dquot_alloc_inode(const struct inode *inode); | 51 | int dquot_alloc_inode(const struct inode *inode); |
49 | 52 | ||
50 | int dquot_claim_space_nodirty(struct inode *inode, qsize_t number); | 53 | int dquot_claim_space_nodirty(struct inode *inode, qsize_t number); |
51 | void dquot_free_inode(const struct inode *inode); | 54 | void dquot_free_inode(const struct inode *inode); |
52 | 55 | ||
56 | int dquot_disable(struct super_block *sb, int type, unsigned int flags); | ||
57 | /* Suspend quotas on remount RO */ | ||
58 | static inline int dquot_suspend(struct super_block *sb, int type) | ||
59 | { | ||
60 | return dquot_disable(sb, type, DQUOT_SUSPENDED); | ||
61 | } | ||
62 | int dquot_resume(struct super_block *sb, int type); | ||
63 | |||
53 | int dquot_commit(struct dquot *dquot); | 64 | int dquot_commit(struct dquot *dquot); |
54 | int dquot_acquire(struct dquot *dquot); | 65 | int dquot_acquire(struct dquot *dquot); |
55 | int dquot_release(struct dquot *dquot); | 66 | int dquot_release(struct dquot *dquot); |
@@ -58,27 +69,25 @@ int dquot_mark_dquot_dirty(struct dquot *dquot); | |||
58 | 69 | ||
59 | int dquot_file_open(struct inode *inode, struct file *file); | 70 | int dquot_file_open(struct inode *inode, struct file *file); |
60 | 71 | ||
61 | int vfs_quota_on(struct super_block *sb, int type, int format_id, | 72 | int dquot_quota_on(struct super_block *sb, int type, int format_id, |
62 | char *path, int remount); | 73 | char *path); |
63 | int vfs_quota_enable(struct inode *inode, int type, int format_id, | 74 | int dquot_enable(struct inode *inode, int type, int format_id, |
64 | unsigned int flags); | 75 | unsigned int flags); |
65 | int vfs_quota_on_path(struct super_block *sb, int type, int format_id, | 76 | int dquot_quota_on_path(struct super_block *sb, int type, int format_id, |
66 | struct path *path); | 77 | struct path *path); |
67 | int vfs_quota_on_mount(struct super_block *sb, char *qf_name, | 78 | int dquot_quota_on_mount(struct super_block *sb, char *qf_name, |
68 | int format_id, int type); | 79 | int format_id, int type); |
69 | int vfs_quota_off(struct super_block *sb, int type, int remount); | 80 | int dquot_quota_off(struct super_block *sb, int type); |
70 | int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags); | 81 | int dquot_quota_sync(struct super_block *sb, int type, int wait); |
71 | int vfs_quota_sync(struct super_block *sb, int type, int wait); | 82 | int dquot_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); |
72 | int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); | 83 | int dquot_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); |
73 | int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); | 84 | int dquot_get_dqblk(struct super_block *sb, int type, qid_t id, |
74 | int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, | ||
75 | struct fs_disk_quota *di); | 85 | struct fs_disk_quota *di); |
76 | int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, | 86 | int dquot_set_dqblk(struct super_block *sb, int type, qid_t id, |
77 | struct fs_disk_quota *di); | 87 | struct fs_disk_quota *di); |
78 | 88 | ||
79 | int __dquot_transfer(struct inode *inode, struct dquot **transfer_to); | 89 | int __dquot_transfer(struct inode *inode, struct dquot **transfer_to); |
80 | int dquot_transfer(struct inode *inode, struct iattr *iattr); | 90 | int dquot_transfer(struct inode *inode, struct iattr *iattr); |
81 | int vfs_dq_quota_on_remount(struct super_block *sb); | ||
82 | 91 | ||
83 | static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) | 92 | static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) |
84 | { | 93 | { |
@@ -145,20 +154,7 @@ static inline unsigned sb_any_quota_active(struct super_block *sb) | |||
145 | * Operations supported for diskquotas. | 154 | * Operations supported for diskquotas. |
146 | */ | 155 | */ |
147 | extern const struct dquot_operations dquot_operations; | 156 | extern const struct dquot_operations dquot_operations; |
148 | extern const struct quotactl_ops vfs_quotactl_ops; | 157 | extern const struct quotactl_ops dquot_quotactl_ops; |
149 | |||
150 | #define sb_dquot_ops (&dquot_operations) | ||
151 | #define sb_quotactl_ops (&vfs_quotactl_ops) | ||
152 | |||
153 | /* Cannot be called inside a transaction */ | ||
154 | static inline int vfs_dq_off(struct super_block *sb, int remount) | ||
155 | { | ||
156 | int ret = -ENOSYS; | ||
157 | |||
158 | if (sb->s_qcop && sb->s_qcop->quota_off) | ||
159 | ret = sb->s_qcop->quota_off(sb, -1, remount); | ||
160 | return ret; | ||
161 | } | ||
162 | 158 | ||
163 | #else | 159 | #else |
164 | 160 | ||
@@ -203,12 +199,6 @@ static inline int sb_any_quota_active(struct super_block *sb) | |||
203 | return 0; | 199 | return 0; |
204 | } | 200 | } |
205 | 201 | ||
206 | /* | ||
207 | * NO-OP when quota not configured. | ||
208 | */ | ||
209 | #define sb_dquot_ops (NULL) | ||
210 | #define sb_quotactl_ops (NULL) | ||
211 | |||
212 | static inline void dquot_initialize(struct inode *inode) | 202 | static inline void dquot_initialize(struct inode *inode) |
213 | { | 203 | { |
214 | } | 204 | } |
@@ -226,39 +216,45 @@ static inline void dquot_free_inode(const struct inode *inode) | |||
226 | { | 216 | { |
227 | } | 217 | } |
228 | 218 | ||
229 | static inline int vfs_dq_off(struct super_block *sb, int remount) | 219 | static inline int dquot_transfer(struct inode *inode, struct iattr *iattr) |
230 | { | 220 | { |
231 | return 0; | 221 | return 0; |
232 | } | 222 | } |
233 | 223 | ||
234 | static inline int vfs_dq_quota_on_remount(struct super_block *sb) | 224 | static inline int __dquot_alloc_space(struct inode *inode, qsize_t number, |
225 | int flags) | ||
235 | { | 226 | { |
227 | if (!(flags & DQUOT_SPACE_RESERVE)) | ||
228 | inode_add_bytes(inode, number); | ||
236 | return 0; | 229 | return 0; |
237 | } | 230 | } |
238 | 231 | ||
239 | static inline int dquot_transfer(struct inode *inode, struct iattr *iattr) | 232 | static inline void __dquot_free_space(struct inode *inode, qsize_t number, |
233 | int flags) | ||
234 | { | ||
235 | if (!(flags & DQUOT_SPACE_RESERVE)) | ||
236 | inode_sub_bytes(inode, number); | ||
237 | } | ||
238 | |||
239 | static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number) | ||
240 | { | 240 | { |
241 | inode_add_bytes(inode, number); | ||
241 | return 0; | 242 | return 0; |
242 | } | 243 | } |
243 | 244 | ||
244 | static inline int __dquot_alloc_space(struct inode *inode, qsize_t number, | 245 | static inline int dquot_disable(struct super_block *sb, int type, |
245 | int warn, int reserve) | 246 | unsigned int flags) |
246 | { | 247 | { |
247 | if (!reserve) | ||
248 | inode_add_bytes(inode, number); | ||
249 | return 0; | 248 | return 0; |
250 | } | 249 | } |
251 | 250 | ||
252 | static inline void __dquot_free_space(struct inode *inode, qsize_t number, | 251 | static inline int dquot_suspend(struct super_block *sb, int type) |
253 | int reserve) | ||
254 | { | 252 | { |
255 | if (!reserve) | 253 | return 0; |
256 | inode_sub_bytes(inode, number); | ||
257 | } | 254 | } |
258 | 255 | ||
259 | static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number) | 256 | static inline int dquot_resume(struct super_block *sb, int type) |
260 | { | 257 | { |
261 | inode_add_bytes(inode, number); | ||
262 | return 0; | 258 | return 0; |
263 | } | 259 | } |
264 | 260 | ||
@@ -268,7 +264,13 @@ static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number) | |||
268 | 264 | ||
269 | static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr) | 265 | static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr) |
270 | { | 266 | { |
271 | return __dquot_alloc_space(inode, nr, 1, 0); | 267 | return __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN); |
268 | } | ||
269 | |||
270 | static inline void dquot_alloc_space_nofail(struct inode *inode, qsize_t nr) | ||
271 | { | ||
272 | __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN|DQUOT_SPACE_NOFAIL); | ||
273 | mark_inode_dirty(inode); | ||
272 | } | 274 | } |
273 | 275 | ||
274 | static inline int dquot_alloc_space(struct inode *inode, qsize_t nr) | 276 | static inline int dquot_alloc_space(struct inode *inode, qsize_t nr) |
@@ -286,6 +288,11 @@ static inline int dquot_alloc_block_nodirty(struct inode *inode, qsize_t nr) | |||
286 | return dquot_alloc_space_nodirty(inode, nr << inode->i_blkbits); | 288 | return dquot_alloc_space_nodirty(inode, nr << inode->i_blkbits); |
287 | } | 289 | } |
288 | 290 | ||
291 | static inline void dquot_alloc_block_nofail(struct inode *inode, qsize_t nr) | ||
292 | { | ||
293 | dquot_alloc_space_nofail(inode, nr << inode->i_blkbits); | ||
294 | } | ||
295 | |||
289 | static inline int dquot_alloc_block(struct inode *inode, qsize_t nr) | 296 | static inline int dquot_alloc_block(struct inode *inode, qsize_t nr) |
290 | { | 297 | { |
291 | return dquot_alloc_space(inode, nr << inode->i_blkbits); | 298 | return dquot_alloc_space(inode, nr << inode->i_blkbits); |
@@ -293,7 +300,7 @@ static inline int dquot_alloc_block(struct inode *inode, qsize_t nr) | |||
293 | 300 | ||
294 | static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr) | 301 | static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr) |
295 | { | 302 | { |
296 | return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0, 0); | 303 | return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0); |
297 | } | 304 | } |
298 | 305 | ||
299 | static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr) | 306 | static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr) |
@@ -308,7 +315,8 @@ static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr) | |||
308 | 315 | ||
309 | static inline int dquot_reserve_block(struct inode *inode, qsize_t nr) | 316 | static inline int dquot_reserve_block(struct inode *inode, qsize_t nr) |
310 | { | 317 | { |
311 | return __dquot_alloc_space(inode, nr << inode->i_blkbits, 1, 1); | 318 | return __dquot_alloc_space(inode, nr << inode->i_blkbits, |
319 | DQUOT_SPACE_WARN|DQUOT_SPACE_RESERVE); | ||
312 | } | 320 | } |
313 | 321 | ||
314 | static inline int dquot_claim_block(struct inode *inode, qsize_t nr) | 322 | static inline int dquot_claim_block(struct inode *inode, qsize_t nr) |
@@ -345,7 +353,7 @@ static inline void dquot_free_block(struct inode *inode, qsize_t nr) | |||
345 | static inline void dquot_release_reservation_block(struct inode *inode, | 353 | static inline void dquot_release_reservation_block(struct inode *inode, |
346 | qsize_t nr) | 354 | qsize_t nr) |
347 | { | 355 | { |
348 | __dquot_free_space(inode, nr << inode->i_blkbits, 1); | 356 | __dquot_free_space(inode, nr << inode->i_blkbits, DQUOT_SPACE_RESERVE); |
349 | } | 357 | } |
350 | 358 | ||
351 | #endif /* _LINUX_QUOTAOPS_ */ | 359 | #endif /* _LINUX_QUOTAOPS_ */ |