linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH] quota: cleanup dquota sync functions
Date: Sun, 26 Apr 2009 09:31:42 +0200	[thread overview]
Message-ID: <20090426073142.GA5267@lst.de> (raw)

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.


Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/fs/quota/quota.c
===================================================================
--- linux-2.6.orig/fs/quota/quota.c	2009-04-25 19:53:49.074949184 +0200
+++ linux-2.6/fs/quota/quota.c	2009-04-25 20:11:23.598952601 +0200
@@ -159,10 +159,13 @@ static int check_quotactl_valid(struct s
 	return 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_b
 	mutex_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_bloc
 			return 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
===================================================================
--- linux-2.6.orig/fs/super.c	2009-04-25 19:54:15.376074155 +0200
+++ linux-2.6/fs/super.c	2009-04-25 19:54:16.125949480 +0200
@@ -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
===================================================================
--- linux-2.6.orig/include/linux/quotaops.h	2009-04-25 19:53:49.086949524 +0200
+++ linux-2.6/include/linux/quotaops.h	2009-04-25 19:54:16.126949327 +0200
@@ -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);
 {
 }
 

             reply	other threads:[~2009-04-26  7:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-26  7:31 Christoph Hellwig [this message]
2009-04-27 13:35 ` [PATCH] quota: cleanup dquota sync functions Jan Kara
2009-04-27 14:14 ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090426073142.GA5267@lst.de \
    --to=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).