Skip to content

Commit

Permalink
dquot: cleanup dquot drop routine
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
  • Loading branch information
Christoph Hellwig authored and jankara committed Mar 4, 2010
1 parent 257ba15 commit 9f75475
Show file tree
Hide file tree
Showing 22 changed files with 49 additions and 59 deletions.
2 changes: 0 additions & 2 deletions Documentation/filesystems/Locking
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@ in sys_read() and friends.
--------------------------- dquot_operations -------------------------------
prototypes:
int (*initialize) (struct inode *, int);
int (*drop) (struct inode *);
int (*write_dquot) (struct dquot *);
int (*acquire_dquot) (struct dquot *);
int (*release_dquot) (struct dquot *);
Expand All @@ -475,7 +474,6 @@ What filesystem should expect from the generic quota functions:

FS recursion Held locks when called
initialize: yes maybe dqonoff_sem
drop: yes -
write_dquot: yes dqonoff_sem or dqptr_sem
acquire_dquot: yes dqonoff_sem or dqptr_sem
release_dquot: yes dqonoff_sem or dqptr_sem
Expand Down
4 changes: 2 additions & 2 deletions fs/ext2/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void ext2_free_inode (struct inode * inode)
/* Quota is already initialized in iput() */
ext2_xattr_delete_inode(inode);
dquot_free_inode(inode);
vfs_dq_drop(inode);
dquot_drop(inode);
}

es = EXT2_SB(sb)->s_es;
Expand Down Expand Up @@ -608,7 +608,7 @@ struct inode *ext2_new_inode(struct inode *dir, int mode)
dquot_free_inode(inode);

fail_drop:
vfs_dq_drop(inode);
dquot_drop(inode);
inode->i_flags |= S_NOQUOTA;
inode->i_nlink = 0;
unlock_new_inode(inode);
Expand Down
2 changes: 1 addition & 1 deletion fs/ext2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static void ext2_clear_inode(struct inode *inode)
{
struct ext2_block_alloc_info *rsv = EXT2_I(inode)->i_block_alloc_info;

vfs_dq_drop(inode);
dquot_drop(inode);
ext2_discard_reservation(inode);
EXT2_I(inode)->i_block_alloc_info = NULL;
if (unlikely(rsv))
Expand Down
4 changes: 2 additions & 2 deletions fs/ext3/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)
vfs_dq_init(inode);
ext3_xattr_delete_inode(handle, inode);
dquot_free_inode(inode);
vfs_dq_drop(inode);
dquot_drop(inode);

is_directory = S_ISDIR(inode->i_mode);

Expand Down Expand Up @@ -622,7 +622,7 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
dquot_free_inode(inode);

