mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baokun Li <libaokun1@huawei.com>
To: <jack@suse.cz>
Cc: <linux-fsdevel@vger.kernel.org>, <linux-ext4@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <yi.zhang@huawei.com>,
	<yangerkun@huawei.com>, <chengzhihao1@huawei.com>,
	<yukuai3@huawei.com>, <libaokun1@huawei.com>
Subject: [PATCH v2 6/7] quota: simplify drop_dquot_ref()
Date: Wed, 28 Jun 2023 21:21:54 +0800	[thread overview]
Message-ID: <20230628132155.1560425-7-libaokun1@huawei.com> (raw)
In-Reply-To: <20230628132155.1560425-1-libaokun1@huawei.com>

Now when dqput() drops the last reference count, it will call
synchronize_srcu(&dquot_srcu) in quota_release_workfn() to ensure that
no other user will use the dquot after the last reference count is dropped,
so we don't need to call synchronize_srcu(&dquot_srcu) in drop_dquot_ref()
and remove the corresponding logic directly to simplify the code.

Signed-off-by: Baokun Li <libaokun1@huawei.com>
---
 fs/quota/dquot.c | 33 ++++++---------------------------
 1 file changed, 6 insertions(+), 27 deletions(-)

diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index e8e702ac64e5..df028fb2ce72 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -1090,8 +1090,7 @@ static int add_dquot_ref(struct super_block *sb, int type)
  * Remove references to dquots from inode and add dquot to list for freeing
  * if we have the last reference to dquot
  */
-static void remove_inode_dquot_ref(struct inode *inode, int type,
-				   struct list_head *tofree_head)
+static void remove_inode_dquot_ref(struct inode *inode, int type)
 {
 	struct dquot **dquots = i_dquot(inode);
 	struct dquot *dquot = dquots[type];
@@ -1100,21 +1099,7 @@ static void remove_inode_dquot_ref(struct inode *inode, int type,
 		return;
 
 	dquots[type] = NULL;
-	if (list_empty(&dquot->dq_free)) {
-		/*
-		 * The inode still has reference to dquot so it can't be in the
-		 * free list
-		 */
-		spin_lock(&dq_list_lock);
-		list_add(&dquot->dq_free, tofree_head);
-		spin_unlock(&dq_list_lock);
-	} else {
-		/*
-		 * Dquot is already in a list to put so we won't drop the last
-		 * reference here.
-		 */
-		dqput(dquot);
-	}
+	dqput(dquot);
 }
 
 /*
@@ -1137,8 +1122,7 @@ static void put_dquot_list(struct list_head *tofree_head)
 	}
 }
 
-static void remove_dquot_ref(struct super_block *sb, int type,
-		struct list_head *tofree_head)
+static void remove_dquot_ref(struct super_block *sb, int type)
 {
 	struct inode *inode;
 #ifdef CONFIG_QUOTA_DEBUG
@@ -1159,7 +1143,7 @@ static void remove_dquot_ref(struct super_block *sb, int type,
 			if (unlikely(inode_get_rsv_space(inode) > 0))
 				reserved = 1;
 #endif
-			remove_inode_dquot_ref(inode, type, tofree_head);
+			remove_inode_dquot_ref(inode, type);
 		}
 		spin_unlock(&dq_data_lock);
 	}
@@ -1176,13 +1160,8 @@ static void remove_dquot_ref(struct super_block *sb, int type,
 /* Gather all references from inodes and drop them */
 static void drop_dquot_ref(struct super_block *sb, int type)
 {
-	LIST_HEAD(tofree_head);
-
-	if (sb->dq_op) {
-		remove_dquot_ref(sb, type, &tofree_head);
-		synchronize_srcu(&dquot_srcu);
-		put_dquot_list(&tofree_head);
-	}
+	if (sb->dq_op)
+		remove_dquot_ref(sb, type);
 }
 
 static inline
-- 
2.31.1


  parent reply	other threads:[~2023-06-28 13:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28 13:21 [PATCH v2 0/7] quota: fix race condition between dqput() and dquot_mark_dquot_dirty() Baokun Li
2023-06-28 13:21 ` [PATCH v2 1/7] quota: factor out dquot_write_dquot() Baokun Li
2023-06-28 13:21 ` [PATCH v2 2/7] quota: add new global dquot list releasing_dquots Baokun Li
2023-06-29 10:29   ` Jan Kara
2023-06-29 11:10     ` Baokun Li
2023-06-28 13:21 ` [PATCH v2 3/7] quota: rename dquot_active() to inode_dquot_active() Baokun Li
2023-06-29 10:24   ` Jan Kara
2023-06-29 11:14     ` Baokun Li
2023-06-28 13:21 ` [PATCH v2 4/7] quota: add new helper dquot_active() Baokun Li
2023-06-28 13:21 ` [PATCH v2 5/7] quota: fix dqput() to follow the guarantees dquot_srcu should provide Baokun Li
2023-06-29 10:59   ` Jan Kara
2023-06-29 11:47     ` Baokun Li
2023-06-29 14:33       ` Jan Kara
2023-06-30  7:45         ` Baokun Li
2023-06-28 13:21 ` Baokun Li [this message]
2023-06-29 11:08   ` [PATCH v2 6/7] quota: simplify drop_dquot_ref() Jan Kara
2023-06-29 12:13     ` Baokun Li
2023-06-29 14:09       ` Jan Kara
2023-06-29 14:16         ` Baokun Li
2023-06-28 13:21 ` [PATCH v2 7/7] quota: remove unused function put_dquot_list() Baokun Li
2023-06-29 11:05   ` Jan Kara
2023-06-29 12:18     ` Baokun Li

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=20230628132155.1560425-7-libaokun1@huawei.com \
    --to=libaokun1@huawei.com \
    --cc=chengzhihao1@huawei.com \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.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

all inboxes | Powered by JetHome®