From: Davidlohr Bueso Date: Thu, 15 May 2025 17:39:23 +0000 (-0700) Subject: fs/buffer: avoid redundant lookup in getblk slowpath X-Git-Tag: v6.15~11^2^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98a6ca16333e10ce450b0ab516f4c3e5fe52ef31;p=thirdparty%2Fkernel%2Flinux.git fs/buffer: avoid redundant lookup in getblk slowpath __getblk_slow() already implies failing a first lookup as the fastpath, so try to create the buffers immediately and avoid the redundant lookup. This saves 5-10% of the total cost/latency of the slowpath. Signed-off-by: Davidlohr Bueso Link: https://lore.kernel.org/20250515173925.147823-3-dave@stgolabs.net Reviewed-by: Jan Kara Signed-off-by: Christian Brauner --- diff --git a/fs/buffer.c b/fs/buffer.c index 8563d949cd2c8..23773b7505241 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1139,15 +1139,15 @@ __getblk_slow(struct block_device *bdev, sector_t block, for (;;) { struct buffer_head *bh; + if (!grow_buffers(bdev, block, size, gfp)) + return NULL; + if (blocking) bh = __find_get_block_nonatomic(bdev, block, size); else bh = __find_get_block(bdev, block, size); if (bh) return bh; - - if (!grow_buffers(bdev, block, size, gfp)) - return NULL; } }