Skip to content

Commit 4bc980f

Browse files
Matthew Wilcox (Oracle)opsiff
authored andcommitted
ext4: call bdev_getblk() from sb_getblk_gfp()
mainline inclusion from mainline-v6.7-rc1 category: bugfix 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> (cherry picked from commit 8a83ac5) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 2650b47 commit 4bc980f

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

fs/ext4/super.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,19 @@ static struct buffer_head *__ext4_sb_bread_gfp(struct super_block *sb,
251251
struct buffer_head *ext4_sb_bread(struct super_block *sb, sector_t block,
252252
blk_opf_t op_flags)
253253
{
254-
return __ext4_sb_bread_gfp(sb, block, op_flags, __GFP_MOVABLE);
254+
gfp_t gfp = mapping_gfp_constraint(sb->s_bdev->bd_inode->i_mapping,
255+
~__GFP_FS) | __GFP_MOVABLE;
256+
257+
return __ext4_sb_bread_gfp(sb, block, op_flags, gfp);
255258
}
256259

257260
struct buffer_head *ext4_sb_bread_unmovable(struct super_block *sb,
258261
sector_t block)
259262
{
260-
return __ext4_sb_bread_gfp(sb, block, 0, 0);
263+
gfp_t gfp = mapping_gfp_constraint(sb->s_bdev->bd_inode->i_mapping,
264+
~__GFP_FS);
265+
266+
return __ext4_sb_bread_gfp(sb, block, 0, gfp);
261267
}
262268

263269
void ext4_sb_breadahead_unmovable(struct super_block *sb, sector_t block)

include/linux/buffer_head.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,10 @@ static inline struct buffer_head *sb_getblk(struct super_block *sb,
368368
return __getblk(sb->s_bdev, block, sb->s_blocksize);
369369
}
370370

371-
static inline struct buffer_head *
372-
sb_getblk_gfp(struct super_block *sb, sector_t block, gfp_t gfp)
371+
static inline struct buffer_head *sb_getblk_gfp(struct super_block *sb,
372+
sector_t block, gfp_t gfp)
373373
{
374-
return __getblk_gfp(sb->s_bdev, block, sb->s_blocksize, gfp);
374+
return bdev_getblk(sb->s_bdev, block, sb->s_blocksize, gfp);
375375
}
376376

377377
static inline struct buffer_head *

0 commit comments

Comments
 (0)