Skip to content

Commit 5189810

Browse files
Christoph Hellwigaxboe
authored andcommitted
f2fs: don't pass a bio to f2fs_target_device
Set the bdev at bio allocation time by changing the f2fs_target_device calling conventions, so that no bio needs to be passed in. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Chao Yu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent fbe7c2e commit 5189810

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

fs/f2fs/data.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ static void f2fs_write_end_io(struct bio *bio)
354354
}
355355

356356
struct block_device *f2fs_target_device(struct f2fs_sb_info *sbi,
357-
block_t blk_addr, struct bio *bio)
357+
block_t blk_addr, sector_t *sector)
358358
{
359359
struct block_device *bdev = sbi->sb->s_bdev;
360360
int i;
@@ -369,10 +369,9 @@ struct block_device *f2fs_target_device(struct f2fs_sb_info *sbi,
369369
}
370370
}
371371
}
372-
if (bio) {
373-
bio_set_dev(bio, bdev);
374-
bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(blk_addr);
375-
}
372+
373+
if (sector)
374+
*sector = SECTOR_FROM_BLOCK(blk_addr);
376375
return bdev;
377376
}
378377

@@ -392,11 +391,13 @@ int f2fs_target_device_index(struct f2fs_sb_info *sbi, block_t blkaddr)
392391
static struct bio *__bio_alloc(struct f2fs_io_info *fio, int npages)
393392
{
394393
struct f2fs_sb_info *sbi = fio->sbi;
394+
struct block_device *bdev;
395+
sector_t sector;
395396
struct bio *bio;
396397

397-
bio = bio_alloc_bioset(NULL, npages, 0, GFP_NOIO, &f2fs_bioset);
398-
399-
f2fs_target_device(sbi, fio->new_blkaddr, bio);
398+
bdev = f2fs_target_device(sbi, fio->new_blkaddr, &sector);
399+
bio = bio_alloc_bioset(bdev, npages, 0, GFP_NOIO, &f2fs_bioset);
400+
bio->bi_iter.bi_sector = sector;
400401
if (is_read_io(fio->op)) {
401402
bio->bi_end_io = f2fs_read_end_io;
402403
bio->bi_private = NULL;
@@ -984,15 +985,15 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
984985
struct bio *bio;
985986
struct bio_post_read_ctx *ctx = NULL;
986987
unsigned int post_read_steps = 0;
988+
sector_t sector;
989+
struct block_device *bdev = f2fs_target_device(sbi, blkaddr, &sector);
987990

988-
bio = bio_alloc_bioset(NULL, bio_max_segs(nr_pages), REQ_OP_READ,
991+
bio = bio_alloc_bioset(bdev, bio_max_segs(nr_pages), REQ_OP_READ,
989992
for_write ? GFP_NOIO : GFP_KERNEL, &f2fs_bioset);
990993
if (!bio)
991994
return ERR_PTR(-ENOMEM);
992-
995+
bio->bi_iter.bi_sector = sector;
993996
f2fs_set_bio_crypt_ctx(bio, inode, first_idx, NULL, GFP_NOFS);
994-
995-
f2fs_target_device(sbi, blkaddr, bio);
996997
bio->bi_end_io = f2fs_read_end_io;
997998

998999
if (fscrypt_inode_uses_fs_layer_crypto(inode))

fs/f2fs/f2fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3631,7 +3631,7 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio);
36313631
int f2fs_merge_page_bio(struct f2fs_io_info *fio);
36323632
void f2fs_submit_page_write(struct f2fs_io_info *fio);
36333633
struct block_device *f2fs_target_device(struct f2fs_sb_info *sbi,
3634-
block_t blk_addr, struct bio *bio);
3634+
block_t blk_addr, sector_t *sector);
36353635
int f2fs_target_device_index(struct f2fs_sb_info *sbi, block_t blkaddr);
36363636
void f2fs_set_data_blkaddr(struct dnode_of_data *dn);
36373637
void f2fs_update_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr);

0 commit comments

Comments
 (0)