Commit 2cef0c79 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: make btrfs_split_bio work on struct btrfs_bio

btrfs_split_bio expects a btrfs_bio as argument and always allocates one.
Type both the orig_bio argument and the return value as struct btrfs_bio
to improve type safety.
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent b41bbd29
...@@ -61,30 +61,31 @@ struct btrfs_bio *btrfs_bio_alloc(unsigned int nr_vecs, blk_opf_t opf, ...@@ -61,30 +61,31 @@ struct btrfs_bio *btrfs_bio_alloc(unsigned int nr_vecs, blk_opf_t opf,
return bbio; return bbio;
} }
static struct bio *btrfs_split_bio(struct btrfs_fs_info *fs_info, static struct btrfs_bio *btrfs_split_bio(struct btrfs_fs_info *fs_info,
struct bio *orig, u64 map_length, struct btrfs_bio *orig_bbio,
bool use_append) u64 map_length, bool use_append)
{ {
struct btrfs_bio *orig_bbio = btrfs_bio(orig); struct btrfs_bio *bbio;
struct bio *bio; struct bio *bio;
if (use_append) { if (use_append) {
unsigned int nr_segs; unsigned int nr_segs;
bio = bio_split_rw(orig, &fs_info->limits, &nr_segs, bio = bio_split_rw(&orig_bbio->bio, &fs_info->limits, &nr_segs,
&btrfs_clone_bioset, map_length); &btrfs_clone_bioset, map_length);
} else { } else {
bio = bio_split(orig, map_length >> SECTOR_SHIFT, GFP_NOFS, bio = bio_split(&orig_bbio->bio, map_length >> SECTOR_SHIFT,
&btrfs_clone_bioset); GFP_NOFS, &btrfs_clone_bioset);
} }
btrfs_bio_init(btrfs_bio(bio), orig_bbio->inode, NULL, orig_bbio); bbio = btrfs_bio(bio);
btrfs_bio_init(bbio, orig_bbio->inode, NULL, orig_bbio);
btrfs_bio(bio)->file_offset = orig_bbio->file_offset; bbio->file_offset = orig_bbio->file_offset;
if (!(orig->bi_opf & REQ_BTRFS_ONE_ORDERED)) if (!(orig_bbio->bio.bi_opf & REQ_BTRFS_ONE_ORDERED))
orig_bbio->file_offset += map_length; orig_bbio->file_offset += map_length;
atomic_inc(&orig_bbio->pending_ios); atomic_inc(&orig_bbio->pending_ios);
return bio; return bbio;
} }
static void btrfs_orig_write_end_io(struct bio *bio); static void btrfs_orig_write_end_io(struct bio *bio);
...@@ -633,8 +634,8 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num) ...@@ -633,8 +634,8 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)
map_length = min(map_length, fs_info->max_zone_append_size); map_length = min(map_length, fs_info->max_zone_append_size);
if (map_length < length) { if (map_length < length) {
bio = btrfs_split_bio(fs_info, bio, map_length, use_append); bbio = btrfs_split_bio(fs_info, bbio, map_length, use_append);
bbio = btrfs_bio(bio); bio = &bbio->bio;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment