linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: <linux-fsdevel@vger.kernel.org>
Cc: Wang Shilong <wangshilong1991@gmail.com>, Jan Kara <jack@suse.cz>
Subject: [PATCH 08/27] quota: Push dqio_sem down to ->write_dqblk()
Date: Wed, 16 Aug 2017 17:41:08 +0200	[thread overview]
Message-ID: <20170816154127.7048-9-jack@suse.cz> (raw)
In-Reply-To: <20170816154127.7048-1-jack@suse.cz>

Push down acquisition of dqio_sem into ->write_dqblk() callback. It will
allow quota formats to decide whether they need it or not.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/quota/dquot.c    | 10 ++++------
 fs/quota/quota_v1.c |  3 +++
 fs/quota/quota_v2.c | 10 +++++++++-
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 70b9a6afe5a8..562f5978488f 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -412,14 +412,14 @@ int dquot_acquire(struct dquot *dquot)
 	set_bit(DQ_READ_B, &dquot->dq_flags);
 	/* Instantiate dquot if needed */
 	if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) {
-		down_write(&dqopt->dqio_sem);
 		ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
 		/* Write the info if needed */
 		if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
+			down_write(&dqopt->dqio_sem);
 			ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
 					dquot->dq_sb, dquot->dq_id.type);
+			up_write(&dqopt->dqio_sem);
 		}
-		up_write(&dqopt->dqio_sem);
 		if (ret < 0)
 			goto out_iolock;
 		if (ret2 < 0) {
@@ -456,11 +456,9 @@ int dquot_commit(struct dquot *dquot)
 	spin_unlock(&dq_list_lock);
 	/* Inactive dquot can be only if there was error during read/init
 	 * => we have better not writing it */
-	if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
-		down_write(&dqopt->dqio_sem);
+	if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
 		ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
-		up_write(&dqopt->dqio_sem);
-	} else
+	else
 		ret = -EIO;
 out_lock:
 	mutex_unlock(&dquot->dq_lock);
diff --git a/fs/quota/quota_v1.c b/fs/quota/quota_v1.c
index 12d69cda57cc..94cceb76b9a3 100644
--- a/fs/quota/quota_v1.c
+++ b/fs/quota/quota_v1.c
@@ -83,7 +83,9 @@ static int v1_commit_dqblk(struct dquot *dquot)
 	short type = dquot->dq_id.type;
 	ssize_t ret;
 	struct v1_disk_dqblk dqblk;
+	struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
 
