From: gouhao@uniontech.com
To: viro@zeniv.linux.org.uk, brauner@kernel.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] fs/buffer: adjust the order of might_sleep() in __getblk_gfp()
Date: Thu, 23 Mar 2023 17:37:52 +0800 [thread overview]
Message-ID: <20230323093752.17461-1-gouhao@uniontech.com> (raw)
From: Gou Hao <gouhao@uniontech.com>
If 'bh' is found in cache, just return directly.
might_sleep() is only required on slow paths.
Signed-off-by: Gou Hao <gouhao@uniontech.com>
---
fs/buffer.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/fs/buffer.c b/fs/buffer.c
index 9e1e2add541e..e13eff504fb5 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1371,10 +1371,11 @@ __getblk_gfp(struct block_device *bdev, sector_t block,
{
struct buffer_head *bh = __find_get_block(bdev, block, size);
+ if (bh)
+ return bh;
+
might_sleep();
- if (bh == NULL)
- bh = __getblk_slow(bdev, block, size, gfp);
- return bh;
+ return __getblk_slow(bdev, block, size, gfp);
}
EXPORT_SYMBOL(__getblk_gfp);
--
2.20.1
next reply other threads:[~2023-03-23 9:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 9:37 gouhao [this message]
2023-03-23 12:23 ` Matthew Wilcox
2023-03-24 1:52 ` gouhao
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=20230323093752.17461-1-gouhao@uniontech.com \
--to=gouhao@uniontech.com \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@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 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®