Skip to content

Commit

Permalink
f2fs: don't pass a bio to f2fs_target_device
Browse files Browse the repository at this point in the history
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 <hch@lst.de>
Reviewed-by: Chao Yu <chao@kernel.org>
Link: https://lore.kernel.org/r/20220228124123.856027-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Mar 9, 2022
1 parent fbe7c2e commit 5189810
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions fs/f2fs/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ static void f2fs_write_end_io(struct bio *bio)
}

struct block_device *f2fs_target_device(struct f2fs_sb_info *sbi,
block_t blk_addr, struct bio *bio)
block_t blk_addr, sector_t *sector)
{
struct block_device *bdev = sbi->sb->s_bdev;
int i;
Expand All @@ -369,10 +369,9 @@ struct block_device *f2fs_target_device(struct f2fs_sb_info *sbi,
}
}
}
if (bio) {
bio_set_dev(bio, bdev);
bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(blk_addr);
}

if (sector)
*sector = SECTOR_FROM_BLOCK(blk_addr);
return bdev;
}

Expand All @@ -392,11 +391,13 @@ int f2fs_target_device_index(struct f2fs_sb_info *sbi, block_t blkaddr)
static struct bio *__bio_alloc(struct f2fs_io_info *fio, int npages)
{
struct f2fs_sb_info *sbi = fio->sbi;
struct block_device *bdev;
sector_t sector;
struct bio *bio;

bio = bio_alloc_bioset(NULL, npages, 0, GFP_NOIO, &f2fs_bioset);

f2fs_target_device(sbi, fio->new_blkaddr, bio);
bdev = f2fs_target_device(sbi, fio->new_blkaddr, &sector);
bio = bio_alloc_bioset(bdev, npages, 0, GFP_NOIO, &f2fs_bioset);
bio->bi_iter.bi_sector = sector;
if (is_read_io(fio->op)) {
bio->bi_end_io = f2fs_read_end_io;
bio->bi_private = NULL;
Expand Down Expand Up @@ -984,15 +985,15 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
struct bio *bio;
struct bio_post_read_ctx *ctx = NULL;
unsigned int post_read_steps = 0;
sector_t sector;
struct block_device *bdev = f2fs_target_device(sbi, blkaddr, &sector);

bio = bio_alloc_bioset(NULL, bio_max_segs(nr_pages), REQ_OP_READ,
bio = bio_alloc_bioset(bdev, bio_max_segs(nr_pages), REQ_OP_READ,
for_write ? GFP_NOIO : GFP_KERNEL, &f2fs_bioset);
if (!bio)
return ERR_PTR(-ENOMEM);

bio->bi_iter.bi_sector = sector;
f2fs_set_bio_crypt_ctx(bio, inode, first_idx, NULL, GFP_NOFS);

f2fs_target_device(sbi, blkaddr, bio);
bio->bi_end_io = f2fs_read_end_io;

if (fscrypt_inode_uses_fs_layer_crypto(inode))
Expand Down
2 changes: 1 addition & 1 deletion fs/f2fs/f2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3631,7 +3631,7 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio);
int f2fs_merge_page_bio(struct f2fs_io_info *fio);
void f2fs_submit_page_write(struct f2fs_io_info *fio);
struct block_device *f2fs_target_device(struct f2fs_sb_info *sbi,
block_t blk_addr, struct bio *bio);
block_t blk_addr, sector_t *sector);
int f2fs_target_device_index(struct f2fs_sb_info *sbi, block_t blkaddr);
void f2fs_set_data_blkaddr(struct dnode_of_data *dn);
void f2fs_update_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr);
Expand Down

0 comments on commit 5189810

Please sign in to comment.