btrfs: pass bytes to btrfs_bio_alloc
Most callers of btrfs_bio_alloc convert from bytes to sectors. Hide that in the helper and simplify the logic in the callsers. Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
9886b17433
commit
c821e7f3da
|
@ -306,7 +306,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
|
||||||
|
|
||||||
bdev = fs_info->fs_devices->latest_bdev;
|
bdev = fs_info->fs_devices->latest_bdev;
|
||||||
|
|
||||||
bio = btrfs_bio_alloc(bdev, first_byte >> 9);
|
bio = btrfs_bio_alloc(bdev, first_byte);
|
||||||
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
|
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
|
||||||
bio->bi_private = cb;
|
bio->bi_private = cb;
|
||||||
bio->bi_end_io = end_compressed_bio_write;
|
bio->bi_end_io = end_compressed_bio_write;
|
||||||
|
@ -353,7 +353,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
|
||||||
|
|
||||||
bio_put(bio);
|
bio_put(bio);
|
||||||
|
|
||||||
bio = btrfs_bio_alloc(bdev, first_byte >> 9);
|
bio = btrfs_bio_alloc(bdev, first_byte);
|
||||||
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
|
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
|
||||||
bio->bi_private = cb;
|
bio->bi_private = cb;
|
||||||
bio->bi_end_io = end_compressed_bio_write;
|
bio->bi_end_io = end_compressed_bio_write;
|
||||||
|
@ -596,7 +596,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
|
||||||
/* include any pages we added in add_ra-bio_pages */
|
/* include any pages we added in add_ra-bio_pages */
|
||||||
cb->len = bio->bi_iter.bi_size;
|
cb->len = bio->bi_iter.bi_size;
|
||||||
|
|
||||||
comp_bio = btrfs_bio_alloc(bdev, cur_disk_byte >> 9);
|
comp_bio = btrfs_bio_alloc(bdev, cur_disk_byte);
|
||||||
bio_set_op_attrs (comp_bio, REQ_OP_READ, 0);
|
bio_set_op_attrs (comp_bio, REQ_OP_READ, 0);
|
||||||
comp_bio->bi_private = cb;
|
comp_bio->bi_private = cb;
|
||||||
comp_bio->bi_end_io = end_compressed_bio_read;
|
comp_bio->bi_end_io = end_compressed_bio_read;
|
||||||
|
@ -647,7 +647,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
|
||||||
|
|
||||||
bio_put(comp_bio);
|
bio_put(comp_bio);
|
||||||
|
|
||||||
comp_bio = btrfs_bio_alloc(bdev, cur_disk_byte >> 9);
|
comp_bio = btrfs_bio_alloc(bdev, cur_disk_byte);
|
||||||
bio_set_op_attrs(comp_bio, REQ_OP_READ, 0);
|
bio_set_op_attrs(comp_bio, REQ_OP_READ, 0);
|
||||||
comp_bio->bi_private = cb;
|
comp_bio->bi_private = cb;
|
||||||
comp_bio->bi_end_io = end_compressed_bio_read;
|
comp_bio->bi_end_io = end_compressed_bio_read;
|
||||||
|
|
|
@ -2658,14 +2658,14 @@ readpage_ok:
|
||||||
* never fail. We're returning a bio right now but you can call btrfs_io_bio
|
* never fail. We're returning a bio right now but you can call btrfs_io_bio
|
||||||
* for the appropriate container_of magic
|
* for the appropriate container_of magic
|
||||||
*/
|
*/
|
||||||
struct bio *btrfs_bio_alloc(struct block_device *bdev, u64 first_sector)
|
struct bio *btrfs_bio_alloc(struct block_device *bdev, u64 first_byte)
|
||||||
{
|
{
|
||||||
struct btrfs_io_bio *btrfs_bio;
|
struct btrfs_io_bio *btrfs_bio;
|
||||||
struct bio *bio;
|
struct bio *bio;
|
||||||
|
|
||||||
bio = bio_alloc_bioset(GFP_NOFS, BIO_MAX_PAGES, btrfs_bioset);
|
bio = bio_alloc_bioset(GFP_NOFS, BIO_MAX_PAGES, btrfs_bioset);
|
||||||
bio->bi_bdev = bdev;
|
bio->bi_bdev = bdev;
|
||||||
bio->bi_iter.bi_sector = first_sector;
|
bio->bi_iter.bi_sector = first_byte >> 9;
|
||||||
btrfs_bio = btrfs_io_bio(bio);
|
btrfs_bio = btrfs_io_bio(bio);
|
||||||
btrfs_bio->csum = NULL;
|
btrfs_bio->csum = NULL;
|
||||||
btrfs_bio->csum_allocated = NULL;
|
btrfs_bio->csum_allocated = NULL;
|
||||||
|
@ -2799,7 +2799,7 @@ static int submit_extent_page(int op, int op_flags, struct extent_io_tree *tree,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bio = btrfs_bio_alloc(bdev, sector);
|
bio = btrfs_bio_alloc(bdev, sector << 9);
|
||||||
bio_add_page(bio, page, page_size, offset);
|
bio_add_page(bio, page, page_size, offset);
|
||||||
bio->bi_end_io = end_io_func;
|
bio->bi_end_io = end_io_func;
|
||||||
bio->bi_private = tree;
|
bio->bi_private = tree;
|
||||||
|
|
|
@ -462,7 +462,7 @@ void extent_clear_unlock_delalloc(struct inode *inode, u64 start, u64 end,
|
||||||
u64 delalloc_end, struct page *locked_page,
|
u64 delalloc_end, struct page *locked_page,
|
||||||
unsigned bits_to_clear,
|
unsigned bits_to_clear,
|
||||||
unsigned long page_ops);
|
unsigned long page_ops);
|
||||||
struct bio *btrfs_bio_alloc(struct block_device *bdev, u64 first_sector);
|
struct bio *btrfs_bio_alloc(struct block_device *bdev, u64 first_byte);
|
||||||
struct bio *btrfs_io_bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs);
|
struct bio *btrfs_io_bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs);
|
||||||
struct bio *btrfs_bio_clone(struct bio *bio);
|
struct bio *btrfs_bio_clone(struct bio *bio);
|
||||||
struct bio *btrfs_bio_clone_partial(struct bio *orig, int offset, int size);
|
struct bio *btrfs_bio_clone_partial(struct bio *orig, int offset, int size);
|
||||||
|
|
Loading…
Reference in New Issue