+	down_write(&dqopt->dqio_sem);
 	v1_mem2disk_dqblk(&dqblk, &dquot->dq_dqb);
 	if (((type == USRQUOTA) && uid_eq(dquot->dq_id.uid, GLOBAL_ROOT_UID)) ||
 	    ((type == GRPQUOTA) && gid_eq(dquot->dq_id.gid, GLOBAL_ROOT_GID))) {
@@ -97,6 +99,7 @@ static int v1_commit_dqblk(struct dquot *dquot)
 		ret = dquot->dq_sb->s_op->quota_write(dquot->dq_sb, type,
 			(char *)&dqblk, sizeof(struct v1_disk_dqblk),
 			v1_dqoff(from_kqid(&init_user_ns, dquot->dq_id)));
+	up_write(&dqopt->dqio_sem);
 	if (ret != sizeof(struct v1_disk_dqblk)) {
 		quota_error(dquot->dq_sb, "dquota write failed");
 		if (ret >= 0)
diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
index b2cd34f6b3da..482733abe4ac 100644
--- a/fs/quota/quota_v2.c
+++ b/fs/quota/quota_v2.c
@@ -298,7 +298,15 @@ static int v2_read_dquot(struct dquot *dquot)
 
 static int v2_write_dquot(struct dquot *dquot)
 {
-	return qtree_write_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv, dquot);
+	struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
+	int ret;
+
+	down_write(&dqopt->dqio_sem);
+	ret = qtree_write_dquot(
+			sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv,
+			dquot);
+	up_write(&dqopt->dqio_sem);
+	return ret;
 }
 
 static int v2_release_dquot(struct dquot *dquot)
-- 
2.12.3

  parent reply	other threads:[~2017-08-16 15:41 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-16 15:41 [PATCH 0/27 v1] Quota scalability patches Jan Kara
2017-08-16 15:41 ` [PATCH 01/27] quota: Convert dqio_mutex to rwsem Jan Kara
2017-08-16 16:23   ` Andreas Dilger
2017-08-17 16:47     ` Jan Kara
2017-08-16 15:41 ` [PATCH 02/27] quota: Do more fine-grained locking in dquot_acquire() Jan Kara
2017-08-16 16:35   ` Andreas Dilger
2017-08-17 16:58     ` Jan Kara
2017-08-16 15:41 ` [PATCH 03/27] quota: Acquire dqio_sem for reading in dquot_get_next_id() Jan Kara
2017-08-16 16:37   ` Andreas Dilger
2017-08-16 15:41 ` [PATCH 04/27] quota: Acquire dqio_sem for reading in vfs_load_quota_inode() Jan Kara
2017-08-16 16:38   ` Andreas Dilger
2017-08-16 15:41 ` [PATCH 05/27] quota: Protect dquot writeout with dq_lock Jan Kara
2017-08-16 16:44   ` Andreas Dilger
2017-08-16 15:41 ` [PATCH 06/27] quota: Push dqio_sem down to ->read_dqblk() Jan Kara
2017-08-16 16:46   ` Andreas Dilger
2017-08-16 15:41 ` [PATCH 07/27] quota: Remove locking for reading from the old quota format Jan Kara
2017-08-16 16:47   ` Andreas Dilger
2017-08-16 15:41 ` Jan Kara [this message]
2017-08-16 16:48   ` [PATCH 08/27] quota: Push dqio_sem down to ->write_dqblk() Andreas Dilger
2017-08-16 15:41 ` [PATCH 09/27] quota: Do not acquire dqio_sem for dquot overwrites in v2 format Jan Kara
2017-08-16 16:49   ` Andreas Dilger
2017-08-16 15:41 ` [PATCH 10/27] quota: Remove locking for writing to the old quota format Jan Kara
2017-08-16 16:50   ` Andreas Dilger
2017-08-16 15:41 ` [PATCH 11/27] quota: Push dqio_sem down to ->release_dqblk() Jan Kara
2017-08-16 16:56   ` Andreas Dilger
2017-08-16 15:41 ` [PATCH 12/27] quota: Push dqio_sem down to ->get_next_id() Jan Kara
2017-08-16 17:08   ` Andreas Dilger
2017-08-17 17:09     ` Jan Kara
2017-08-16 15:41 ` [PATCH 13/27] quota: Push dqio_sem down to ->write_file_info() Jan Kara
2017-08-16 17:33   ` Andreas Dilger
2017-08-17 17:13     ` Jan Kara
2017-08-16 15:41 ` [PATCH 14/27] quota: Push dqio_sem down to ->read_file_info() Jan Kara
2017-08-16 17:57   ` Andreas Dilger
2017-08-16 15:41 ` [PATCH 15/27] quota: Fix error codes in v2_read_file_info() Jan Kara
2017-08-16 18:00   ` Andreas Dilger
2017-08-16 15:41 ` [PATCH 16/27] quota: Fix possible corruption of dqi_flags Jan Kara
2017-08-16 18:14   ` Andreas Dilger
2017-08-16 15:41 ` [PATCH 17/27] quota: Drop return value of mark_all_dquot_dirty() Jan Kara
2017-08-16 15:41 ` [PATCH 18/27] quota: Do not dirty bad dquots Jan Kara
2017-08-16 15:41 ` [PATCH 19/27] quota: Move locking into clear_dquot_dirty() Jan Kara
2017-08-16 18:29   ` Andreas Dilger
2017-08-16 15:41 ` [PATCH 20/27] quota: Remove dq_wait_unused from dquot Jan Kara
2017-08-16 15:41 ` [PATCH 21/27] quota: Allow disabling tracking of dirty dquots in a list Jan Kara
2017-08-16 15:41 ` [PATCH 22/27] ext4: Disable dirty list tracking of dquots when journalling quotas Jan Kara
2017-08-16 15:41 ` [PATCH 23/27] quota: Inline functions into their callsites Jan Kara
2017-08-16 15:41 ` [PATCH 24/27] quota: Inline inode_{incr,decr}_space() into callsites Jan Kara
2017-08-16 15:41 ` [PATCH 25/27] quota: Inline dquot_[re]claim_reserved_space() into callsite Jan Kara
2017-08-16 19:52   ` Andreas Dilger
2017-08-16 15:41 ` [PATCH 26/27] fs: Provide __inode_get_bytes() Jan Kara
2017-08-16 16:12   ` Andreas Dilger
2017-08-17 20:04     ` Jan Kara
2017-08-16 15:41 ` [PATCH 27/27] quota: Reduce contention on dq_data_lock Jan Kara
2017-08-16 20:17   ` Andreas Dilger
2017-08-17 20:08     ` Jan Kara
  -- strict thread matches above, loose matches on Subject: below --
2017-08-21 11:54 [PATCH 0/27 v2] Quota scalability patches Jan Kara
2017-08-21 11:54 ` [PATCH 08/27] quota: Push dqio_sem down to ->write_dqblk() 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=20170816154127.7048-9-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=wangshilong1991@gmail.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).