fail_drop:
vfs_dq_drop(inode);
dquot_drop(inode);
inode->i_flags |= S_NOQUOTA;
inode->i_nlink = 0;
unlock_new_inode(inode);
Expand Down
3 changes: 1 addition & 2 deletions fs/ext3/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ static void ext3_clear_inode(struct inode *inode)
{
struct ext3_block_alloc_info *rsv = EXT3_I(inode)->i_block_alloc_info;

vfs_dq_drop(inode);
dquot_drop(inode);
ext3_discard_reservation(inode);
EXT3_I(inode)->i_block_alloc_info = NULL;
if (unlikely(rsv))
Expand Down Expand Up @@ -753,7 +753,6 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type,

static const struct dquot_operations ext3_quota_operations = {
.initialize = dquot_initialize,
.drop = dquot_drop,
.write_dquot = ext3_write_dquot,
.acquire_dquot = ext3_acquire_dquot,
.release_dquot = ext3_release_dquot,
Expand Down
4 changes: 2 additions & 2 deletions fs/ext4/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
vfs_dq_init(inode);
ext4_xattr_delete_inode(handle, inode);
dquot_free_inode(inode);
vfs_dq_drop(inode);
dquot_drop(inode);

is_directory = S_ISDIR(inode->i_mode);

Expand Down Expand Up @@ -1077,7 +1077,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode,
dquot_free_inode(inode);

fail_drop:
vfs_dq_drop(inode);
dquot_drop(inode);
inode->i_flags |= S_NOQUOTA;
inode->i_nlink = 0;
unlock_new_inode(inode);
Expand Down
3 changes: 1 addition & 2 deletions fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ static void destroy_inodecache(void)

static void ext4_clear_inode(struct inode *inode)
{
vfs_dq_drop(inode);
dquot_drop(inode);
ext4_discard_preallocations(inode);
if (EXT4_JOURNAL(inode))
jbd2_journal_release_jbd_inode(EXT4_SB(inode->i_sb)->s_journal,
Expand Down Expand Up @@ -1014,7 +1014,6 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,

static const struct dquot_operations ext4_quota_operations = {
.initialize = dquot_initialize,
.drop = dquot_drop,
#ifdef CONFIG_QUOTA
.get_reserved_space = ext4_get_reserved_space,
#endif
Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void jfs_delete_inode(struct inode *inode)
*/
vfs_dq_init(inode);
dquot_free_inode(inode);
vfs_dq_drop(inode);
dquot_drop(inode);
}

clear_inode(inode);
Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/jfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
return inode;

fail_drop:
vfs_dq_drop(inode);
dquot_drop(inode);
inode->i_flags |= S_NOQUOTA;
fail_unlock:
inode->i_nlink = 0;
Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static void jfs_destroy_inode(struct inode *inode)

static void jfs_clear_inode(struct inode *inode)
{
vfs_dq_drop(inode);
dquot_drop(inode);
}

static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf)
Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ void ocfs2_clear_inode(struct inode *inode)
mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL,
"Inode=%lu\n", inode->i_ino);

vfs_dq_drop(inode);
dquot_drop(inode);

/* To preven remote deletes we hold open lock before, now it
* is time to unlock PR and EX open locks. */
Expand Down
1 change: 0 additions & 1 deletion fs/ocfs2/quota_global.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,6 @@ static void ocfs2_destroy_dquot(struct dquot *dquot)

const struct dquot_operations ocfs2_quota_operations = {
.initialize = dquot_initialize,
.drop = dquot_drop,
.write_dquot = ocfs2_write_dquot,
.acquire_dquot = ocfs2_acquire_dquot,
.release_dquot = ocfs2_release_dquot,
Expand Down
52 changes: 25 additions & 27 deletions fs/quota/dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ EXPORT_SYMBOL(dquot_initialize);
/*
* Release all quotas referenced by inode
*/
int dquot_drop(struct inode *inode)
static void __dquot_drop(struct inode *inode)
{
int cnt;
struct dquot *put[MAXQUOTAS];
Expand All @@ -1370,32 +1370,31 @@ int dquot_drop(struct inode *inode)
}
up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
dqput_all(put);
return 0;
}
EXPORT_SYMBOL(dquot_drop);

/* Wrapper to remove references to quota structures from inode */
void vfs_dq_drop(struct inode *inode)
{
/* Here we can get arbitrary inode from clear_inode() so we have
* to be careful. OTOH we don't need locking as quota operations
* are allowed to change only at mount time */
if (!IS_NOQUOTA(inode) && inode->i_sb && inode->i_sb->dq_op
&& inode->i_sb->dq_op->drop) {
int cnt;
/* Test before calling to rule out calls from proc and such
* where we are not allowed to block. Note that this is
* actually reliable test even without the lock - the caller
* must assure that nobody can come after the DQUOT_DROP and
* add quota pointers back anyway */
for (cnt = 0; cnt < MAXQUOTAS; cnt++)
if (inode->i_dquot[cnt])
break;
if (cnt < MAXQUOTAS)
inode->i_sb->dq_op->drop(inode);
}
}
EXPORT_SYMBOL(vfs_dq_drop);
void dquot_drop(struct inode *inode)
{
int cnt;

if (IS_NOQUOTA(inode))
return;

/*
* Test before calling to rule out calls from proc and such
* where we are not allowed to block. Note that this is
* actually reliable test even without the lock - the caller
* must assure that nobody can come after the DQUOT_DROP and
* add quota pointers back anyway.
*/
for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
if (inode->i_dquot[cnt])
break;
}

if (cnt < MAXQUOTAS)
__dquot_drop(inode);
}
EXPORT_SYMBOL(dquot_drop);

/*
* inode_reserved_space is managed internally by quota, and protected by
Expand Down Expand Up @@ -1812,7 +1811,6 @@ EXPORT_SYMBOL(dquot_commit_info);
*/
const struct dquot_operations dquot_operations = {
.initialize = dquot_initialize,
.drop = dquot_drop,
.write_dquot = dquot_commit,
.acquire_dquot = dquot_acquire,
.release_dquot = dquot_release,
Expand Down Expand Up @@ -2029,7 +2027,7 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
* When S_NOQUOTA is set, remove dquot references as no more
* references can be added
*/
sb->dq_op->drop(inode);
__dquot_drop(inode);
}

error = -EIO;
Expand Down
2 changes: 1 addition & 1 deletion fs/reiserfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
out_end_trans:
journal_end(th, th->t_super, th->t_blocks_allocated);
/* Drop can be outside and it needs more credits so it's better to have it outside */
vfs_dq_drop(inode);
dquot_drop(inode);
inode->i_flags |= S_NOQUOTA;
make_bad_inode(inode);

Expand Down
2 changes: 1 addition & 1 deletion fs/reiserfs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
*/
static int drop_new_inode(struct inode *inode)
{
vfs_dq_drop(inode);
dquot_drop(inode);
make_bad_inode(inode);
inode->i_flags |= S_NOQUOTA;
iput(inode);
Expand Down
3 changes: 1 addition & 2 deletions fs/reiserfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ static void reiserfs_dirty_inode(struct inode *inode)

static void reiserfs_clear_inode(struct inode *inode)
{
vfs_dq_drop(inode);
dquot_drop(inode);
}

#ifdef CONFIG_QUOTA
Expand Down Expand Up @@ -623,7 +623,6 @@ static int reiserfs_quota_on(struct super_block *, int, int, char *, int);

static const struct dquot_operations reiserfs_quota_operations = {
.initialize = dquot_initialize,
.drop = dquot_drop,
.write_dquot = reiserfs_write_dquot,
.acquire_dquot = reiserfs_acquire_dquot,
.release_dquot = reiserfs_release_dquot,
Expand Down
4 changes: 2 additions & 2 deletions fs/udf/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void udf_free_inode(struct inode *inode)
* as writing the quota to disk may need the lock as well.
*/
dquot_free_inode(inode);
vfs_dq_drop(inode);
dquot_drop(inode);

clear_inode(inode);

Expand Down Expand Up @@ -156,7 +156,7 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
vfs_dq_init(inode);
ret = dquot_alloc_inode(inode);
if (ret) {
vfs_dq_drop(inode);
dquot_drop(inode);
inode->i_flags |= S_NOQUOTA;
inode->i_nlink = 0;
iput(inode);
Expand Down
2 changes: 1 addition & 1 deletion fs/udf/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void udf_clear_inode(struct inode *inode)
(unsigned long long)iinfo->i_lenExtents);
}

vfs_dq_drop(inode);
dquot_drop(inode);
kfree(iinfo->i_ext.i_data);
iinfo->i_ext.i_data = NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions fs/ufs/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void ufs_free_inode (struct inode * inode)
is_directory = S_ISDIR(inode->i_mode);

dquot_free_inode(inode);
vfs_dq_drop(inode);
dquot_drop(inode);

clear_inode (inode);

Expand Down Expand Up @@ -358,7 +358,7 @@ struct inode * ufs_new_inode(struct inode * dir, int mode)
vfs_dq_init(inode);
err = dquot_alloc_inode(inode);
if (err) {
vfs_dq_drop(inode);
dquot_drop(inode);
goto fail_without_unlock;
}

Expand Down
2 changes: 1 addition & 1 deletion fs/ufs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ static void destroy_inodecache(void)

static void ufs_clear_inode(struct inode *inode)
{
vfs_dq_drop(inode);
dquot_drop(inode);
}

#ifdef CONFIG_QUOTA
Expand Down
1 change: 0 additions & 1 deletion include/linux/quota.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ struct quota_format_ops {
/* Operations working with dquots */
struct dquot_operations {
int (*initialize) (struct inode *, int);
int (*drop) (struct inode *);
int (*write_dquot) (struct dquot *); /* Ordinary dquot write */
struct dquot *(*alloc_dquot)(struct super_block *, int); /* Allocate memory for new dquot */
void (*destroy_dquot)(struct dquot *); /* Free memory for dquot */
Expand Down
5 changes: 2 additions & 3 deletions include/linux/quotaops.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void inode_claim_rsv_space(struct inode *inode, qsize_t number);
void inode_sub_rsv_space(struct inode *inode, qsize_t number);

int dquot_initialize(struct inode *inode, int type);
int dquot_drop(struct inode *inode);
void dquot_drop(struct inode *inode);
struct dquot *dqget(struct super_block *sb, unsigned int id, int type);
void dqput(struct dquot *dquot);
int dquot_scan_active(struct super_block *sb,
Expand Down Expand Up @@ -64,7 +64,6 @@ int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);

void vfs_dq_drop(struct inode *inode);
int dquot_transfer(struct inode *inode, struct iattr *iattr);
int vfs_dq_quota_on_remount(struct super_block *sb);

Expand Down Expand Up @@ -210,7 +209,7 @@ static inline void vfs_dq_init(struct inode *inode)
{
}

static inline void vfs_dq_drop(struct inode *inode)
static inline void dquot_drop(struct inode *inode)
{
}

Expand Down

0 comments on commit 9f75475

Please sign in to comment.