ext4: call bdev_getblk() from sb_getblk_gfp()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 14 Sep 2023 15:00:10 +0000 (16:00 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 4 Oct 2023 17:32:29 +0000 (10:32 -0700)
Most of the callers of sb_getblk_gfp() already assumed that they were
passing the entire GFP flags to use.  Fix up the two callers that didn't,
and remove the __GFP_NOFAIL from them since they both appear to correctly
handle failure.

Link: https://lkml.kernel.org/r/20230914150011.843330-8-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Hui Zhu <teawater@antgroup.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/ext4/super.c
include/linux/buffer_head.h

index 268d812b0add4e2e6f9c9a69e77dd35f4a2dc7ff..c00ec159dea5e089427aa855758d68d653c55a48 100644 (file)
@@ -244,13 +244,19 @@ static struct buffer_head *__ext4_sb_bread_gfp(struct super_block *sb,
 struct buffer_head *ext4_sb_bread(struct super_block *sb, sector_t block,
                                   blk_opf_t op_flags)
 {
-       return __ext4_sb_bread_gfp(sb, block, op_flags, __GFP_MOVABLE);
+       gfp_t gfp = mapping_gfp_constraint(sb->s_bdev->bd_inode->i_mapping,
+                       ~__GFP_FS) | __GFP_MOVABLE;
+
+       return __ext4_sb_bread_gfp(sb, block, op_flags, gfp);
 }
 
 struct buffer_head *ext4_sb_bread_unmovable(struct super_block *sb,
                                            sector_t block)
 {
-       return __ext4_sb_bread_gfp(sb, block, 0, 0);
+       gfp_t gfp = mapping_gfp_constraint(sb->s_bdev->bd_inode->i_mapping,
+                       ~__GFP_FS);
+
+       return __ext4_sb_bread_gfp(sb, block, 0, gfp);
 }
 
 void ext4_sb_breadahead_unmovable(struct super_block *sb, sector_t block)
index b294e2cccbae32e28ac0df12ede5a5c2f08f7871..22f13eece71978e47ec5d0b86b63d913f530ee68 100644 (file)
@@ -368,10 +368,10 @@ static inline struct buffer_head *sb_getblk(struct super_block *sb,
        return __getblk(sb->s_bdev, block, sb->s_blocksize);
 }
 
-static inline struct buffer_head *
-sb_getblk_gfp(struct super_block *sb, sector_t block, gfp_t gfp)
+static inline struct buffer_head *sb_getblk_gfp(struct super_block *sb,
+               sector_t block, gfp_t gfp)
 {
-       return __getblk_gfp(sb->s_bdev, block, sb->s_blocksize, gfp);
+       return bdev_getblk(sb->s_bdev, block, sb->s_blocksize, gfp);
 }
 
 static inline struct buffer_head *