diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/ext3_fs.h | 33 | ||||
-rw-r--r-- | include/linux/ext3_fs_i.h | 2 | ||||
-rw-r--r-- | include/linux/jbd.h | 11 | ||||
-rw-r--r-- | include/linux/jbd2.h | 11 | ||||
-rw-r--r-- | include/linux/quota.h | 33 | ||||
-rw-r--r-- | include/linux/quotaops.h | 304 |
6 files changed, 126 insertions, 268 deletions
diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h index deac2566450e..cac84b006667 100644 --- a/include/linux/ext3_fs.h +++ b/include/linux/ext3_fs.h | |||
@@ -202,14 +202,6 @@ static inline __u32 ext3_mask_flags(umode_t mode, __u32 flags) | |||
202 | return flags & EXT3_OTHER_FLMASK; | 202 | return flags & EXT3_OTHER_FLMASK; |
203 | } | 203 | } |
204 | 204 | ||
205 | /* | ||
206 | * Inode dynamic state flags | ||
207 | */ | ||
208 | #define EXT3_STATE_JDATA 0x00000001 /* journaled data exists */ | ||
209 | #define EXT3_STATE_NEW 0x00000002 /* inode is newly created */ | ||
210 | #define EXT3_STATE_XATTR 0x00000004 /* has in-inode xattrs */ | ||
211 | #define EXT3_STATE_FLUSH_ON_CLOSE 0x00000008 | ||
212 | |||
213 | /* Used to pass group descriptor data when online resize is done */ | 205 | /* Used to pass group descriptor data when online resize is done */ |
214 | struct ext3_new_group_input { | 206 | struct ext3_new_group_input { |
215 | __u32 group; /* Group number for this data */ | 207 | __u32 group; /* Group number for this data */ |
@@ -560,6 +552,31 @@ static inline int ext3_valid_inum(struct super_block *sb, unsigned long ino) | |||
560 | (ino >= EXT3_FIRST_INO(sb) && | 552 | (ino >= EXT3_FIRST_INO(sb) && |
561 | ino <= le32_to_cpu(EXT3_SB(sb)->s_es->s_inodes_count)); | 553 | ino <= le32_to_cpu(EXT3_SB(sb)->s_es->s_inodes_count)); |
562 | } | 554 | } |
555 | |||
556 | /* | ||
557 | * Inode dynamic state flags | ||
558 | */ | ||
559 | enum { | ||
560 | EXT3_STATE_JDATA, /* journaled data exists */ | ||
561 | EXT3_STATE_NEW, /* inode is newly created */ | ||
562 | EXT3_STATE_XATTR, /* has in-inode xattrs */ | ||
563 | EXT3_STATE_FLUSH_ON_CLOSE, /* flush dirty pages on close */ | ||
564 | }; | ||
565 | |||
566 | static inline int ext3_test_inode_state(struct inode *inode, int bit) | ||
567 | { | ||
568 | return test_bit(bit, &EXT3_I(inode)->i_state); | ||
569 | } | ||
570 | |||
571 | static inline void ext3_set_inode_state(struct inode *inode, int bit) | ||
572 | { | ||
573 | set_bit(bit, &EXT3_I(inode)->i_state); | ||
574 | } | ||
575 | |||
576 | static inline void ext3_clear_inode_state(struct inode *inode, int bit) | ||
577 | { | ||
578 | clear_bit(bit, &EXT3_I(inode)->i_state); | ||
579 | } | ||
563 | #else | 580 | #else |
564 | /* Assume that user mode programs are passing in an ext3fs superblock, not | 581 | /* Assume that user mode programs are passing in an ext3fs superblock, not |
565 | * a kernel struct super_block. This will allow us to call the feature-test | 582 | * a kernel struct super_block. This will allow us to call the feature-test |
diff --git a/include/linux/ext3_fs_i.h b/include/linux/ext3_fs_i.h index 93e7428156ba..7679acdb519a 100644 --- a/include/linux/ext3_fs_i.h +++ b/include/linux/ext3_fs_i.h | |||
@@ -87,7 +87,7 @@ struct ext3_inode_info { | |||
87 | * near to their parent directory's inode. | 87 | * near to their parent directory's inode. |
88 | */ | 88 | */ |
89 | __u32 i_block_group; | 89 | __u32 i_block_group; |
90 | __u32 i_state; /* Dynamic state flags for ext3 */ | 90 | unsigned long i_state; /* Dynamic state flags for ext3 */ |
91 | 91 | ||
92 | /* block reservation info */ | 92 | /* block reservation info */ |
93 | struct ext3_block_alloc_info *i_block_alloc_info; | 93 | struct ext3_block_alloc_info *i_block_alloc_info; |
diff --git a/include/linux/jbd.h b/include/linux/jbd.h index 331530cd3cc6..f3aa59cb675d 100644 --- a/include/linux/jbd.h +++ b/include/linux/jbd.h | |||
@@ -246,19 +246,8 @@ typedef struct journal_superblock_s | |||
246 | 246 | ||
247 | #define J_ASSERT(assert) BUG_ON(!(assert)) | 247 | #define J_ASSERT(assert) BUG_ON(!(assert)) |
248 | 248 | ||
249 | #if defined(CONFIG_BUFFER_DEBUG) | ||
250 | void buffer_assertion_failure(struct buffer_head *bh); | ||
251 | #define J_ASSERT_BH(bh, expr) \ | ||
252 | do { \ | ||
253 | if (!(expr)) \ | ||
254 | buffer_assertion_failure(bh); \ | ||
255 | J_ASSERT(expr); \ | ||
256 | } while (0) | ||
257 | #define J_ASSERT_JH(jh, expr) J_ASSERT_BH(jh2bh(jh), expr) | ||
258 | #else | ||
259 | #define J_ASSERT_BH(bh, expr) J_ASSERT(expr) | 249 | #define J_ASSERT_BH(bh, expr) J_ASSERT(expr) |
260 | #define J_ASSERT_JH(jh, expr) J_ASSERT(expr) | 250 | #define J_ASSERT_JH(jh, expr) J_ASSERT(expr) |
261 | #endif | ||
262 | 251 | ||
263 | #if defined(JBD_PARANOID_IOFAIL) | 252 | #if defined(JBD_PARANOID_IOFAIL) |
264 | #define J_EXPECT(expr, why...) J_ASSERT(expr) | 253 | #define J_EXPECT(expr, why...) J_ASSERT(expr) |
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index 8ada2a129d08..1ec876358180 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h | |||
@@ -277,19 +277,8 @@ typedef struct journal_superblock_s | |||
277 | 277 | ||
278 | #define J_ASSERT(assert) BUG_ON(!(assert)) | 278 | #define J_ASSERT(assert) BUG_ON(!(assert)) |
279 | 279 | ||
280 | #if defined(CONFIG_BUFFER_DEBUG) | ||
281 | void buffer_assertion_failure(struct buffer_head *bh); | ||
282 | #define J_ASSERT_BH(bh, expr) \ | ||
283 | do { \ | ||
284 | if (!(expr)) \ | ||
285 | buffer_assertion_failure(bh); \ | ||
286 | J_ASSERT(expr); \ | ||
287 | } while (0) | ||
288 | #define J_ASSERT_JH(jh, expr) J_ASSERT_BH(jh2bh(jh), expr) | ||
289 | #else | ||
290 | #define J_ASSERT_BH(bh, expr) J_ASSERT(expr) | 280 | #define J_ASSERT_BH(bh, expr) J_ASSERT(expr) |
291 | #define J_ASSERT_JH(jh, expr) J_ASSERT(expr) | 281 | #define J_ASSERT_JH(jh, expr) J_ASSERT(expr) |
292 | #endif | ||
293 | 282 | ||
294 | #if defined(JBD2_PARANOID_IOFAIL) | 283 | #if defined(JBD2_PARANOID_IOFAIL) |
295 | #define J_EXPECT(expr, why...) J_ASSERT(expr) | 284 | #define J_EXPECT(expr, why...) J_ASSERT(expr) |
diff --git a/include/linux/quota.h b/include/linux/quota.h index a6861f117480..b462916b2a0a 100644 --- a/include/linux/quota.h +++ b/include/linux/quota.h | |||
@@ -279,9 +279,6 @@ struct dquot { | |||
279 | struct mem_dqblk dq_dqb; /* Diskquota usage */ | 279 | struct mem_dqblk dq_dqb; /* Diskquota usage */ |
280 | }; | 280 | }; |
281 | 281 | ||
282 | #define QUOTA_OK 0 | ||
283 | #define NO_QUOTA 1 | ||
284 | |||
285 | /* Operations which must be implemented by each quota format */ | 282 | /* Operations which must be implemented by each quota format */ |
286 | struct quota_format_ops { | 283 | struct quota_format_ops { |
287 | int (*check_quota_file)(struct super_block *sb, int type); /* Detect whether file is in our format */ | 284 | int (*check_quota_file)(struct super_block *sb, int type); /* Detect whether file is in our format */ |
@@ -295,13 +292,6 @@ struct quota_format_ops { | |||
295 | 292 | ||
296 | /* Operations working with dquots */ | 293 | /* Operations working with dquots */ |
297 | struct dquot_operations { | 294 | struct dquot_operations { |
298 | int (*initialize) (struct inode *, int); | ||
299 | int (*drop) (struct inode *); | ||
300 | int (*alloc_space) (struct inode *, qsize_t, int); | ||
301 | int (*alloc_inode) (const struct inode *, qsize_t); | ||
302 | int (*free_space) (struct inode *, qsize_t); | ||
303 | int (*free_inode) (const struct inode *, qsize_t); | ||
304 | int (*transfer) (struct inode *, struct iattr *); | ||
305 | int (*write_dquot) (struct dquot *); /* Ordinary dquot write */ | 295 | int (*write_dquot) (struct dquot *); /* Ordinary dquot write */ |
306 | struct dquot *(*alloc_dquot)(struct super_block *, int); /* Allocate memory for new dquot */ | 296 | struct dquot *(*alloc_dquot)(struct super_block *, int); /* Allocate memory for new dquot */ |
307 | void (*destroy_dquot)(struct dquot *); /* Free memory for dquot */ | 297 | void (*destroy_dquot)(struct dquot *); /* Free memory for dquot */ |
@@ -309,12 +299,6 @@ struct dquot_operations { | |||
309 | int (*release_dquot) (struct dquot *); /* Quota is going to be deleted from disk */ | 299 | int (*release_dquot) (struct dquot *); /* Quota is going to be deleted from disk */ |
310 | int (*mark_dirty) (struct dquot *); /* Dquot is marked dirty */ | 300 | int (*mark_dirty) (struct dquot *); /* Dquot is marked dirty */ |
311 | int (*write_info) (struct super_block *, int); /* Write of quota "superblock" */ | 301 | int (*write_info) (struct super_block *, int); /* Write of quota "superblock" */ |
312 | /* reserve quota for delayed block allocation */ | ||
313 | int (*reserve_space) (struct inode *, qsize_t, int); | ||
314 | /* claim reserved quota for delayed alloc */ | ||
315 | int (*claim_space) (struct inode *, qsize_t); | ||
316 | /* release rsved quota for delayed alloc */ | ||
317 | void (*release_rsv) (struct inode *, qsize_t); | ||
318 | /* get reserved quota for delayed alloc, value returned is managed by | 302 | /* get reserved quota for delayed alloc, value returned is managed by |
319 | * quota code only */ | 303 | * quota code only */ |
320 | qsize_t *(*get_reserved_space) (struct inode *); | 304 | qsize_t *(*get_reserved_space) (struct inode *); |
@@ -324,7 +308,7 @@ struct dquot_operations { | |||
324 | struct quotactl_ops { | 308 | struct quotactl_ops { |
325 | int (*quota_on)(struct super_block *, int, int, char *, int); | 309 | int (*quota_on)(struct super_block *, int, int, char *, int); |
326 | int (*quota_off)(struct super_block *, int, int); | 310 | int (*quota_off)(struct super_block *, int, int); |
327 | int (*quota_sync)(struct super_block *, int); | 311 | int (*quota_sync)(struct super_block *, int, int); |
328 | int (*get_info)(struct super_block *, int, struct if_dqinfo *); | 312 | int (*get_info)(struct super_block *, int, struct if_dqinfo *); |
329 | int (*set_info)(struct super_block *, int, struct if_dqinfo *); | 313 | int (*set_info)(struct super_block *, int, struct if_dqinfo *); |
330 | int (*get_dqblk)(struct super_block *, int, qid_t, struct if_dqblk *); | 314 | int (*get_dqblk)(struct super_block *, int, qid_t, struct if_dqblk *); |
@@ -357,26 +341,25 @@ enum { | |||
357 | #define DQUOT_STATE_FLAGS (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED | \ | 341 | #define DQUOT_STATE_FLAGS (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED | \ |
358 | DQUOT_SUSPENDED) | 342 | DQUOT_SUSPENDED) |
359 | /* Other quota flags */ | 343 | /* Other quota flags */ |
360 | #define DQUOT_QUOTA_SYS_FILE (1 << 6) /* Quota file is a special | 344 | #define DQUOT_STATE_LAST (_DQUOT_STATE_FLAGS * MAXQUOTAS) |
345 | #define DQUOT_QUOTA_SYS_FILE (1 << DQUOT_STATE_LAST) | ||
346 | /* Quota file is a special | ||
361 | * system file and user cannot | 347 | * system file and user cannot |
362 | * touch it. Filesystem is | 348 | * touch it. Filesystem is |
363 | * responsible for setting | 349 | * responsible for setting |
364 | * S_NOQUOTA, S_NOATIME flags | 350 | * S_NOQUOTA, S_NOATIME flags |
365 | */ | 351 | */ |
366 | #define DQUOT_NEGATIVE_USAGE (1 << 7) /* Allow negative quota usage */ | 352 | #define DQUOT_NEGATIVE_USAGE (1 << (DQUOT_STATE_LAST + 1)) |
353 | /* Allow negative quota usage */ | ||
367 | 354 | ||
368 | static inline unsigned int dquot_state_flag(unsigned int flags, int type) | 355 | static inline unsigned int dquot_state_flag(unsigned int flags, int type) |
369 | { | 356 | { |
370 | if (type == USRQUOTA) | 357 | return flags << _DQUOT_STATE_FLAGS * type; |
371 | return flags; | ||
372 | return flags << _DQUOT_STATE_FLAGS; | ||
373 | } | 358 | } |
374 | 359 | ||
375 | static inline unsigned int dquot_generic_flag(unsigned int flags, int type) | 360 | static inline unsigned int dquot_generic_flag(unsigned int flags, int type) |
376 | { | 361 | { |
377 | if (type == USRQUOTA) | 362 | return (flags >> _DQUOT_STATE_FLAGS * type) & DQUOT_STATE_FLAGS; |
378 | return flags; | ||
379 | return flags >> _DQUOT_STATE_FLAGS; | ||
380 | } | 363 | } |
381 | 364 | ||
382 | #ifdef CONFIG_QUOTA_NETLINK_INTERFACE | 365 | #ifdef CONFIG_QUOTA_NETLINK_INTERFACE |
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 3ebb23153640..e6fa7acce290 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h | |||
@@ -19,15 +19,12 @@ static inline struct quota_info *sb_dqopt(struct super_block *sb) | |||
19 | /* | 19 | /* |
20 | * declaration of quota_function calls in kernel. | 20 | * declaration of quota_function calls in kernel. |
21 | */ | 21 | */ |
22 | void sync_quota_sb(struct super_block *sb, int type); | 22 | void inode_add_rsv_space(struct inode *inode, qsize_t number); |
23 | static inline void writeout_quota_sb(struct super_block *sb, int type) | 23 | void inode_claim_rsv_space(struct inode *inode, qsize_t number); |
24 | { | 24 | void inode_sub_rsv_space(struct inode *inode, qsize_t number); |
25 | if (sb->s_qcop->quota_sync) | ||
26 | sb->s_qcop->quota_sync(sb, type); | ||
27 | } | ||
28 | 25 | ||
29 | int dquot_initialize(struct inode *inode, int type); | 26 | void dquot_initialize(struct inode *inode); |
30 | int dquot_drop(struct inode *inode); | 27 | void dquot_drop(struct inode *inode); |
31 | struct dquot *dqget(struct super_block *sb, unsigned int id, int type); | 28 | struct dquot *dqget(struct super_block *sb, unsigned int id, int type); |
32 | void dqput(struct dquot *dquot); | 29 | void dqput(struct dquot *dquot); |
33 | int dquot_scan_active(struct super_block *sb, | 30 | int dquot_scan_active(struct super_block *sb, |
@@ -36,24 +33,23 @@ int dquot_scan_active(struct super_block *sb, | |||
36 | struct dquot *dquot_alloc(struct super_block *sb, int type); | 33 | struct dquot *dquot_alloc(struct super_block *sb, int type); |
37 | void dquot_destroy(struct dquot *dquot); | 34 | void dquot_destroy(struct dquot *dquot); |
38 | 35 | ||
39 | int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc); | 36 | int __dquot_alloc_space(struct inode *inode, qsize_t number, |
40 | int dquot_alloc_inode(const struct inode *inode, qsize_t number); | 37 | int warn, int reserve); |
38 | void __dquot_free_space(struct inode *inode, qsize_t number, int reserve); | ||
41 | 39 | ||
42 | int dquot_reserve_space(struct inode *inode, qsize_t number, int prealloc); | 40 | int dquot_alloc_inode(const struct inode *inode); |
43 | int dquot_claim_space(struct inode *inode, qsize_t number); | ||
44 | void dquot_release_reserved_space(struct inode *inode, qsize_t number); | ||
45 | qsize_t dquot_get_reserved_space(struct inode *inode); | ||
46 | 41 | ||
47 | int dquot_free_space(struct inode *inode, qsize_t number); | 42 | int dquot_claim_space_nodirty(struct inode *inode, qsize_t number); |
48 | int dquot_free_inode(const struct inode *inode, qsize_t number); | 43 | void dquot_free_inode(const struct inode *inode); |
49 | 44 | ||
50 | int dquot_transfer(struct inode *inode, struct iattr *iattr); | ||
51 | int dquot_commit(struct dquot *dquot); | 45 | int dquot_commit(struct dquot *dquot); |
52 | int dquot_acquire(struct dquot *dquot); | 46 | int dquot_acquire(struct dquot *dquot); |
53 | int dquot_release(struct dquot *dquot); | 47 | int dquot_release(struct dquot *dquot); |
54 | int dquot_commit_info(struct super_block *sb, int type); | 48 | int dquot_commit_info(struct super_block *sb, int type); |
55 | int dquot_mark_dquot_dirty(struct dquot *dquot); | 49 | int dquot_mark_dquot_dirty(struct dquot *dquot); |
56 | 50 | ||
51 | int dquot_file_open(struct inode *inode, struct file *file); | ||
52 | |||
57 | int vfs_quota_on(struct super_block *sb, int type, int format_id, | 53 | int vfs_quota_on(struct super_block *sb, int type, int format_id, |
58 | char *path, int remount); | 54 | char *path, int remount); |
59 | int vfs_quota_enable(struct inode *inode, int type, int format_id, | 55 | int vfs_quota_enable(struct inode *inode, int type, int format_id, |
@@ -64,14 +60,13 @@ int vfs_quota_on_mount(struct super_block *sb, char *qf_name, | |||
64 | int format_id, int type); | 60 | int format_id, int type); |
65 | int vfs_quota_off(struct super_block *sb, int type, int remount); | 61 | int vfs_quota_off(struct super_block *sb, int type, int remount); |
66 | int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags); | 62 | int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags); |
67 | int vfs_quota_sync(struct super_block *sb, int type); | 63 | int vfs_quota_sync(struct super_block *sb, int type, int wait); |
68 | int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); | 64 | int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); |
69 | int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); | 65 | int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); |
70 | int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); | 66 | int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); |
71 | int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); | 67 | int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); |
72 | 68 | ||
73 | void vfs_dq_drop(struct inode *inode); | 69 | int dquot_transfer(struct inode *inode, struct iattr *iattr); |
74 | int vfs_dq_transfer(struct inode *inode, struct iattr *iattr); | ||
75 | int vfs_dq_quota_on_remount(struct super_block *sb); | 70 | int vfs_dq_quota_on_remount(struct super_block *sb); |
76 | 71 | ||
77 | static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) | 72 | static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) |
@@ -83,53 +78,56 @@ static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) | |||
83 | * Functions for checking status of quota | 78 | * Functions for checking status of quota |
84 | */ | 79 | */ |
85 | 80 | ||
86 | static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type) | 81 | static inline bool sb_has_quota_usage_enabled(struct super_block *sb, int type) |
87 | { | 82 | { |
88 | return sb_dqopt(sb)->flags & | 83 | return sb_dqopt(sb)->flags & |
89 | dquot_state_flag(DQUOT_USAGE_ENABLED, type); | 84 | dquot_state_flag(DQUOT_USAGE_ENABLED, type); |
90 | } | 85 | } |
91 | 86 | ||
92 | static inline int sb_has_quota_limits_enabled(struct super_block *sb, int type) | 87 | static inline bool sb_has_quota_limits_enabled(struct super_block *sb, int type) |
93 | { | 88 | { |
94 | return sb_dqopt(sb)->flags & | 89 | return sb_dqopt(sb)->flags & |
95 | dquot_state_flag(DQUOT_LIMITS_ENABLED, type); | 90 | dquot_state_flag(DQUOT_LIMITS_ENABLED, type); |
96 | } | 91 | } |
97 | 92 | ||
98 | static inline int sb_has_quota_suspended(struct super_block *sb, int type) | 93 | static inline bool sb_has_quota_suspended(struct super_block *sb, int type) |
99 | { | 94 | { |
100 | return sb_dqopt(sb)->flags & | 95 | return sb_dqopt(sb)->flags & |
101 | dquot_state_flag(DQUOT_SUSPENDED, type); | 96 | dquot_state_flag(DQUOT_SUSPENDED, type); |
102 | } | 97 | } |
103 | 98 | ||
104 | static inline int sb_any_quota_suspended(struct super_block *sb) | 99 | static inline unsigned sb_any_quota_suspended(struct super_block *sb) |
105 | { | 100 | { |
106 | return sb_has_quota_suspended(sb, USRQUOTA) || | 101 | unsigned type, tmsk = 0; |
107 | sb_has_quota_suspended(sb, GRPQUOTA); | 102 | for (type = 0; type < MAXQUOTAS; type++) |
103 | tmsk |= sb_has_quota_suspended(sb, type) << type; | ||
104 | return tmsk; | ||
108 | } | 105 | } |
109 | 106 | ||
110 | /* Does kernel know about any quota information for given sb + type? */ | 107 | /* Does kernel know about any quota information for given sb + type? */ |
111 | static inline int sb_has_quota_loaded(struct super_block *sb, int type) | 108 | static inline bool sb_has_quota_loaded(struct super_block *sb, int type) |
112 | { | 109 | { |
113 | /* Currently if anything is on, then quota usage is on as well */ | 110 | /* Currently if anything is on, then quota usage is on as well */ |
114 | return sb_has_quota_usage_enabled(sb, type); | 111 | return sb_has_quota_usage_enabled(sb, type); |
115 | } | 112 | } |
116 | 113 | ||
117 | static inline int sb_any_quota_loaded(struct super_block *sb) | 114 | static inline unsigned sb_any_quota_loaded(struct super_block *sb) |
118 | { | 115 | { |
119 | return sb_has_quota_loaded(sb, USRQUOTA) || | 116 | unsigned type, tmsk = 0; |
120 | sb_has_quota_loaded(sb, GRPQUOTA); | 117 | for (type = 0; type < MAXQUOTAS; type++) |
118 | tmsk |= sb_has_quota_loaded(sb, type) << type; | ||
119 | return tmsk; | ||
121 | } | 120 | } |
122 | 121 | ||
123 | static inline int sb_has_quota_active(struct super_block *sb, int type) | 122 | static inline bool sb_has_quota_active(struct super_block *sb, int type) |
124 | { | 123 | { |
125 | return sb_has_quota_loaded(sb, type) && | 124 | return sb_has_quota_loaded(sb, type) && |
126 | !sb_has_quota_suspended(sb, type); | 125 | !sb_has_quota_suspended(sb, type); |
127 | } | 126 | } |
128 | 127 | ||
129 | static inline int sb_any_quota_active(struct super_block *sb) | 128 | static inline unsigned sb_any_quota_active(struct super_block *sb) |
130 | { | 129 | { |
131 | return sb_has_quota_active(sb, USRQUOTA) || | 130 | return sb_any_quota_loaded(sb) & ~sb_any_quota_suspended(sb); |
132 | sb_has_quota_active(sb, GRPQUOTA); | ||
133 | } | 131 | } |
134 | 132 | ||
135 | /* | 133 | /* |
@@ -141,122 +139,6 @@ extern const struct quotactl_ops vfs_quotactl_ops; | |||
141 | #define sb_dquot_ops (&dquot_operations) | 139 | #define sb_dquot_ops (&dquot_operations) |
142 | #define sb_quotactl_ops (&vfs_quotactl_ops) | 140 | #define sb_quotactl_ops (&vfs_quotactl_ops) |
143 | 141 | ||
144 | /* It is better to call this function outside of any transaction as it might | ||
145 | * need a lot of space in journal for dquot structure allocation. */ | ||
146 | static inline void vfs_dq_init(struct inode *inode) | ||
147 | { | ||
148 | BUG_ON(!inode->i_sb); | ||
149 | if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode)) | ||
150 | inode->i_sb->dq_op->initialize(inode, -1); | ||
151 | } | ||
152 | |||
153 | /* The following allocation/freeing/transfer functions *must* be called inside | ||
154 | * a transaction (deadlocks possible otherwise) */ | ||
155 | static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr) | ||
156 | { | ||
157 | if (sb_any_quota_active(inode->i_sb)) { | ||
158 | /* Used space is updated in alloc_space() */ | ||
159 | if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA) | ||
160 | return 1; | ||
161 | } | ||
162 | else | ||
163 | inode_add_bytes(inode, nr); | ||
164 | return 0; | ||
165 | } | ||
166 | |||
167 | static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr) | ||
168 | { | ||
169 | int ret; | ||
170 | if (!(ret = vfs_dq_prealloc_space_nodirty(inode, nr))) | ||
171 | mark_inode_dirty(inode); | ||
172 | return ret; | ||
173 | } | ||
174 | |||
175 | static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr) | ||
176 | { | ||
177 | if (sb_any_quota_active(inode->i_sb)) { | ||
178 | /* Used space is updated in alloc_space() */ | ||
179 | if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA) | ||
180 | return 1; | ||
181 | } | ||
182 | else | ||
183 | inode_add_bytes(inode, nr); | ||
184 | return 0; | ||
185 | } | ||
186 | |||
187 | static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr) | ||
188 | { | ||
189 | int ret; | ||
190 | if (!(ret = vfs_dq_alloc_space_nodirty(inode, nr))) | ||
191 | mark_inode_dirty(inode); | ||
192 | return ret; | ||
193 | } | ||
194 | |||
195 | static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr) | ||
196 | { | ||
197 | if (sb_any_quota_active(inode->i_sb)) { | ||
198 | /* Used space is updated in alloc_space() */ | ||
199 | if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA) | ||
200 | return 1; | ||
201 | } | ||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | static inline int vfs_dq_alloc_inode(struct inode *inode) | ||
206 | { | ||
207 | if (sb_any_quota_active(inode->i_sb)) { | ||
208 | vfs_dq_init(inode); | ||
209 | if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) | ||
210 | return 1; | ||
211 | } | ||
212 | return 0; | ||
213 | } | ||
214 | |||
215 | /* | ||
216 | * Convert in-memory reserved quotas to real consumed quotas | ||
217 | */ | ||
218 | static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr) | ||
219 | { | ||
220 | if (sb_any_quota_active(inode->i_sb)) { | ||
221 | if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA) | ||
222 | return 1; | ||
223 | } else | ||
224 | inode_add_bytes(inode, nr); | ||
225 | |||
226 | mark_inode_dirty(inode); | ||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | /* | ||
231 | * Release reserved (in-memory) quotas | ||
232 | */ | ||
233 | static inline | ||
234 | void vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr) | ||
235 | { | ||
236 | if (sb_any_quota_active(inode->i_sb)) | ||
237 | inode->i_sb->dq_op->release_rsv(inode, nr); | ||
238 | } | ||
239 | |||
240 | static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) | ||
241 | { | ||
242 | if (sb_any_quota_active(inode->i_sb)) | ||
243 | inode->i_sb->dq_op->free_space(inode, nr); | ||
244 | else | ||
245 | inode_sub_bytes(inode, nr); | ||
246 | } | ||
247 | |||
248 | static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr) | ||
249 | { | ||
250 | vfs_dq_free_space_nodirty(inode, nr); | ||
251 | mark_inode_dirty(inode); | ||
252 | } | ||
253 | |||
254 | static inline void vfs_dq_free_inode(struct inode *inode) | ||
255 | { | ||
256 | if (sb_any_quota_active(inode->i_sb)) | ||
257 | inode->i_sb->dq_op->free_inode(inode, 1); | ||
258 | } | ||
259 | |||
260 | /* Cannot be called inside a transaction */ | 142 | /* Cannot be called inside a transaction */ |
261 | static inline int vfs_dq_off(struct super_block *sb, int remount) | 143 | static inline int vfs_dq_off(struct super_block *sb, int remount) |
262 | { | 144 | { |
@@ -316,28 +198,20 @@ static inline int sb_any_quota_active(struct super_block *sb) | |||
316 | #define sb_dquot_ops (NULL) | 198 | #define sb_dquot_ops (NULL) |
317 | #define sb_quotactl_ops (NULL) | 199 | #define sb_quotactl_ops (NULL) |
318 | 200 | ||
319 | static inline void vfs_dq_init(struct inode *inode) | 201 | static inline void dquot_initialize(struct inode *inode) |
320 | { | 202 | { |
321 | } | 203 | } |
322 | 204 | ||
323 | static inline void vfs_dq_drop(struct inode *inode) | 205 | static inline void dquot_drop(struct inode *inode) |
324 | { | 206 | { |
325 | } | 207 | } |
326 | 208 | ||
327 | static inline int vfs_dq_alloc_inode(struct inode *inode) | 209 | static inline int dquot_alloc_inode(const struct inode *inode) |
328 | { | 210 | { |
329 | return 0; | 211 | return 0; |
330 | } | 212 | } |
331 | 213 | ||
332 | static inline void vfs_dq_free_inode(struct inode *inode) | 214 | static inline void dquot_free_inode(const struct inode *inode) |
333 | { | ||
334 | } | ||
335 | |||
336 | static inline void sync_quota_sb(struct super_block *sb, int type) | ||
337 | { | ||
338 | } | ||
339 | |||
340 | static inline void writeout_quota_sb(struct super_block *sb, int type) | ||
341 | { | 215 | { |
342 | } | 216 | } |
343 | 217 | ||
@@ -351,110 +225,116 @@ static inline int vfs_dq_quota_on_remount(struct super_block *sb) | |||
351 | return 0; | 225 | return 0; |
352 | } | 226 | } |
353 | 227 | ||
354 | static inline int vfs_dq_transfer(struct inode *inode, struct iattr *iattr) | 228 | static inline int dquot_transfer(struct inode *inode, struct iattr *iattr) |
355 | { | 229 | { |
356 | return 0; | 230 | return 0; |
357 | } | 231 | } |
358 | 232 | ||
359 | static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr) | 233 | static inline int __dquot_alloc_space(struct inode *inode, qsize_t number, |
234 | int warn, int reserve) | ||
360 | { | 235 | { |
361 | inode_add_bytes(inode, nr); | 236 | if (!reserve) |
237 | inode_add_bytes(inode, number); | ||
362 | return 0; | 238 | return 0; |
363 | } | 239 | } |
364 | 240 | ||
365 | static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr) | 241 | static inline void __dquot_free_space(struct inode *inode, qsize_t number, |
242 | int reserve) | ||
366 | { | 243 | { |
367 | vfs_dq_prealloc_space_nodirty(inode, nr); | 244 | if (!reserve) |
368 | mark_inode_dirty(inode); | 245 | inode_sub_bytes(inode, number); |
369 | return 0; | ||
370 | } | 246 | } |
371 | 247 | ||
372 | static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr) | 248 | static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number) |
373 | { | 249 | { |
374 | inode_add_bytes(inode, nr); | 250 | inode_add_bytes(inode, number); |
375 | return 0; | 251 | return 0; |
376 | } | 252 | } |
377 | 253 | ||
378 | static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr) | 254 | #define dquot_file_open generic_file_open |
255 | |||
256 | #endif /* CONFIG_QUOTA */ | ||
257 | |||
258 | static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr) | ||
379 | { | 259 | { |
380 | vfs_dq_alloc_space_nodirty(inode, nr); | 260 | return __dquot_alloc_space(inode, nr, 1, 0); |
381 | mark_inode_dirty(inode); | ||
382 | return 0; | ||
383 | } | 261 | } |
384 | 262 | ||
385 | static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr) | 263 | static inline int dquot_alloc_space(struct inode *inode, qsize_t nr) |
386 | { | 264 | { |
387 | return 0; | 265 | int ret; |
266 | |||
267 | ret = dquot_alloc_space_nodirty(inode, nr); | ||
268 | if (!ret) | ||
269 | mark_inode_dirty(inode); | ||
270 | return ret; | ||
388 | } | 271 | } |
389 | 272 | ||
390 | static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr) | 273 | static inline int dquot_alloc_block_nodirty(struct inode *inode, qsize_t nr) |
391 | { | 274 | { |
392 | return vfs_dq_alloc_space(inode, nr); | 275 | return dquot_alloc_space_nodirty(inode, nr << inode->i_blkbits); |
393 | } | 276 | } |
394 | 277 | ||
395 | static inline | 278 | static inline int dquot_alloc_block(struct inode *inode, qsize_t nr) |
396 | int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr) | ||
397 | { | 279 | { |
398 | return 0; | 280 | return dquot_alloc_space(inode, nr << inode->i_blkbits); |
399 | } | 281 | } |
400 | 282 | ||
401 | static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) | 283 | static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr) |
402 | { | 284 | { |
403 | inode_sub_bytes(inode, nr); | 285 | return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0, 0); |
404 | } | 286 | } |
405 | 287 | ||
406 | static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr) | 288 | static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr) |
407 | { | 289 | { |
408 | vfs_dq_free_space_nodirty(inode, nr); | 290 | int ret; |
409 | mark_inode_dirty(inode); | ||
410 | } | ||
411 | |||
412 | #endif /* CONFIG_QUOTA */ | ||
413 | 291 | ||
414 | static inline int vfs_dq_prealloc_block_nodirty(struct inode *inode, qsize_t nr) | 292 | ret = dquot_prealloc_block_nodirty(inode, nr); |
415 | { | 293 | if (!ret) |
416 | return vfs_dq_prealloc_space_nodirty(inode, nr << inode->i_blkbits); | 294 | mark_inode_dirty(inode); |
295 | return ret; | ||
417 | } | 296 | } |
418 | 297 | ||
419 | static inline int vfs_dq_prealloc_block(struct inode *inode, qsize_t nr) | 298 | static inline int dquot_reserve_block(struct inode *inode, qsize_t nr) |
420 | { | 299 | { |
421 | return vfs_dq_prealloc_space(inode, nr << inode->i_blkbits); | 300 | return __dquot_alloc_space(inode, nr << inode->i_blkbits, 1, 1); |
422 | } | 301 | } |
423 | 302 | ||
424 | static inline int vfs_dq_alloc_block_nodirty(struct inode *inode, qsize_t nr) | 303 | static inline int dquot_claim_block(struct inode *inode, qsize_t nr) |
425 | { | 304 | { |
426 | return vfs_dq_alloc_space_nodirty(inode, nr << inode->i_blkbits); | 305 | int ret; |
427 | } | ||
428 | 306 | ||
429 | static inline int vfs_dq_alloc_block(struct inode *inode, qsize_t nr) | 307 | ret = dquot_claim_space_nodirty(inode, nr << inode->i_blkbits); |
430 | { | 308 | if (!ret) |
431 | return vfs_dq_alloc_space(inode, nr << inode->i_blkbits); | 309 | mark_inode_dirty(inode); |
310 | return ret; | ||
432 | } | 311 | } |
433 | 312 | ||
434 | static inline int vfs_dq_reserve_block(struct inode *inode, qsize_t nr) | 313 | static inline void dquot_free_space_nodirty(struct inode *inode, qsize_t nr) |
435 | { | 314 | { |
436 | return vfs_dq_reserve_space(inode, nr << inode->i_blkbits); | 315 | __dquot_free_space(inode, nr, 0); |
437 | } | 316 | } |
438 | 317 | ||
439 | static inline int vfs_dq_claim_block(struct inode *inode, qsize_t nr) | 318 | static inline void dquot_free_space(struct inode *inode, qsize_t nr) |
440 | { | 319 | { |
441 | return vfs_dq_claim_space(inode, nr << inode->i_blkbits); | 320 | dquot_free_space_nodirty(inode, nr); |
321 | mark_inode_dirty(inode); | ||
442 | } | 322 | } |
443 | 323 | ||
444 | static inline | 324 | static inline void dquot_free_block_nodirty(struct inode *inode, qsize_t nr) |
445 | void vfs_dq_release_reservation_block(struct inode *inode, qsize_t nr) | ||
446 | { | 325 | { |
447 | vfs_dq_release_reservation_space(inode, nr << inode->i_blkbits); | 326 | dquot_free_space_nodirty(inode, nr << inode->i_blkbits); |
448 | } | 327 | } |
449 | 328 | ||
450 | static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr) | 329 | static inline void dquot_free_block(struct inode *inode, qsize_t nr) |
451 | { | 330 | { |
452 | vfs_dq_free_space_nodirty(inode, nr << inode->i_blkbits); | 331 | dquot_free_space(inode, nr << inode->i_blkbits); |
453 | } | 332 | } |
454 | 333 | ||
455 | static inline void vfs_dq_free_block(struct inode *inode, qsize_t nr) | 334 | static inline void dquot_release_reservation_block(struct inode *inode, |
335 | qsize_t nr) | ||
456 | { | 336 | { |
457 | vfs_dq_free_space(inode, nr << inode->i_blkbits); | 337 | __dquot_free_space(inode, nr << inode->i_blkbits, 1); |
458 | } | 338 | } |
459 | 339 | ||
460 | #endif /* _LINUX_QUOTAOPS_ */ | 340 | #endif /* _LINUX_QUOTAOPS_ */ |