Commit 9f7547580263d4a55efe06ce5cfd567f568be6e8

Authored by Christoph Hellwig
Committed by Jan Kara
1 parent 257ba15ced

dquot: cleanup dquot drop routine

Get rid of the drop dquot operation - it is now always called from
the filesystem and if a filesystem really needs it's own (which none
currently does) it can just call into it's own routine directly.

Rename the now static low-level dquot_drop helper to __dquot_drop
and vfs_dq_drop to dquot_drop to have a consistent namespace.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>

Showing 22 changed files with 49 additions and 59 deletions Side-by-side Diff

Documentation/filesystems/Locking
... ... @@ -461,7 +461,6 @@
461 461 --------------------------- dquot_operations -------------------------------
462 462 prototypes:
463 463 int (*initialize) (struct inode *, int);
464   - int (*drop) (struct inode *);
465 464 int (*write_dquot) (struct dquot *);
466 465 int (*acquire_dquot) (struct dquot *);
467 466 int (*release_dquot) (struct dquot *);
... ... @@ -475,7 +474,6 @@
475 474  
476 475 FS recursion Held locks when called
477 476 initialize: yes maybe dqonoff_sem
478   -drop: yes -
479 477 write_dquot: yes dqonoff_sem or dqptr_sem
480 478 acquire_dquot: yes dqonoff_sem or dqptr_sem
481 479 release_dquot: yes dqonoff_sem or dqptr_sem
... ... @@ -122,7 +122,7 @@
122 122 /* Quota is already initialized in iput() */
123 123 ext2_xattr_delete_inode(inode);
124 124 dquot_free_inode(inode);
125   - vfs_dq_drop(inode);
  125 + dquot_drop(inode);
126 126 }
127 127  
128 128 es = EXT2_SB(sb)->s_es;
... ... @@ -608,7 +608,7 @@
608 608 dquot_free_inode(inode);
609 609  
610 610 fail_drop:
611   - vfs_dq_drop(inode);
  611 + dquot_drop(inode);
