From: Liu Bo <bo.liu@linux.alibaba.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH v2] Btrfs: set keep_lock when necessary in btrfs_defrag_leaves
Date: Thu, 26 Apr 2018 09:27:43 +0800 [thread overview]
Message-ID: <1524706063-93210-1-git-send-email-bo.liu@linux.alibaba.com> (raw)
path->keep_lock may force to lock tree root and higher nodes, and make
lock contention worse, thus it needs to be avoided as much as
possible.
In btrfs_degrag_leaves, path->keep_lock is set but @path immediatley
gets released, which is not necessary at all.
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
---
v2: update commit log with more details.
fs/btrfs/tree-defrag.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
index 3c0987ab587d..c12747904d4c 100644
--- a/fs/btrfs/tree-defrag.c
+++ b/fs/btrfs/tree-defrag.c
@@ -65,8 +65,6 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
memcpy(&key, &root->defrag_progress, sizeof(key));
}
- path->keep_locks = 1;
-
ret = btrfs_search_forward(root, &key, path, BTRFS_OLDEST_GENERATION);
if (ret < 0)
goto out;
@@ -81,6 +79,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
* a deadlock (attempting to write lock an already write locked leaf).
*/
path->lowest_level = 1;
+ path->keep_locks = 1;
wret = btrfs_search_slot(trans, root, &key, path, 0, 1);
if (wret < 0) {
--
1.8.3.1
next reply other threads:[~2018-04-26 1:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-26 1:27 Liu Bo [this message]
2018-04-26 4:57 ` [PATCH v2] Btrfs: set keep_lock when necessary in btrfs_defrag_leaves Nikolay Borisov
2018-04-26 18:06 ` David Sterba
2018-04-27 3:23 ` Liu Bo
2018-04-27 10:55 ` David Sterba
2018-04-27 5:36 ` Liu Bo
2018-05-01 13:39 ` David Sterba
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=1524706063-93210-1-git-send-email-bo.liu@linux.alibaba.com \
--to=bo.liu@linux.alibaba.com \
--cc=linux-btrfs@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