Skip to content

Commit 2814a7d

Browse files
Davidlohr Buesobrauner
authored andcommitted
fs/buffer: introduce sleeping flavors for pagecache lookups
Add __find_get_block_nonatomic() and sb_find_get_block_nonatomic() calls for which users will be converted where safe. These versions will take the folio lock instead of the mapping's private_lock. Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net> Link: https://kdevops.org/ext4/v6.15-rc2.html # [0] Link: https://lore.kernel.org/all/aAAEvcrmREWa1SKF@bombadil.infradead.org/ # [1] Link: https://lore.kernel.org/20250418015921.132400-3-dave@stgolabs.net Tested-by: kdevops@lists.linux.dev Reviewed-by: Luis Chamberlain <mcgrof@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 7ffe3de commit 2814a7d

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

fs/buffer.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,15 @@ __find_get_block(struct block_device *bdev, sector_t block, unsigned size)
14141414
}
14151415
EXPORT_SYMBOL(__find_get_block);
14161416

1417+
/* same as __find_get_block() but allows sleeping contexts */
1418+
struct buffer_head *
1419+
__find_get_block_nonatomic(struct block_device *bdev, sector_t block,
1420+
unsigned size)
1421+
{
1422+
return find_get_block_common(bdev, block, size, false);
1423+
}
1424+
EXPORT_SYMBOL(__find_get_block_nonatomic);
1425+
14171426
/**
14181427
* bdev_getblk - Get a buffer_head in a block device's buffer cache.
14191428
* @bdev: The block device.

include/linux/buffer_head.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ void __wait_on_buffer(struct buffer_head *);
222222
wait_queue_head_t *bh_waitq_head(struct buffer_head *bh);
223223
struct buffer_head *__find_get_block(struct block_device *bdev, sector_t block,
224224
unsigned size);
225+
struct buffer_head *__find_get_block_nonatomic(struct block_device *bdev,
226+
sector_t block, unsigned size);
225227
struct buffer_head *bdev_getblk(struct block_device *bdev, sector_t block,
226228
unsigned size, gfp_t gfp);
227229
void __brelse(struct buffer_head *);
@@ -397,6 +399,12 @@ sb_find_get_block(struct super_block *sb, sector_t block)
397399
return __find_get_block(sb->s_bdev, block, sb->s_blocksize);
398400
}
399401

402+
static inline struct buffer_head *
403+
sb_find_get_block_nonatomic(struct super_block *sb, sector_t block)
404+
{
405+
return __find_get_block_nonatomic(sb->s_bdev, block, sb->s_blocksize);
406+
}
407+
400408
static inline void
401409
map_bh(struct buffer_head *bh, struct super_block *sb, sector_t block)
402410
{

0 commit comments

Comments
 (0)