612 612 inode->i_flags |= S_NOQUOTA;
613 613 inode->i_nlink = 0;
614 614 unlock_new_inode(inode);
... ... @@ -195,7 +195,7 @@
195 195 {
196 196 struct ext2_block_alloc_info *rsv = EXT2_I(inode)->i_block_alloc_info;
197 197  
198   - vfs_dq_drop(inode);
  198 + dquot_drop(inode);
199 199 ext2_discard_reservation(inode);
200 200 EXT2_I(inode)->i_block_alloc_info = NULL;
201 201 if (unlikely(rsv))
... ... @@ -126,7 +126,7 @@
126 126 vfs_dq_init(inode);
127 127 ext3_xattr_delete_inode(handle, inode);
128 128 dquot_free_inode(inode);
129   - vfs_dq_drop(inode);
  129 + dquot_drop(inode);
130 130  
131 131 is_directory = S_ISDIR(inode->i_mode);
132 132  
... ... @@ -622,7 +622,7 @@
622 622 dquot_free_inode(inode);
623 623  
624 624 fail_drop:
625   - vfs_dq_drop(inode);
  625 + dquot_drop(inode);
626 626 inode->i_flags |= S_NOQUOTA;
627 627 inode->i_nlink = 0;
628 628 unlock_new_inode(inode);
... ... @@ -529,7 +529,7 @@
529 529 {
530 530 struct ext3_block_alloc_info *rsv = EXT3_I(inode)->i_block_alloc_info;
531 531  
532   - vfs_dq_drop(inode);
  532 + dquot_drop(inode);
533 533 ext3_discard_reservation(inode);
534 534 EXT3_I(inode)->i_block_alloc_info = NULL;
535 535 if (unlikely(rsv))
... ... @@ -753,7 +753,6 @@
753 753  
754 754 static const struct dquot_operations ext3_quota_operations = {
755 755 .initialize = dquot_initialize,
756   - .drop = dquot_drop,
757 756 .write_dquot = ext3_write_dquot,
758 757 .acquire_dquot = ext3_acquire_dquot,
759 758 .release_dquot = ext3_release_dquot,
... ... @@ -220,7 +220,7 @@
220 220 vfs_dq_init(inode);
221 221 ext4_xattr_delete_inode(handle, inode);
222 222 dquot_free_inode(inode);
223   - vfs_dq_drop(inode);
  223 + dquot_drop(inode);
224 224  
225 225 is_directory = S_ISDIR(inode->i_mode);
226 226  
... ... @@ -1077,7 +1077,7 @@
1077 1077 dquot_free_inode(inode);
1078 1078  
1079 1079 fail_drop:
1080   - vfs_dq_drop(inode);
  1080 + dquot_drop(inode);
1081 1081 inode->i_flags |= S_NOQUOTA;
1082 1082 inode->i_nlink = 0;
1083 1083 unlock_new_inode(inode);
... ... @@ -761,7 +761,7 @@
761 761  
762 762 static void ext4_clear_inode(struct inode *inode)
763 763 {
764   - vfs_dq_drop(inode);
  764 + dquot_drop(inode);
765 765 ext4_discard_preallocations(inode);
766 766 if (EXT4_JOURNAL(inode))
767 767 jbd2_journal_release_jbd_inode(EXT4_SB(inode->i_sb)->s_journal,
... ... @@ -1014,7 +1014,6 @@
1014 1014  
1015 1015 static const struct dquot_operations ext4_quota_operations = {
1016 1016 .initialize = dquot_initialize,
1017   - .drop = dquot_drop,
1018 1017 #ifdef CONFIG_QUOTA
1019 1018 .get_reserved_space = ext4_get_reserved_space,
1020 1019 #endif
... ... @@ -160,7 +160,7 @@
160 160 */
161 161 vfs_dq_init(inode);
162 162 dquot_free_inode(inode);
163   - vfs_dq_drop(inode);
  163 + dquot_drop(inode);
164 164 }
165 165  
166 166 clear_inode(inode);
... ... @@ -162,7 +162,7 @@
162 162 return inode;
163 163  
164 164 fail_drop:
165   - vfs_dq_drop(inode);
  165 + dquot_drop(inode);
166 166 inode->i_flags |= S_NOQUOTA;
167 167 fail_unlock:
168 168 inode->i_nlink = 0;
... ... @@ -133,7 +133,7 @@
133 133  
134 134 static void jfs_clear_inode(struct inode *inode)
135 135 {
136   - vfs_dq_drop(inode);
  136 + dquot_drop(inode);
137 137 }
138 138  
139 139 static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf)
... ... @@ -1087,7 +1087,7 @@
1087 1087 mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL,
1088 1088 "Inode=%lu\n", inode->i_ino);
1089 1089  
1090   - vfs_dq_drop(inode);
  1090 + dquot_drop(inode);
1091 1091  
1092 1092 /* To preven remote deletes we hold open lock before, now it
1093 1093 * is time to unlock PR and EX open locks. */
fs/ocfs2/quota_global.c
... ... @@ -852,7 +852,6 @@
852 852  
853 853 const struct dquot_operations ocfs2_quota_operations = {
854 854 .initialize = dquot_initialize,
855   - .drop = dquot_drop,
856 855 .write_dquot = ocfs2_write_dquot,
857 856 .acquire_dquot = ocfs2_acquire_dquot,
858 857 .release_dquot = ocfs2_release_dquot,
... ... @@ -1358,7 +1358,7 @@
1358 1358 /*
1359 1359 * Release all quotas referenced by inode
1360 1360 */
1361   -int dquot_drop(struct inode *inode)
  1361 +static void __dquot_drop(struct inode *inode)
1362 1362 {
1363 1363 int cnt;
1364 1364 struct dquot *put[MAXQUOTAS];
1365 1365  
1366 1366  
1367 1367  
1368 1368  
1369 1369  
... ... @@ -1370,32 +1370,31 @@
1370 1370 }
1371 1371 up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
1372 1372 dqput_all(put);
1373   - return 0;
1374 1373 }
1375   -EXPORT_SYMBOL(dquot_drop);
1376 1374  
1377   -/* Wrapper to remove references to quota structures from inode */
1378   -void vfs_dq_drop(struct inode *inode)
  1375 +void dquot_drop(struct inode *inode)
1379 1376 {
1380   - /* Here we can get arbitrary inode from clear_inode() so we have
1381   - * to be careful. OTOH we don't need locking as quota operations
1382   - * are allowed to change only at mount time */
1383   - if (!IS_NOQUOTA(inode) && inode->i_sb && inode->i_sb->dq_op
1384   - && inode->i_sb->dq_op->drop) {
1385   - int cnt;
1386   - /* Test before calling to rule out calls from proc and such
1387   - * where we are not allowed to block. Note that this is
1388   - * actually reliable test even without the lock - the caller
1389   - * must assure that nobody can come after the DQUOT_DROP and
1390   - * add quota pointers back anyway */
1391   - for (cnt = 0; cnt < MAXQUOTAS; cnt++)
1392   - if (inode->i_dquot[cnt])
1393   - break;
1394   - if (cnt < MAXQUOTAS)
1395   - inode->i_sb->dq_op->drop(inode);
  1377 + int cnt;
  1378 +
  1379 + if (IS_NOQUOTA(inode))
  1380 + return;
  1381 +
  1382 + /*
  1383 + * Test before calling to rule out calls from proc and such
  1384 + * where we are not allowed to block. Note that this is
  1385 + * actually reliable test even without the lock - the caller
  1386 + * must assure that nobody can come after the DQUOT_DROP and
  1387 + * add quota pointers back anyway.
  1388 + */
  1389 + for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
  1390 + if (inode->i_dquot[cnt])
  1391 + break;
1396 1392 }
  1393 +
  1394 + if (cnt < MAXQUOTAS)
  1395 + __dquot_drop(inode);
1397 1396 }
1398   -EXPORT_SYMBOL(vfs_dq_drop);
  1397 +EXPORT_SYMBOL(dquot_drop);
1399 1398  
1400 1399 /*
1401 1400 * inode_reserved_space is managed internally by quota, and protected by
... ... @@ -1812,7 +1811,6 @@
1812 1811 */
1813 1812 const struct dquot_operations dquot_operations = {
1814 1813 .initialize = dquot_initialize,
1815   - .drop = dquot_drop,
1816 1814 .write_dquot = dquot_commit,
1817 1815 .acquire_dquot = dquot_acquire,
1818 1816 .release_dquot = dquot_release,
... ... @@ -2029,7 +2027,7 @@
2029 2027 * When S_NOQUOTA is set, remove dquot references as no more
2030 2028 * references can be added
2031 2029 */
2032   - sb->dq_op->drop(inode);
  2030 + __dquot_drop(inode);
2033 2031 }
2034 2032  
2035 2033 error = -EIO;
... ... @@ -1964,7 +1964,7 @@
1964 1964 out_end_trans:
1965 1965 journal_end(th, th->t_super, th->t_blocks_allocated);
1966 1966 /* Drop can be outside and it needs more credits so it's better to have it outside */
1967   - vfs_dq_drop(inode);
  1967 + dquot_drop(inode);
1968 1968 inode->i_flags |= S_NOQUOTA;
1969 1969 make_bad_inode(inode);
1970 1970  
... ... @@ -546,7 +546,7 @@
546 546 */
547 547 static int drop_new_inode(struct inode *inode)
548 548 {
549   - vfs_dq_drop(inode);
  549 + dquot_drop(inode);
550 550 make_bad_inode(inode);
551 551 inode->i_flags |= S_NOQUOTA;
552 552 iput(inode);
... ... @@ -580,7 +580,7 @@
580 580  
581 581 static void reiserfs_clear_inode(struct inode *inode)
582 582 {
583   - vfs_dq_drop(inode);
  583 + dquot_drop(inode);
584 584 }
585 585  
586 586 #ifdef CONFIG_QUOTA
... ... @@ -623,7 +623,6 @@
623 623  
624 624 static const struct dquot_operations reiserfs_quota_operations = {
625 625 .initialize = dquot_initialize,
626   - .drop = dquot_drop,
627 626 .write_dquot = reiserfs_write_dquot,
628 627 .acquire_dquot = reiserfs_acquire_dquot,
629 628 .release_dquot = reiserfs_release_dquot,
... ... @@ -37,7 +37,7 @@
37 37 * as writing the quota to disk may need the lock as well.
38 38 */
39 39 dquot_free_inode(inode);
40   - vfs_dq_drop(inode);
  40 + dquot_drop(inode);
41 41  
42 42 clear_inode(inode);
43 43  
... ... @@ -156,7 +156,7 @@
156 156 vfs_dq_init(inode);
157 157 ret = dquot_alloc_inode(inode);
158 158 if (ret) {
159   - vfs_dq_drop(inode);
  159 + dquot_drop(inode);
160 160 inode->i_flags |= S_NOQUOTA;
161 161 inode->i_nlink = 0;
162 162 iput(inode);
... ... @@ -109,7 +109,7 @@
109 109 (unsigned long long)iinfo->i_lenExtents);
110 110 }
111 111  
112   - vfs_dq_drop(inode);
  112 + dquot_drop(inode);
113 113 kfree(iinfo->i_ext.i_data);
114 114 iinfo->i_ext.i_data = NULL;
115 115 }
... ... @@ -96,7 +96,7 @@
96 96 is_directory = S_ISDIR(inode->i_mode);
97 97  
98 98 dquot_free_inode(inode);
99   - vfs_dq_drop(inode);
  99 + dquot_drop(inode);
100 100  
101 101 clear_inode (inode);
102 102  
... ... @@ -358,7 +358,7 @@
358 358 vfs_dq_init(inode);
359 359 err = dquot_alloc_inode(inode);
360 360 if (err) {
361   - vfs_dq_drop(inode);
  361 + dquot_drop(inode);
362 362 goto fail_without_unlock;
363 363 }
364 364  
... ... @@ -1434,7 +1434,7 @@
1434 1434  
1435 1435 static void ufs_clear_inode(struct inode *inode)
1436 1436 {
1437   - vfs_dq_drop(inode);
  1437 + dquot_drop(inode);
1438 1438 }
1439 1439  
1440 1440 #ifdef CONFIG_QUOTA
include/linux/quota.h
... ... @@ -296,7 +296,6 @@
296 296 /* Operations working with dquots */
297 297 struct dquot_operations {
298 298 int (*initialize) (struct inode *, int);
299   - int (*drop) (struct inode *);
300 299 int (*write_dquot) (struct dquot *); /* Ordinary dquot write */
301 300 struct dquot *(*alloc_dquot)(struct super_block *, int); /* Allocate memory for new dquot */
302 301 void (*destroy_dquot)(struct dquot *); /* Free memory for dquot */
include/linux/quotaops.h
... ... @@ -24,7 +24,7 @@
24 24 void inode_sub_rsv_space(struct inode *inode, qsize_t number);
25 25  
26 26 int dquot_initialize(struct inode *inode, int type);
27   -int dquot_drop(struct inode *inode);
  27 +void dquot_drop(struct inode *inode);
28 28 struct dquot *dqget(struct super_block *sb, unsigned int id, int type);
29 29 void dqput(struct dquot *dquot);
30 30 int dquot_scan_active(struct super_block *sb,
... ... @@ -64,7 +64,6 @@
64 64 int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
65 65 int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
66 66  
67   -void vfs_dq_drop(struct inode *inode);
68 67 int dquot_transfer(struct inode *inode, struct iattr *iattr);
69 68 int vfs_dq_quota_on_remount(struct super_block *sb);
70 69  
... ... @@ -210,7 +209,7 @@
210 209 {
211 210 }
212 211  
213   -static inline void vfs_dq_drop(struct inode *inode)
  212 +static inline void dquot_drop(struct inode *inode)
214 213 {
215 214 }
216 215