Commit 850b201b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Al Viro

quota: cleanup dquota sync functions (version 4)

Currently the VFS calls vfs_dq_sync to sync out disk quotas for a given
superblock.  This is a small wrapper around sync_dquots which for the
case of a non-NULL superblock is a small wrapper around quota_sync_sb.

Just make quota_sync_sb global (rename it to sync_quota_sb) and call it
directly.  Also call it directly for those cases in quota.c that have a
superblock and leave sync_dquots purely an iterator over sync_quota_sb and
remove it's superblock argument.

To make this nicer move the check for the lack of a quota_sync method
from the callers into sync_quota_sb.

[folded build fix from Alexander Beregalov <a.beregalov@gmail.com>]
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 60b0680f
...@@ -159,10 +159,14 @@ static int check_quotactl_valid(struct super_block *sb, int type, int cmd, ...@@ -159,10 +159,14 @@ static int check_quotactl_valid(struct super_block *sb, int type, int cmd,
return error; return error;
} }
static void quota_sync_sb(struct super_block *sb, int type) #ifdef CONFIG_QUOTA
void sync_quota_sb(struct super_block *sb, int type)
{ {
int cnt; int cnt;
if (!sb->s_qcop->quota_sync)
return;
sb->s_qcop->quota_sync(sb, type); sb->s_qcop->quota_sync(sb, type);
if (sb_dqopt(sb)->flags & DQUOT_QUOTA_SYS_FILE) if (sb_dqopt(sb)->flags & DQUOT_QUOTA_SYS_FILE)
...@@ -191,17 +195,13 @@ static void quota_sync_sb(struct super_block *sb, int type) ...@@ -191,17 +195,13 @@ static void quota_sync_sb(struct super_block *sb, int type)
} }
mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
} }
#endif
void sync_dquots(struct super_block *sb, int type) static void sync_dquots(int type)
{ {
struct super_block *sb;
int cnt; int cnt;
if (sb) {
if (sb->s_qcop->quota_sync)
quota_sync_sb(sb, type);
return;
}
spin_lock(&sb_lock); spin_lock(&sb_lock);
restart: restart:
list_for_each_entry(sb, &super_blocks, s_list) { list_for_each_entry(sb, &super_blocks, s_list) {
...@@ -222,8 +222,8 @@ void sync_dquots(struct super_block *sb, int type) ...@@ -222,8 +222,8 @@ void sync_dquots(struct super_block *sb, int type)
sb->s_count++; sb->s_count++;
spin_unlock(&sb_lock); spin_unlock(&sb_lock);
down_read(&sb->s_umount); down_read(&sb->s_umount);
if (sb->s_root && sb->s_qcop->quota_sync) if (sb->s_root)
quota_sync_sb(sb, type); sync_quota_sb(sb, type);
up_read(&sb->s_umount); up_read(&sb->s_umount);
spin_lock(&sb_lock); spin_lock(&sb_lock);
if (__put_super_and_need_restart(sb)) if (__put_super_and_need_restart(sb))
...@@ -301,7 +301,10 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, ...@@ -301,7 +301,10 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,
return sb->s_qcop->set_dqblk(sb, type, id, &idq); return sb->s_qcop->set_dqblk(sb, type, id, &idq);
} }
case Q_SYNC: case Q_SYNC:
sync_dquots(sb, type); if (sb)
sync_quota_sb(sb, type);
else
sync_dquots(type);
return 0; return 0;
case Q_XQUOTAON: case Q_XQUOTAON:
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
*/ */
static int __sync_filesystem(struct super_block *sb, int wait) static int __sync_filesystem(struct super_block *sb, int wait)
{ {
vfs_dq_sync(sb); sync_quota_sb(sb, -1);
sync_inodes_sb(sb, wait); sync_inodes_sb(sb, wait);
lock_super(sb); lock_super(sb);
if (sb->s_dirt && sb->s_op->write_super) if (sb->s_dirt && sb->s_op->write_super)
......
...@@ -20,7 +20,7 @@ static inline struct quota_info *sb_dqopt(struct super_block *sb) ...@@ -20,7 +20,7 @@ static inline struct quota_info *sb_dqopt(struct super_block *sb)
/* /*
* declaration of quota_function calls in kernel. * declaration of quota_function calls in kernel.
*/ */
void sync_dquots(struct super_block *sb, int type); void sync_quota_sb(struct super_block *sb, int type);
int dquot_initialize(struct inode *inode, int type); int dquot_initialize(struct inode *inode, int type);
int dquot_drop(struct inode *inode); int dquot_drop(struct inode *inode);
...@@ -253,12 +253,7 @@ static inline void vfs_dq_free_inode(struct inode *inode) ...@@ -253,12 +253,7 @@ static inline void vfs_dq_free_inode(struct inode *inode)
inode->i_sb->dq_op->free_inode(inode, 1); inode->i_sb->dq_op->free_inode(inode, 1);
} }
/* The following two functions cannot be called inside a transaction */ /* Cannot be called inside a transaction */
static inline void vfs_dq_sync(struct super_block *sb)
{
sync_dquots(sb, -1);
}
static inline int vfs_dq_off(struct super_block *sb, int remount) static inline int vfs_dq_off(struct super_block *sb, int remount)
{ {
int ret = -ENOSYS; int ret = -ENOSYS;
...@@ -334,7 +329,7 @@ static inline void vfs_dq_free_inode(struct inode *inode) ...@@ -334,7 +329,7 @@ static inline void vfs_dq_free_inode(struct inode *inode)
{ {
} }
static inline void vfs_dq_sync(struct super_block *sb) static inline void sync_quota_sb(struct super_block *sb, int type)
{ {
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment