mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-08 15:04:45 +00:00
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:
parent
9dfde1b47b
commit
b41bbd293e
@ -48,15 +48,17 @@ void btrfs_bio_init(struct btrfs_bio *bbio, struct btrfs_inode *inode,
|
|||||||
* Just like the underlying bio_alloc_bioset it will not fail as it is backed by
|
* Just like the underlying bio_alloc_bioset it will not fail as it is backed by
|
||||||
* a mempool.
|
* a mempool.
|
||||||
*/
|
*/
|
||||||
struct bio *btrfs_bio_alloc(unsigned int nr_vecs, blk_opf_t opf,
|
struct btrfs_bio *btrfs_bio_alloc(unsigned int nr_vecs, blk_opf_t opf,
|
||||||
struct btrfs_inode *inode,
|
struct btrfs_inode *inode,
|
||||||
btrfs_bio_end_io_t end_io, void *private)
|
btrfs_bio_end_io_t end_io, void *private)
|
||||||
{
|
{
|
||||||
|
struct btrfs_bio *bbio;
|
||||||
struct bio *bio;
|
struct bio *bio;
|
||||||
|
|
||||||
bio = bio_alloc_bioset(NULL, nr_vecs, opf, GFP_NOFS, &btrfs_bioset);
|
bio = bio_alloc_bioset(NULL, nr_vecs, opf, GFP_NOFS, &btrfs_bioset);
|
||||||
btrfs_bio_init(btrfs_bio(bio), inode, end_io, private);
|
bbio = btrfs_bio(bio);
|
||||||
return bio;
|
btrfs_bio_init(bbio, inode, end_io, private);
|
||||||
|
return bbio;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct bio *btrfs_split_bio(struct btrfs_fs_info *fs_info,
|
static struct bio *btrfs_split_bio(struct btrfs_fs_info *fs_info,
|
||||||
|
@ -75,9 +75,9 @@ void __cold btrfs_bioset_exit(void);
|
|||||||
|
|
||||||
void btrfs_bio_init(struct btrfs_bio *bbio, struct btrfs_inode *inode,
|
void btrfs_bio_init(struct btrfs_bio *bbio, struct btrfs_inode *inode,
|
||||||
btrfs_bio_end_io_t end_io, void *private);
|
btrfs_bio_end_io_t end_io, void *private);
|
||||||
struct bio *btrfs_bio_alloc(unsigned int nr_vecs, blk_opf_t opf,
|
struct btrfs_bio *btrfs_bio_alloc(unsigned int nr_vecs, blk_opf_t opf,
|
||||||
struct btrfs_inode *inode,
|
struct btrfs_inode *inode,
|
||||||
btrfs_bio_end_io_t end_io, void *private);
|
btrfs_bio_end_io_t end_io, void *private);
|
||||||
|
|
||||||
static inline void btrfs_bio_end_io(struct btrfs_bio *bbio, blk_status_t status)
|
static inline void btrfs_bio_end_io(struct btrfs_bio *bbio, blk_status_t status)
|
||||||
{
|
{
|
||||||
|
@ -896,13 +896,13 @@ static void alloc_new_bio(struct btrfs_inode *inode,
|
|||||||
u64 disk_bytenr, u64 file_offset)
|
u64 disk_bytenr, u64 file_offset)
|
||||||
{
|
{
|
||||||
struct btrfs_fs_info *fs_info = inode->root->fs_info;
|
struct btrfs_fs_info *fs_info = inode->root->fs_info;
|
||||||
struct bio *bio;
|
struct btrfs_bio *bbio;
|
||||||
|
|
||||||
bio = btrfs_bio_alloc(BIO_MAX_VECS, bio_ctrl->opf, inode,
|
bbio = btrfs_bio_alloc(BIO_MAX_VECS, bio_ctrl->opf, inode,
|
||||||
bio_ctrl->end_io_func, NULL);
|
bio_ctrl->end_io_func, NULL);
|
||||||
bio->bi_iter.bi_sector = disk_bytenr >> SECTOR_SHIFT;
|
bbio->bio.bi_iter.bi_sector = disk_bytenr >> SECTOR_SHIFT;
|
||||||
btrfs_bio(bio)->file_offset = file_offset;
|
bbio->file_offset = file_offset;
|
||||||
bio_ctrl->bbio = btrfs_bio(bio);
|
bio_ctrl->bbio = bbio;
|
||||||
bio_ctrl->len_to_oe_boundary = U32_MAX;
|
bio_ctrl->len_to_oe_boundary = U32_MAX;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -911,7 +911,7 @@ static void alloc_new_bio(struct btrfs_inode *inode,
|
|||||||
* them.
|
* them.
|
||||||
*/
|
*/
|
||||||
if (bio_ctrl->compress_type == BTRFS_COMPRESS_NONE &&
|
if (bio_ctrl->compress_type == BTRFS_COMPRESS_NONE &&
|
||||||
btrfs_use_zone_append(btrfs_bio(bio))) {
|
btrfs_use_zone_append(bbio)) {
|
||||||
struct btrfs_ordered_extent *ordered;
|
struct btrfs_ordered_extent *ordered;
|
||||||
|
|
||||||
ordered = btrfs_lookup_ordered_extent(inode, file_offset);
|
ordered = btrfs_lookup_ordered_extent(inode, file_offset);
|
||||||
@ -930,8 +930,8 @@ static void alloc_new_bio(struct btrfs_inode *inode,
|
|||||||
* to always be set on the last added/replaced device.
|
* to always be set on the last added/replaced device.
|
||||||
* This is a bit odd but has been like that for a long time.
|
* This is a bit odd but has been like that for a long time.
|
||||||
*/
|
*/
|
||||||
bio_set_dev(bio, fs_info->fs_devices->latest_dev->bdev);
|
bio_set_dev(&bbio->bio, fs_info->fs_devices->latest_dev->bdev);
|
||||||
wbc_init_bio(bio_ctrl->wbc, bio);
|
wbc_init_bio(bio_ctrl->wbc, &bbio->bio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9928,24 +9928,24 @@ int btrfs_encoded_read_regular_fill_pages(struct btrfs_inode *inode,
|
|||||||
.pending = ATOMIC_INIT(1),
|
.pending = ATOMIC_INIT(1),
|
||||||
};
|
};
|
||||||
unsigned long i = 0;
|
unsigned long i = 0;
|
||||||
struct bio *bio;
|
struct btrfs_bio *bbio;
|
||||||
|
|
||||||
init_waitqueue_head(&priv.wait);
|
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);
|
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 {
|
do {
|
||||||
size_t bytes = min_t(u64, disk_io_size, PAGE_SIZE);
|
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);
|
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,
|
bbio = btrfs_bio_alloc(BIO_MAX_VECS, REQ_OP_READ, inode,
|
||||||
btrfs_encoded_read_endio, &priv);
|
btrfs_encoded_read_endio, &priv);
|
||||||
bio->bi_iter.bi_sector = disk_bytenr >> SECTOR_SHIFT;
|
bbio->bio.bi_iter.bi_sector = disk_bytenr >> SECTOR_SHIFT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9955,7 +9955,7 @@ int btrfs_encoded_read_regular_fill_pages(struct btrfs_inode *inode,
|
|||||||
} while (disk_io_size);
|
} while (disk_io_size);
|
||||||
|
|
||||||
atomic_inc(&priv.pending);
|
atomic_inc(&priv.pending);
|
||||||
btrfs_submit_bio(btrfs_bio(bio), 0);
|
btrfs_submit_bio(bbio, 0);
|
||||||
|
|
||||||
if (atomic_dec_return(&priv.pending))
|
if (atomic_dec_return(&priv.pending))
|
||||||
io_wait_event(priv.wait, !atomic_read(&priv.pending));
|
io_wait_event(priv.wait, !atomic_read(&priv.pending));
|
||||||
|
Loading…
Reference in New Issue
Block a user