linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@stgolabs.net>
To: brauner@kernel.org
Cc: jack@suse.cz, viro@zeniv.linux.org.uk, mcgrof@kernel.org,
	dave@stgolabs.net, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/4] fs/buffer: use sleeping lookup in __getblk_slowpath()
Date: Thu, 15 May 2025 10:39:22 -0700	[thread overview]
Message-ID: <20250515173925.147823-2-dave@stgolabs.net> (raw)
In-Reply-To: <20250515173925.147823-1-dave@stgolabs.net>

Just as with the fast path, call the lookup variant depending
on the gfp flags.

Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
 fs/buffer.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index b8e1e6e325cd..5a4342881f3b 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1122,6 +1122,8 @@ static struct buffer_head *
 __getblk_slow(struct block_device *bdev, sector_t block,
 	     unsigned size, gfp_t gfp)
 {
+	bool blocking = gfpflags_allow_blocking(gfp);
+
 	/* Size must be multiple of hard sectorsize */
 	if (unlikely(size & (bdev_logical_block_size(bdev)-1) ||
 			(size < 512 || size > PAGE_SIZE))) {
@@ -1137,7 +1139,10 @@ __getblk_slow(struct block_device *bdev, sector_t block,
 	for (;;) {
 		struct buffer_head *bh;
 
-		bh = __find_get_block(bdev, block, size);
+		if (blocking)
+			bh = __find_get_block_nonatomic(bdev, block, size);
+		else
+			bh = __find_get_block(bdev, block, size);
 		if (bh)
 			return bh;
 
-- 
2.39.5


  reply	other threads:[~2025-05-15 17:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-15 17:39 [PATCH -next 0/4] fs/buffer: misc optimizations Davidlohr Bueso
2025-05-15 17:39 ` Davidlohr Bueso [this message]
2025-05-16 10:11   ` [PATCH 1/4] fs/buffer: use sleeping lookup in __getblk_slowpath() Jan Kara
2025-05-15 17:39 ` [PATCH 2/4] fs/buffer: avoid redundant lookup in getblk slowpath Davidlohr Bueso
2025-05-16 10:12   ` Jan Kara
2025-05-15 17:39 ` [PATCH 3/4] fs/buffer: remove superfluous statements Davidlohr Bueso
2025-05-16 10:13   ` Jan Kara
2025-05-15 17:39 ` [PATCH 4/4] fs/buffer: optimize discard_buffer() Davidlohr Bueso
2025-05-16 10:17   ` Jan Kara
2025-05-19 10:06 ` [PATCH -next 0/4] fs/buffer: misc optimizations Christian Brauner

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=20250515173925.147823-2-dave@stgolabs.net \
    --to=dave@stgolabs.net \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@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;
as well as URLs for NNTP newsgroup(s).