btrfs: return a btrfs_bio from btrfs_bio_alloc

Return the containing struct btrfs_bio instead of the less type safe
struct bio from btrfs_bio_alloc.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Christoph Hellwig
2023-03-07 17:39:44 +01:00
committed by David Sterba
parent 9dfde1b47b
commit b41bbd293e
4 changed files with 28 additions and 26 deletions

View File

@ -9928,24 +9928,24 @@ int btrfs_encoded_read_regular_fill_pages(struct btrfs_inode *inode,
.pending = ATOMIC_INIT(1),
};
unsigned long i = 0;
struct bio *bio;
struct btrfs_bio *bbio;
init_waitqueue_head(&priv.wait);
bio = btrfs_bio_alloc(BIO_MAX_VECS, REQ_OP_READ, inode,
bbio = btrfs_bio_alloc(BIO_MAX_VECS, REQ_OP_READ, inode,
btrfs_encoded_read_endio, &priv);
bio->bi_iter.bi_sector = disk_bytenr >> SECTOR_SHIFT;
bbio->bio.bi_iter.bi_sector = disk_bytenr >> SECTOR_SHIFT;
do {
size_t bytes = min_t(u64, disk_io_size, PAGE_SIZE);
if (bio_add_page(bio, pages[i], bytes, 0) < bytes) {
if (bio_add_page(&bbio->bio, pages[i], bytes, 0) < bytes) {
atomic_inc(&priv.pending);
btrfs_submit_bio(btrfs_bio(bio), 0);
btrfs_submit_bio(bbio, 0);
bio = btrfs_bio_alloc(BIO_MAX_VECS, REQ_OP_READ, inode,
btrfs_encoded_read_endio, &priv);
bio->bi_iter.bi_sector = disk_bytenr >> SECTOR_SHIFT;
bbio = btrfs_bio_alloc(BIO_MAX_VECS, REQ_OP_READ, inode,
btrfs_encoded_read_endio, &priv);
bbio->bio.bi_iter.bi_sector = disk_bytenr >> SECTOR_SHIFT;
continue;
}
@ -9955,7 +9955,7 @@ int btrfs_encoded_read_regular_fill_pages(struct btrfs_inode *inode,
} while (disk_io_size);
atomic_inc(&priv.pending);
btrfs_submit_bio(btrfs_bio(bio), 0);
btrfs_submit_bio(bbio, 0);
if (atomic_dec_return(&priv.pending))
io_wait_event(priv.wait, !atomic_read(&priv.pending));