Skip to content

Commit 871a293

Browse files
Christoph Hellwigjankara
authored andcommitted
dquot: cleanup dquot initialize routine
Get rid of the initialize 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_initialize helper to __dquot_initialize and vfs_dq_init to dquot_initialize to have a consistent namespace. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 907f455 commit 871a293

39 files changed

Lines changed: 141 additions & 145 deletions

‎Documentation/filesystems/Locking‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@ in sys_read() and friends.
460460

461461
--------------------------- dquot_operations -------------------------------
462462
prototypes:
463-
int (*initialize) (struct inode *, int);
464463
int (*write_dquot) (struct dquot *);
465464
int (*acquire_dquot) (struct dquot *);
466465
int (*release_dquot) (struct dquot *);
@@ -473,7 +472,6 @@ a proper locking wrt the filesystem and call the generic quota operations.
473472
What filesystem should expect from the generic quota functions:
474473

475474
FS recursion Held locks when called
476-
initialize: yes maybe dqonoff_sem
477475
write_dquot: yes dqonoff_sem or dqptr_sem
478476
acquire_dquot: yes dqonoff_sem or dqptr_sem
479477
release_dquot: yes dqonoff_sem or dqptr_sem

‎fs/ext2/file.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <linux/time.h>
2222
#include <linux/pagemap.h>
23+
#include <linux/quotaops.h>
2324
#include "ext2.h"
2425
#include "xattr.h"
2526
#include "acl.h"

‎fs/ext2/ialloc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ struct inode *ext2_new_inode(struct inode *dir, int mode)
586586
goto fail_drop;
587587
}
588588

589-
vfs_dq_init(inode);
589+
dquot_initialize(inode);
590590
err = dquot_alloc_inode(inode);
591591
if (err)
592592
goto fail_drop;

