ext4: use bdev_getblk() to avoid memory reclaim in readahead path
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 14 Sep 2023 15:00:06 +0000 (16:00 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 4 Oct 2023 17:32:28 +0000 (10:32 -0700)
sb_getblk_gfp adds __GFP_NOFAIL, which is unnecessary for readahead; we're
quite comfortable with the possibility that we may not get a bh back.
Switch to bdev_getblk() which does not include __GFP_NOFAIL.

Link: https://lkml.kernel.org/r/20230914150011.843330-4-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reported-by: Hui Zhu <teawater@antgroup.com>
Closes: https://lore.kernel.org/linux-fsdevel/20230811035705.3296-1-teawaterz@linux.alibaba.com/
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/ext4/super.c

index dbebd8b..268d812 100644 (file)
@@ -255,7 +255,8 @@ struct buffer_head *ext4_sb_bread_unmovable(struct super_block *sb,
 
 void ext4_sb_breadahead_unmovable(struct super_block *sb, sector_t block)
 {
-       struct buffer_head *bh = sb_getblk_gfp(sb, block, 0);
+       struct buffer_head *bh = bdev_getblk(sb->s_bdev, block,
+                       sb->s_blocksize, GFP_NOWAIT);
 
        if (likely(bh)) {
                if (trylock_buffer(bh))