From: Christoph Hellwig <hch@infradead.org>
To: jack@suse.cz
Cc: swhiteho@redhat.com, linux-fsdevel@vger.kernel.org, xfs@oss.sgi.com
Subject: [PATCH 06/10] quota: move code from sync_quota_sb into vfs_quota_sync
Date: Tue, 16 Feb 2010 03:44:52 -0500 [thread overview]
Message-ID: <20100216084651.956101538@bombadil.infradead.org> (raw)
In-Reply-To: 20100216084446.377980079@bombadil.infradead.org
[-- Attachment #1: quota-cleanup-sync --]
[-- Type: text/plain, Size: 7555 bytes --]
Currenly sync_quota_sb does a lot of sync and truncate action that only
applies to "VFS" style quotas and is actively harmful for the sync
performance in XFS. Move it into vfs_quota_sync and add a wait paramter
to ->quota_sync to tell if we need it or not.
My audit of the GFS2 code says it's also not needed given the way GFS2
implements quotas, but I'd be happy if this can get a detailed review.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: linux-2.6/fs/quota/dquot.c
===================================================================
--- linux-2.6.orig/fs/quota/dquot.c 2010-02-16 00:13:43.000000000 +0100
+++ linux-2.6/fs/quota/dquot.c 2010-02-16 00:19:51.642255742 +0100
@@ -564,7 +564,7 @@ out:
}
EXPORT_SYMBOL(dquot_scan_active);
-int vfs_quota_sync(struct super_block *sb, int type)
+int vfs_quota_sync(struct super_block *sb, int type, int wait)
{
struct list_head *dirty;
struct dquot *dquot;
@@ -609,6 +609,33 @@ int vfs_quota_sync(struct super_block *s
spin_unlock(&dq_list_lock);
mutex_unlock(&dqopt->dqonoff_mutex);
+ if (!wait || (sb_dqopt(sb)->flags & DQUOT_QUOTA_SYS_FILE))
+ return 0;
+
+ /* This is not very clever (and fast) but currently I don't know about
+ * any other simple way of getting quota data to disk and we must get
+ * them there for userspace to be visible... */
+ if (sb->s_op->sync_fs)
+ sb->s_op->sync_fs(sb, 1);
+ sync_blockdev(sb->s_bdev);
+
+ /*
+ * Now when everything is written we can discard the pagecache so
+ * that userspace sees the changes.
+ */
+ mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
+ for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
+ if (type != -1 && cnt != type)
+ continue;
+ if (!sb_has_quota_active(sb, cnt))
+ continue;
+ mutex_lock_nested(&sb_dqopt(sb)->files[cnt]->i_mutex,
+ I_MUTEX_QUOTA);
+ truncate_inode_pages(&sb_dqopt(sb)->files[cnt]->i_data, 0);
+ mutex_unlock(&sb_dqopt(sb)->files[cnt]->i_mutex);
+ }
+ mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
+
return 0;
}
EXPORT_SYMBOL(vfs_quota_sync);
Index: linux-2.6/fs/quota/quota.c
===================================================================
--- linux-2.6.orig/fs/quota/quota.c 2010-02-16 00:16:29.030004171 +0100
+++ linux-2.6/fs/quota/quota.c 2010-02-16 00:23:57.795005847 +0100
@@ -48,44 +48,6 @@ static int check_quotactl_permission(str
return security_quotactl(cmd, type, id, sb);
}
-#ifdef CONFIG_QUOTA
-void sync_quota_sb(struct super_block *sb, int type)
-{
- int cnt;
-
- if (!sb->s_qcop || !sb->s_qcop->quota_sync)
- return;
-
- sb->s_qcop->quota_sync(sb, type);
-
- if (sb_dqopt(sb)->flags & DQUOT_QUOTA_SYS_FILE)
- return;
- /* This is not very clever (and fast) but currently I don't know about
- * any other simple way of getting quota data to disk and we must get
- * them there for userspace to be visible... */
- if (sb->s_op->sync_fs)
- sb->s_op->sync_fs(sb, 1);
- sync_blockdev(sb->s_bdev);
-
- /*
- * Now when everything is written we can discard the pagecache so
- * that userspace sees the changes.
- */
- mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
- for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
- if (type != -1 && cnt != type)
- continue;
- if (!sb_has_quota_active(sb, cnt))
- continue;
- mutex_lock_nested(&sb_dqopt(sb)->files[cnt]->i_mutex,
- I_MUTEX_QUOTA);
- truncate_inode_pages(&sb_dqopt(sb)->files[cnt]->i_data, 0);
- mutex_unlock(&sb_dqopt(sb)->files[cnt]->i_mutex);
- }
- mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
-}
-#endif
-
static int quota_sync_all(int type)
{
struct super_block *sb;
@@ -101,6 +63,9 @@ static int quota_sync_all(int type)
spin_lock(&sb_lock);
restart:
list_for_each_entry(sb, &super_blocks, s_list) {
+ if (!sb->s_qcop || !sb->s_qcop->quota_sync)
+ continue;
+
/* This test just improves performance so it needn't be
* reliable... */
for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
@@ -119,7 +84,7 @@ restart:
spin_unlock(&sb_lock);
down_read(&sb->s_umount);
if (sb->s_root)
- sync_quota_sb(sb, type);
+ sb->s_qcop->quota_sync(sb, type, 1);
up_read(&sb->s_umount);
spin_lock(&sb_lock);
if (__put_super_and_need_restart(sb))
@@ -306,8 +271,7 @@ static int do_quotactl(struct super_bloc
case Q_SYNC:
if (!sb->s_qcop->quota_sync)
return -ENOSYS;
- sync_quota_sb(sb, type);
- return 0;
+ return sb->s_qcop->quota_sync(sb, type, 1);
case Q_XQUOTAON:
case Q_XQUOTAOFF:
case Q_XQUOTARM:
Index: linux-2.6/fs/sync.c
===================================================================
--- linux-2.6.orig/fs/sync.c 2010-02-16 00:13:43.000000000 +0100
+++ linux-2.6/fs/sync.c 2010-02-16 00:21:32.283004241 +0100
@@ -34,14 +34,14 @@ static int __sync_filesystem(struct supe
if (!sb->s_bdi)
return 0;
- /* Avoid doing twice syncing and cache pruning for quota sync */
- if (!wait) {
- writeout_quota_sb(sb, -1);
- writeback_inodes_sb(sb);
- } else {
- sync_quota_sb(sb, -1);
+ if (sb->s_qcop && sb->s_qcop->quota_sync)
+ sb->s_qcop->quota_sync(sb, -1, wait);
+
+ if (wait)
sync_inodes_sb(sb);
- }
+ else
+ writeback_inodes_sb(sb);
+
if (sb->s_op->sync_fs)
sb->s_op->sync_fs(sb, wait);
return __sync_blockdev(sb->s_bdev, wait);
Index: linux-2.6/include/linux/quotaops.h
===================================================================
--- linux-2.6.orig/include/linux/quotaops.h 2010-02-16 00:16:15.361004730 +0100
+++ linux-2.6/include/linux/quotaops.h 2010-02-16 00:19:15.186253926 +0100
@@ -19,13 +19,6 @@ static inline struct quota_info *sb_dqop
/*
* declaration of quota_function calls in kernel.
*/
-void sync_quota_sb(struct super_block *sb, int type);
-static inline void writeout_quota_sb(struct super_block *sb, int type)
-{
- if (sb->s_qcop && sb->s_qcop->quota_sync)
- sb->s_qcop->quota_sync(sb, type);
-}
-
int dquot_initialize(struct inode *inode, int type);
int dquot_drop(struct inode *inode);
struct dquot *dqget(struct super_block *sb, unsigned int id, int type);
@@ -64,7 +57,7 @@ int vfs_quota_on_mount(struct super_bloc
int format_id, int type);
int vfs_quota_off(struct super_block *sb, int type, int remount);
int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags);
-int vfs_quota_sync(struct super_block *sb, int type);
+int vfs_quota_sync(struct super_block *sb, int type, int wait);
int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
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);
@@ -333,14 +326,6 @@ static inline void vfs_dq_free_inode(str
{
}
-static inline void sync_quota_sb(struct super_block *sb, int type)
-{
-}
-
-static inline void writeout_quota_sb(struct super_block *sb, int type)
-{
-}
-
static inline int vfs_dq_off(struct super_block *sb, int remount)
{
return 0;
Index: linux-2.6/include/linux/quota.h
===================================================================
--- linux-2.6.orig/include/linux/quota.h 2010-02-16 00:19:54.595004101 +0100
+++ linux-2.6/include/linux/quota.h 2010-02-16 00:20:00.855004381 +0100
@@ -324,7 +324,7 @@ struct dquot_operations {
struct quotactl_ops {
int (*quota_on)(struct super_block *, int, int, char *, int);
int (*quota_off)(struct super_block *, int, int);
- int (*quota_sync)(struct super_block *, int);
+ int (*quota_sync)(struct super_block *, int, int);
int (*get_info)(struct super_block *, int, struct if_dqinfo *);
int (*set_info)(struct super_block *, int, struct if_dqinfo *);
int (*get_dqblk)(struct super_block *, int, qid_t, struct if_dqblk *);
next prev parent reply other threads:[~2010-02-16 8:46 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-16 8:44 [PATCH 00/10] quotactl fixed and cleanups Christoph Hellwig
2010-02-16 8:44 ` [PATCH 01/10] quota: split do_quotactl Christoph Hellwig
2010-02-16 8:44 ` [PATCH 02/10] quota: clean up checks for supported quota methods Christoph Hellwig
2010-02-16 8:44 ` [PATCH 03/10] quota: special case Q_SYNC without device name Christoph Hellwig
2010-02-16 8:44 ` [PATCH 04/10] quota: simplify permission checking Christoph Hellwig
2010-02-16 8:44 ` [PATCH 05/10] quota: clean up Q_XQUOTASYNC Christoph Hellwig
2010-02-16 8:44 ` Christoph Hellwig [this message]
2010-02-16 8:44 ` [PATCH 07/10] quota: remove invalid optimization from quota_sync_all Christoph Hellwig
2010-02-16 8:44 ` [PATCH 08/10] quota: split out netlink notification support from quota.c Christoph Hellwig
2010-02-16 8:44 ` [PATCH 09/10] quota: split out compat_sys_quotactl " Christoph Hellwig
2010-02-16 8:44 ` [PATCH 10/10] quota: drop permission checks from xfs_fs_set_xstate/xfs_fs_set_xquota Christoph Hellwig
2010-02-16 8:48 ` [PATCH 00/10] quotactl fixed and cleanups Christoph Hellwig
2010-02-16 10:37 ` Steven Whitehouse
2010-02-16 18:36 ` Jan Kara
2010-02-16 19:12 ` Christoph Hellwig
2010-02-16 21:26 ` Jan Kara
2010-02-16 21:54 ` Christoph Hellwig
2010-02-17 19:37 ` Christoph Hellwig
2010-02-17 23:34 ` Jan Kara
2010-02-25 22:04 ` Alex Elder
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=20100216084651.956101538@bombadil.infradead.org \
--to=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=swhiteho@redhat.com \
--cc=xfs@oss.sgi.com \
/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).