‎fs/ext2/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static inline int ext2_inode_is_fast_symlink(struct inode *inode)
5959
void ext2_delete_inode (struct inode * inode)
6060
{
6161
if (!is_bad_inode(inode))
62-
vfs_dq_init(inode);
62+
dquot_initialize(inode);
6363
truncate_inode_pages(&inode->i_data, 0);
6464

6565
if (is_bad_inode(inode))
@@ -1461,7 +1461,7 @@ int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
14611461
return error;
14621462

14631463
if (iattr->ia_valid & ATTR_SIZE)
1464-
vfs_dq_init(inode);
1464+
dquot_initialize(inode);
14651465
if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
14661466
(iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
14671467
error = dquot_transfer(inode, iattr);

‎fs/ext2/namei.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static int ext2_create (struct inode * dir, struct dentry * dentry, int mode, st
102102
{
103103
struct inode *inode;
104104

105-
vfs_dq_init(dir);
105+
dquot_initialize(dir);
106106

107107
inode = ext2_new_inode(dir, mode);
108108
if (IS_ERR(inode))
@@ -131,7 +131,7 @@ static int ext2_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_
131131
if (!new_valid_dev(rdev))
132132
return -EINVAL;
133133

134-
vfs_dq_init(dir);
134+
dquot_initialize(dir);
135135

136136
inode = ext2_new_inode (dir, mode);
137137
err = PTR_ERR(inode);
@@ -157,7 +157,7 @@ static int ext2_symlink (struct inode * dir, struct dentry * dentry,
157157
if (l > sb->s_blocksize)
158158
goto out;
159159

160-
vfs_dq_init(dir);
160+
dquot_initialize(dir);
161161

162162
inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO);
163163
err = PTR_ERR(inode);
@@ -202,7 +202,7 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,
202202
if (inode->i_nlink >= EXT2_LINK_MAX)
203203
return -EMLINK;
204204

205-
vfs_dq_init(dir);
205+
dquot_initialize(dir);
206206

207207
inode->i_ctime = CURRENT_TIME_SEC;
208208
inode_inc_link_count(inode);
@@ -226,7 +226,7 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode)
226226
if (dir->i_nlink >= EXT2_LINK_MAX)
227227
goto out;
228228

229-
vfs_dq_init(dir);
229+
dquot_initialize(dir);
230230

231231
inode_inc_link_count(dir);
232232

@@ -274,7 +274,7 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry)
274274
struct page * page;
275275
int err = -ENOENT;
276276

277-
vfs_dq_init(dir);
277+
dquot_initialize(dir);
278278

279279
de = ext2_find_entry (dir, &dentry->d_name, &page);
280280
if (!de)
@@ -318,8 +318,8 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
318318
struct ext2_dir_entry_2 * old_de;
319319
int err = -ENOENT;
320320

321-
vfs_dq_init(old_dir);
322-
vfs_dq_init(new_dir);
321+
dquot_initialize(old_dir);
322+
dquot_initialize(new_dir);
323323

324324
old_de = ext2_find_entry (old_dir, &old_dentry->d_name, &old_page);
325325
if (!old_de)

‎fs/ext3/file.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/time.h>
2222
#include <linux/fs.h>
2323
#include <linux/jbd.h>
24+
#include <linux/quotaops.h>
2425
#include <linux/ext3_fs.h>
2526
#include <linux/ext3_jbd.h>
2627
#include "xattr.h"

‎fs/ext3/ialloc.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)
123123
* Note: we must free any quota before locking the superblock,
124124
* as writing the quota to disk may need the lock as well.
125125
*/
126-
vfs_dq_init(inode);
126+
dquot_initialize(inode);
127127
ext3_xattr_delete_inode(handle, inode);
128128
dquot_free_inode(inode);
129129
dquot_drop(inode);
@@ -588,7 +588,7 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
588588
sizeof(struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE : 0;
589589

590590
ret = inode;
591-
vfs_dq_init(inode);
591+
dquot_initialize(inode);
592592
err = dquot_alloc_inode(inode);
593593
if (err)
594594
goto fail_drop;

‎fs/ext3/inode.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void ext3_delete_inode (struct inode * inode)
197197
handle_t *handle;
198198

199199
if (!is_bad_inode(inode))
200-
vfs_dq_init(inode);
200+
dquot_initialize(inode);
201201

202202
truncate_inode_pages(&inode->i_data, 0);
203203

@@ -3152,7 +3152,7 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr)
31523152
return error;
31533153

31543154
if (ia_valid & ATTR_SIZE)
3155-
vfs_dq_init(inode);
3155+
dquot_initialize(inode);
31563156
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
31573157
(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
31583158
handle_t *handle;
@@ -3250,7 +3250,7 @@ static int ext3_writepage_trans_blocks(struct inode *inode)
32503250
ret = 2 * (bpp + indirects) + 2;
32513251

32523252
#ifdef CONFIG_QUOTA
3253-
/* We know that structure was already allocated during vfs_dq_init so
3253+
/* We know that structure was already allocated during dquot_initialize so
32543254
* we will be updating only the data blocks + inodes */
32553255
ret += EXT3_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb);
32563256
#endif

‎fs/ext3/namei.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ static int ext3_create (struct inode * dir, struct dentry * dentry, int mode,
16961696
struct inode * inode;
16971697
int err, retries = 0;
16981698

1699-
vfs_dq_init(dir);
1699+
dquot_initialize(dir);
17001700

17011701
retry:
17021702
handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -1732,7 +1732,7 @@ static int ext3_mknod (struct inode * dir, struct dentry *dentry,
17321732
if (!new_valid_dev(rdev))
17331733
return -EINVAL;
17341734

1735-
vfs_dq_init(dir);
1735+
dquot_initialize(dir);
17361736

17371737
retry:
17381738
handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -1770,7 +1770,7 @@ static int ext3_mkdir(struct inode * dir, struct dentry * dentry, int mode)
17701770
if (dir->i_nlink >= EXT3_LINK_MAX)
17711771
return -EMLINK;
17721772

1773-
vfs_dq_init(dir);
1773+
dquot_initialize(dir);
17741774

17751775
retry:
17761776
handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -2066,8 +2066,8 @@ static int ext3_rmdir (struct inode * dir, struct dentry *dentry)
20662066

20672067
/* Initialize quotas before so that eventual writes go in
20682068
* separate transaction */
2069-
vfs_dq_init(dir);
2070-
vfs_dq_init(dentry->d_inode);
2069+
dquot_initialize(dir);
2070+
dquot_initialize(dentry->d_inode);
20712071

20722072
handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb));
20732073
if (IS_ERR(handle))
@@ -2127,8 +2127,8 @@ static int ext3_unlink(struct inode * dir, struct dentry *dentry)
21272127

21282128
/* Initialize quotas before so that eventual writes go
21292129
* in separate transaction */
2130-
vfs_dq_init(dir);
2131-
vfs_dq_init(dentry->d_inode);
2130+
dquot_initialize(dir);
2131+
dquot_initialize(dentry->d_inode);
21322132

21332133
handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb));
21342134
if (IS_ERR(handle))
@@ -2184,7 +2184,7 @@ static int ext3_symlink (struct inode * dir,
21842184
if (l > dir->i_sb->s_blocksize)
21852185
return -ENAMETOOLONG;
21862186

2187-
vfs_dq_init(dir);
2187+
dquot_initialize(dir);
21882188

21892189
retry:
21902190
handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
@@ -2241,7 +2241,7 @@ static int ext3_link (struct dentry * old_dentry,
22412241
if (inode->i_nlink >= EXT3_LINK_MAX)
22422242
return -EMLINK;
22432243

2244-
vfs_dq_init(dir);
2244+
dquot_initialize(dir);
22452245

22462246
/*
22472247
* Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing
@@ -2293,15 +2293,15 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
22932293
struct ext3_dir_entry_2 * old_de, * new_de;
22942294
int retval, flush_file = 0;
22952295

2296-
vfs_dq_init(old_dir);
2297-
vfs_dq_init(new_dir);
2296+
dquot_initialize(old_dir);
2297+
dquot_initialize(new_dir);
22982298

22992299
old_bh = new_bh = dir_bh = NULL;
23002300

23012301
/* Initialize quotas before so that eventual writes go
23022302
* in separate transaction */
23032303
if (new_dentry->d_inode)
2304-
vfs_dq_init(new_dentry->d_inode);
2304+
dquot_initialize(new_dentry->d_inode);
23052305
handle = ext3_journal_start(old_dir, 2 *
23062306
EXT3_DATA_TRANS_BLOCKS(old_dir->i_sb) +
23072307
EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2);

‎fs/ext3/super.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,6 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type,
752752
const char *data, size_t len, loff_t off);
753753

754754
static const struct dquot_operations ext3_quota_operations = {
755-
.initialize = dquot_initialize,
756755
.write_dquot = ext3_write_dquot,
757756
.acquire_dquot = ext3_acquire_dquot,
758757
.release_dquot = ext3_release_dquot,
@@ -1480,7 +1479,7 @@ static void ext3_orphan_cleanup (struct super_block * sb,
14801479
}
14811480

14821481
list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan);
1483-
vfs_dq_init(inode);
1482+
dquot_initialize(inode);
14841483
if (inode->i_nlink) {
14851484
printk(KERN_DEBUG
14861485
"%s: truncating inode %lu to %Ld bytes\n",
@@ -2736,7 +2735,7 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
27362735
* Process 1 Process 2
27372736
* ext3_create() quota_sync()
27382737
* journal_start() write_dquot()
2739-
* vfs_dq_init() down(dqio_mutex)
2738+
* dquot_initialize() down(dqio_mutex)
27402739
* down(dqio_mutex) journal_start()
27412740
*
27422741
*/

0 commit comments

Comments
 (0)