Skip to content

Commit 91e904b

Browse files
Matthew Wilcox (Oracle)opsiff
authored andcommitted
buffer: convert getblk_unmovable() and __getblk() to use bdev_getblk()
mainline inclusion from mainline-v6.7-rc1 category: bugfix Move these two functions up in the file for the benefit of the next patch, and pass in all of the GFP flags to use instead of the partial GFP flags used by __getblk_gfp(). Link: https://lkml.kernel.org/r/20230914150011.843330-6-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 c645e65) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent a2e776c commit 91e904b

1 file changed

Lines changed: 22 additions & 14 deletions

File tree

include/linux/buffer_head.h

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,28 @@ sb_breadahead(struct super_block *sb, sector_t block)
340340
__breadahead(sb->s_bdev, block, sb->s_blocksize);
341341
}
342342

343+
static inline struct buffer_head *getblk_unmovable(struct block_device *bdev,
344+
sector_t block, unsigned size)
345+
{
346+
gfp_t gfp;
347+
348+
gfp = mapping_gfp_constraint(bdev->bd_inode->i_mapping, ~__GFP_FS);
349+
gfp |= __GFP_NOFAIL;
350+
351+
return bdev_getblk(bdev, block, size, gfp);
352+
}
353+
354+
static inline struct buffer_head *__getblk(struct block_device *bdev,
355+
sector_t block, unsigned size)
356+
{
357+
gfp_t gfp;
358+
359+
gfp = mapping_gfp_constraint(bdev->bd_inode->i_mapping, ~__GFP_FS);
360+
gfp |= __GFP_MOVABLE | __GFP_NOFAIL;
361+
362+
return bdev_getblk(bdev, block, size, gfp);
363+
}
364+
343365
static inline struct buffer_head *
344366
sb_getblk(struct super_block *sb, sector_t block)
345367
{
@@ -387,20 +409,6 @@ static inline void lock_buffer(struct buffer_head *bh)
387409
__lock_buffer(bh);
388410
}
389411

390-
static inline struct buffer_head *getblk_unmovable(struct block_device *bdev,
391-
sector_t block,
392-
unsigned size)
393-
{
394-
return __getblk_gfp(bdev, block, size, 0);
395-
}
396-
397-
static inline struct buffer_head *__getblk(struct block_device *bdev,
398-
sector_t block,
399-
unsigned size)
400-
{
401-
return __getblk_gfp(bdev, block, size, __GFP_MOVABLE);
402-
}
403-
404412
static inline void bh_readahead(struct buffer_head *bh, blk_opf_t op_flags)
405413
{
406414
if (!buffer_uptodate(bh) && trylock_buffer(bh)) {

0 commit comments

Comments
 (0)