quota: cleanup dquota sync functions
PATCH 1/1 quota: cleanup dquota sync functions
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 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 quota_sync_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 quota_sync_sb.
Btw, I think calling quota_sync_sb for the !wait case in __fsync_super might be a bad idea because it calls into ->sync_fs with wait = 1.
Note that the patch requires Jan's sync rewrite applies first.
fs/quota/quota.c +11 -10
@@ -159,10 +159,13 @@ static int check_quotactl_valid(struct sreturn error; } -static void quota_sync_sb (struct super_block *sb,int type) +void quota_sync_sb (struct super_block *sb,int type) {int cnt; +if (!sb->s_qcop->quota_sync) +return ; + sb->s_qcop->quota_sync (sb, type);if (sb_dqopt (sb)->flags &DQUOT_QUOTA_SYS_FILE )
@@ -192,16 +195,11 @@ static void quota_sync_sb(struct super_bmutex_unlock (&sb_dqopt (sb)->dqonoff_mutex); } -void sync_dquots (struct super_block *sb,int type) +static void sync_dquots (int type) { +struct super_block *sb;int cnt; -if (sb) { -if (sb->s_qcop->quota_sync) -quota_sync_sb (sb, type); -return ; - } -spin_lock (&sb_lock); restart:list_for_each_entry (sb, &super_blocks, s_list) {
@@ -222,7 +220,7 @@ restart: sb->s_count++;spin_unlock (&sb_lock);down_read (&sb->s_umount); -if (sb->s_root && sb->s_qcop->quota_sync) +if (sb->s_root)quota_sync_sb (sb, type);up_read (&sb->s_umount);spin_lock (&sb_lock);
@@ -301,7 +299,10 @@ static int do_quotactl(struct super_blocreturn sb->s_qcop->set_dqblk (sb, type, id, &idq); }case Q_SYNC : -sync_dquots (sb, type); +if (sb) +quota_sync_sb (sb, type); +else +sync_dquots (type);return 0 ;case Q_XQUOTAON :
fs/super.c +1 -1
@@ -259,7 +259,7 @@ EXPORT_SYMBOL(unlock_super);static int __fsync_super (struct super_block *sb,int wait) { -vfs_dq_sync (sb); +quota_sync_sb (sb,-1 );sync_inodes_sb (sb, wait);lock_super (sb);if (sb->s_dirt && sb->s_op->write_super)
include/linux/quotaops.h +3 -8
@@ -20,7 +20,7 @@ static inline struct quota_info *sb_dqop/* * declaration of quota_function calls in kernel. */ -void sync_dquots (struct super_block *sb,int type); +void quota_sync_sb (struct super_block *sb,int type);int dquot_initialize (struct inode *inode,int type);int dquot_drop (struct inode *inode);
@@ -253,12 +253,7 @@ static inline void vfs_dq_free_inode(str inode->i_sb->dq_op->free_inode (inode,1 ); } -/* The following two functions cannot be called inside a transaction */ -static inline void vfs_dq_sync (struct super_block *sb) -{ -sync_dquots (sb,-1 ); -} - +/* Cannot be called inside a transaction */ static inline int vfs_dq_off (struct super_block *sb,int remount) {int ret = -ENOSYS ;
@@ -334,7 +329,7 @@ static inline void vfs_dq_free_inode(str { } -static inline void vfs_dq_sync (struct super_block *sb) +static inline void quota_sync_sb (struct super_block *sb,int type); { }
Jan Kara
reviewerHi,
Quoted 9 lines · Christoph Hellwig
Currently the VFS calls
vfs_dq_syncto sync out disk quotas for a given superblock. This is a small wrapper aroundsync_dquotswhich for the case of a non-NULL superblock is a small wrapper aroundquota_sync_sb.Just make
quota_sync_sbglobal and call it directly. Also call it directly for those cases inquota.cthat have a superblock and leavesync_dquotspurely an iterator overquota_sync_sband remove it's superblock argument.
Quoted 7 lines
To make this nicer move the check for the lack of a
quota_syncmethod from the callers intoquota_sync_sb.Btw, I think calling
quota_sync_sbfor the !wait case in__fsync_supermight be a bad idea because it calls into ->sync_fs with wait = 1.Note that the patch requires Jan's sync rewrite applies first.
Looks fine. Thanks. I've added it to the series of sync cleanups...
Honza
Quoted 110 lines
Signed-off-by Christoph Hellwig <[email protected]>Index:
linux-2.6/fs/quota/quota.c
===================================================================fs/quota/quota.c +11
-10@@ -159,10 +159,13 @@ static int check_quotactl_valid(struct sreturn error; } -static void quota_sync_sb (struct super_block *sb,int type) +void quota_sync_sb (struct super_block *sb,int type) {int cnt; +if (!sb->s_qcop->quota_sync) +return ; + sb->s_qcop->quota_sync (sb, type);if (sb_dqopt (sb)->flags &DQUOT_QUOTA_SYS_FILE )@@ -192,16 +195,11 @@ static void quota_sync_sb(struct super_bmutex_unlock (&sb_dqopt (sb)->dqonoff_mutex); } -void sync_dquots (struct super_block *sb,int type) +static void sync_dquots (int type) { +struct super_block *sb;int cnt; -if (sb) { -if (sb->s_qcop->quota_sync) -quota_sync_sb (sb, type); -return ; - } -spin_lock (&sb_lock); restart:list_for_each_entry (sb, &super_blocks, s_list) {@@ -222,7 +220,7 @@ restart: sb->s_count++;spin_unlock (&sb_lock);down_read (&sb->s_umount); -if (sb->s_root && sb->s_qcop->quota_sync) +if (sb->s_root)quota_sync_sb (sb, type);up_read (&sb->s_umount);spin_lock (&sb_lock);@@ -301,7 +299,10 @@ static int do_quotactl(struct super_blocreturn sb->s_qcop->set_dqblk (sb, type, id, &idq); }case Q_SYNC : -sync_dquots (sb, type); +if (sb) +quota_sync_sb (sb, type); +else +sync_dquots (type);return 0 ;case Q_XQUOTAON :Index:
linux-2.6/fs/super.c
===================================================================fs/super.c +1
-1@@ -259,7 +259,7 @@ EXPORT_SYMBOL(unlock_super);static int __fsync_super (struct super_block *sb,int wait) { -vfs_dq_sync (sb); +quota_sync_sb (sb,-1 );sync_inodes_sb (sb, wait);lock_super (sb);if (sb->s_dirt && sb->s_op->write_super)Index:
linux-2.6/include/linux/quotaops.h
===================================================================include/linux/quotaops.h +3
-8@@ -20,7 +20,7 @@ static inline struct quota_info *sb_dqop/* * declaration of quota_function calls in kernel. */ -void sync_dquots (struct super_block *sb,int type); +void quota_sync_sb (struct super_block *sb,int type);int dquot_initialize (struct inode *inode,int type);int dquot_drop (struct inode *inode);@@ -253,12 +253,7 @@ static inline void vfs_dq_free_inode(str inode->i_sb->dq_op->free_inode (inode,1 ); } -/* The following two functions cannot be called inside a transaction */ -static inline void vfs_dq_sync (struct super_block *sb) -{ -sync_dquots (sb,-1 ); -} - +/* Cannot be called inside a transaction */ static inline int vfs_dq_off (struct super_block *sb,int remount) {int ret = -ENOSYS ;@@ -334,7 +329,7 @@ static inline void vfs_dq_free_inode(str { } -static inline void vfs_dq_sync (struct super_block *sb) +static inline void quota_sync_sb (struct super_block *sb,int type); { }
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Jan Kara
reviewerQuoted 2 lines · Christoph Hellwig
Btw, I think calling
quota_sync_sbfor the !wait case in__fsync_supermight be a bad idea because it calls into ->sync_fs with wait = 1.
Yes, I know this. I could hack it around so that quota is not synced at
all when wait == 0 but it would be a bit surprising to future callers. But we could just call ->quota_sync() when wait == 0. That would basically do what's expected. I guess I'll do that.
Honza
PS: I've changed quota_sync_sb() to sync_quota_sb() and fixed one compile error when CONFIG_QUOTA is disabled in your patch.
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR