From: Steven Whitehouse <swhiteho@redhat.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
Curt Wohlgemuth <curtw@google.com>,
Al Viro <viro@ZenIV.linux.org.uk>
Subject: Re: [PATCH 3/5] quota: Split dquot_quota_sync() to writeback and cache flushing part
Date: Wed, 27 Jul 2011 09:26:06 +0100 [thread overview]
Message-ID: <1311755166.2801.2.camel@menhir> (raw)
In-Reply-To: <1311719886-1130-4-git-send-email-jack@suse.cz>
Hi,
On Wed, 2011-07-27 at 00:38 +0200, Jan Kara wrote:
> Split off part of dquot_quota_sync() which writes dquots into a quota file
> to a separate function. In the next patch we will use the function from
> filesystems and we do not want to abuse ->quota_sync quotactl callback more
> than necessary.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
Acked-by: Steven Whitehouse <swhiteho@redhat.com>
Steve.
> ---
> fs/gfs2/quota.c | 4 ++--
> fs/gfs2/quota.h | 2 +-
> fs/gfs2/super.c | 2 +-
> fs/gfs2/sys.c | 2 +-
> fs/quota/dquot.c | 35 ++++++++++++++++++++++++++---------
> fs/quota/quota.c | 4 ++--
> fs/sync.c | 2 +-
> include/linux/quota.h | 2 +-
> include/linux/quotaops.h | 3 ++-
> 9 files changed, 37 insertions(+), 19 deletions(-)
>
> diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
> index 42e8d23..2ca3c6a 100644
> --- a/fs/gfs2/quota.c
> +++ b/fs/gfs2/quota.c
> @@ -1122,7 +1122,7 @@ void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
> }
> }
>
> -int gfs2_quota_sync(struct super_block *sb, int type, int wait)
> +int gfs2_quota_sync(struct super_block *sb, int type)
> {
> struct gfs2_sbd *sdp = sb->s_fs_info;
> struct gfs2_quota_data **qda;
> @@ -1168,7 +1168,7 @@ int gfs2_quota_sync(struct super_block *sb, int type, int wait)
>
> static int gfs2_quota_sync_timeo(struct super_block *sb, int type)
> {
> - return gfs2_quota_sync(sb, type, 0);
> + return gfs2_quota_sync(sb, type);
> }
>
> int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id)
> diff --git a/fs/gfs2/quota.h b/fs/gfs2/quota.h
> index 90bf1c3..f25d98b 100644
> --- a/fs/gfs2/quota.h
> +++ b/fs/gfs2/quota.h
> @@ -26,7 +26,7 @@ extern int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid);
> extern void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
> u32 uid, u32 gid);
>
> -extern int gfs2_quota_sync(struct super_block *sb, int type, int wait);
> +extern int gfs2_quota_sync(struct super_block *sb, int type);
> extern int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id);
>
> extern int gfs2_quota_init(struct gfs2_sbd *sdp);
> diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
> index ed540e7..e361610 100644
> --- a/fs/gfs2/super.c
> +++ b/fs/gfs2/super.c
> @@ -807,7 +807,7 @@ static int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
> int error;
>
> flush_workqueue(gfs2_delete_workqueue);
> - gfs2_quota_sync(sdp->sd_vfs, 0, 1);
> + gfs2_quota_sync(sdp->sd_vfs, 0);
> gfs2_statfs_sync(sdp->sd_vfs, 0);
>
> error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED, GL_NOCACHE,
> diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
> index e20eab3..b595462 100644
> --- a/fs/gfs2/sys.c
> +++ b/fs/gfs2/sys.c
> @@ -168,7 +168,7 @@ static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
> if (simple_strtol(buf, NULL, 0) != 1)
> return -EINVAL;
>
> - gfs2_quota_sync(sdp->sd_vfs, 0, 1);
> + gfs2_quota_sync(sdp->sd_vfs, 0);
> return len;
> }
>
> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> index 5b572c8..35c4a47 100644
> --- a/fs/quota/dquot.c
> +++ b/fs/quota/dquot.c
> @@ -595,12 +595,14 @@ out:
> }
> EXPORT_SYMBOL(dquot_scan_active);
>
> -int dquot_quota_sync(struct super_block *sb, int type, int wait)
> +/* Write all dquot structures to quota files */
> +int dquot_writeback_dquots(struct super_block *sb, int type)
> {
> struct list_head *dirty;
> struct dquot *dquot;
> struct quota_info *dqopt = sb_dqopt(sb);
> int cnt;
> + int err, ret = 0;
>
> mutex_lock(&dqopt->dqonoff_mutex);
> for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
> @@ -624,7 +626,9 @@ int dquot_quota_sync(struct super_block *sb, int type, int wait)
> atomic_inc(&dquot->dq_count);
> spin_unlock(&dq_list_lock);
> dqstats_inc(DQST_LOOKUPS);
> - sb->dq_op->write_dquot(dquot);
> + err = sb->dq_op->write_dquot(dquot);
> + if (!ret && err)
> + err = ret;
> dqput(dquot);
> spin_lock(&dq_list_lock);
> }
> @@ -638,7 +642,21 @@ int dquot_quota_sync(struct super_block *sb, int type, int wait)
> dqstats_inc(DQST_SYNCS);
> mutex_unlock(&dqopt->dqonoff_mutex);
>
> - if (!wait || (sb_dqopt(sb)->flags & DQUOT_QUOTA_SYS_FILE))
> + return ret;
> +}
> +EXPORT_SYMBOL(dquot_writeback_dquots);
> +
> +/* Write all dquot structures to disk and make them visible from userspace */
> +int dquot_quota_sync(struct super_block *sb, int type)
> +{
> + struct quota_info *dqopt = sb_dqopt(sb);
> + int cnt;
> + int ret;
> +
> + ret = dquot_writeback_dquots(sb, type);
> + if (ret)
> + return ret;
> + if (dqopt->flags & DQUOT_QUOTA_SYS_FILE)
> return 0;
>
> /* This is not very clever (and fast) but currently I don't know about
> @@ -652,18 +670,17 @@ int dquot_quota_sync(struct super_block *sb, int type, int wait)
> * Now when everything is written we can discard the pagecache so
> * that userspace sees the changes.
> */
> - mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
> + mutex_lock(&dqopt->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_lock_nested(&dqopt->files[cnt]->i_mutex, I_MUTEX_QUOTA);
> + truncate_inode_pages(&dqopt->files[cnt]->i_data, 0);
> + mutex_unlock(&dqopt->files[cnt]->i_mutex);
> }
> - mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
> + mutex_unlock(&dqopt->dqonoff_mutex);
>
> return 0;
> }
> diff --git a/fs/quota/quota.c b/fs/quota/quota.c
> index b34bdb2..76b8012 100644
> --- a/fs/quota/quota.c
> +++ b/fs/quota/quota.c
> @@ -48,7 +48,7 @@ static int check_quotactl_permission(struct super_block *sb, int type, int cmd,
> static void quota_sync_one(struct super_block *sb, void *arg)
> {
> if (sb->s_qcop && sb->s_qcop->quota_sync)
> - sb->s_qcop->quota_sync(sb, *(int *)arg, 1);
> + sb->s_qcop->quota_sync(sb, *(int *)arg);
> }
>
> static int quota_sync_all(int type)
> @@ -271,7 +271,7 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,
> case Q_SYNC:
> if (!sb->s_qcop->quota_sync)
> return -ENOSYS;
> - return sb->s_qcop->quota_sync(sb, type, 1);
> + return sb->s_qcop->quota_sync(sb, type);
> case Q_XQUOTAON:
> case Q_XQUOTAOFF:
> case Q_XQUOTARM:
> diff --git a/fs/sync.c b/fs/sync.c
> index 2f5bd52..2b7d569 100644
> --- a/fs/sync.c
> +++ b/fs/sync.c
> @@ -31,7 +31,7 @@
> static void __sync_filesystem(struct super_block *sb, int wait)
> {
> if (sb->s_qcop && sb->s_qcop->quota_sync)
> - sb->s_qcop->quota_sync(sb, -1, wait);
> + sb->s_qcop->quota_sync(sb, -1);
>
> if (wait)
> sync_inodes_sb(sb);
> diff --git a/include/linux/quota.h b/include/linux/quota.h
> index 9a85412..86173d6 100644
> --- a/include/linux/quota.h
> +++ b/include/linux/quota.h
> @@ -329,7 +329,7 @@ struct quotactl_ops {
> int (*quota_on)(struct super_block *, int, int, struct path *);
> int (*quota_on_meta)(struct super_block *, int, int);
> int (*quota_off)(struct super_block *, int);
> - int (*quota_sync)(struct super_block *, int, int);
> + int (*quota_sync)(struct super_block *, 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 fs_disk_quota *);
> diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
> index 26f9e36..aba7578 100644
> --- a/include/linux/quotaops.h
> +++ b/include/linux/quotaops.h
> @@ -83,7 +83,8 @@ int dquot_quota_on(struct super_block *sb, int type, int format_id,
> int dquot_quota_on_mount(struct super_block *sb, char *qf_name,
> int format_id, int type);
> int dquot_quota_off(struct super_block *sb, int type);
> -int dquot_quota_sync(struct super_block *sb, int type, int wait);
> +int dquot_writeback_dquots(struct super_block *sb, int type);
> +int dquot_quota_sync(struct super_block *sb, int type);
> int dquot_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
> int dquot_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
> int dquot_get_dqblk(struct super_block *sb, int type, qid_t id,
next prev parent reply other threads:[~2011-07-27 8:24 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-26 22:38 [PATCH 0/5 v2] Improve sync(2) handling Jan Kara
2011-07-26 22:38 ` [PATCH 1/5] vfs: Make sync(1) writeout also block device inodes Jan Kara
2011-07-27 9:44 ` Christoph Hellwig
2011-07-28 20:13 ` Jan Kara
2011-07-26 22:38 ` [PATCH 2/5] vfs: Move noop_backing_dev_info check from sync into writeback Jan Kara
2011-07-27 9:44 ` Christoph Hellwig
2011-07-26 22:38 ` [PATCH 3/5] quota: Split dquot_quota_sync() to writeback and cache flushing part Jan Kara
2011-07-27 8:26 ` Steven Whitehouse [this message]
2011-07-27 9:45 ` Christoph Hellwig
2011-07-26 22:38 ` [PATCH 4/5] quota: Move quota syncing to ->sync_fs method Jan Kara
2011-07-27 8:32 ` Steven Whitehouse
2011-07-27 9:46 ` Christoph Hellwig
2011-07-27 13:44 ` Dave Kleikamp
2011-07-26 22:38 ` [PATCH 5/5] vfs: Avoid unnecessary WB_SYNC_NONE writeback during sync(1) Jan Kara
2011-07-27 9:52 ` Christoph Hellwig
2011-07-28 17:42 ` Jan Kara
2011-07-28 20:37 ` Christoph Hellwig
2011-07-28 21:20 ` Curt Wohlgemuth
2011-07-29 11:09 ` Christoph Hellwig
2011-09-28 15:00 ` [PATCH 0/5 v2] Improve sync(2) handling Christoph Hellwig
2011-10-06 22:20 ` 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=1311755166.2801.2.camel@menhir \
--to=swhiteho@redhat.com \
--cc=curtw@google.com \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.