Commit 81a75f67 authored by Mike Christie's avatar Mike Christie Committed by Jens Axboe

btrfs: use bio fields for op and flags

The bio REQ_OP and bi_rw rq_flag_bits are now always setup, so there is
no need to pass around the rq_flag_bits bits too. btrfs users should
should access the bio insead.
Signed-off-by: default avatarMike Christie <mchristi@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent b3d3fa51
...@@ -374,7 +374,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -374,7 +374,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
page = compressed_pages[pg_index]; page = compressed_pages[pg_index];
page->mapping = inode->i_mapping; page->mapping = inode->i_mapping;
if (bio->bi_iter.bi_size) if (bio->bi_iter.bi_size)
ret = io_tree->ops->merge_bio_hook(WRITE, page, 0, ret = io_tree->ops->merge_bio_hook(page, 0,
PAGE_SIZE, PAGE_SIZE,
bio, 0); bio, 0);
else else
...@@ -402,7 +402,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -402,7 +402,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
} }
ret = btrfs_map_bio(root, WRITE, bio, 0, 1); ret = btrfs_map_bio(root, bio, 0, 1);
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
bio_put(bio); bio_put(bio);
...@@ -433,7 +433,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -433,7 +433,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
} }
ret = btrfs_map_bio(root, WRITE, bio, 0, 1); ret = btrfs_map_bio(root, bio, 0, 1);
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
bio_put(bio); bio_put(bio);
...@@ -659,7 +659,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, ...@@ -659,7 +659,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
page->index = em_start >> PAGE_SHIFT; page->index = em_start >> PAGE_SHIFT;
if (comp_bio->bi_iter.bi_size) if (comp_bio->bi_iter.bi_size)
ret = tree->ops->merge_bio_hook(READ, page, 0, ret = tree->ops->merge_bio_hook(page, 0,
PAGE_SIZE, PAGE_SIZE,
comp_bio, 0); comp_bio, 0);
else else
...@@ -690,8 +690,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, ...@@ -690,8 +690,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
sums += DIV_ROUND_UP(comp_bio->bi_iter.bi_size, sums += DIV_ROUND_UP(comp_bio->bi_iter.bi_size,
root->sectorsize); root->sectorsize);
ret = btrfs_map_bio(root, READ, comp_bio, ret = btrfs_map_bio(root, comp_bio, mirror_num, 0);
mirror_num, 0);
if (ret) { if (ret) {
bio->bi_error = ret; bio->bi_error = ret;
bio_endio(comp_bio); bio_endio(comp_bio);
...@@ -721,7 +720,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, ...@@ -721,7 +720,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
} }
ret = btrfs_map_bio(root, READ, comp_bio, mirror_num, 0); ret = btrfs_map_bio(root, comp_bio, mirror_num, 0);
if (ret) { if (ret) {
bio->bi_error = ret; bio->bi_error = ret;
bio_endio(comp_bio); bio_endio(comp_bio);
......
...@@ -3091,7 +3091,7 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans, ...@@ -3091,7 +3091,7 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
struct btrfs_root *new_root, struct btrfs_root *new_root,
struct btrfs_root *parent_root, struct btrfs_root *parent_root,
u64 new_dirid); u64 new_dirid);
int btrfs_merge_bio_hook(int rw, struct page *page, unsigned long offset, int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
size_t size, struct bio *bio, size_t size, struct bio *bio,
unsigned long bio_flags); unsigned long bio_flags);
int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf); int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
......
...@@ -124,7 +124,6 @@ struct async_submit_bio { ...@@ -124,7 +124,6 @@ struct async_submit_bio {
struct list_head list; struct list_head list;
extent_submit_bio_hook_t *submit_bio_start; extent_submit_bio_hook_t *submit_bio_start;
extent_submit_bio_hook_t *submit_bio_done; extent_submit_bio_hook_t *submit_bio_done;
int rw;
int mirror_num; int mirror_num;
unsigned long bio_flags; unsigned long bio_flags;
/* /*
...@@ -797,7 +796,7 @@ static void run_one_async_start(struct btrfs_work *work) ...@@ -797,7 +796,7 @@ static void run_one_async_start(struct btrfs_work *work)
int ret; int ret;
async = container_of(work, struct async_submit_bio, work); async = container_of(work, struct async_submit_bio, work);
ret = async->submit_bio_start(async->inode, async->rw, async->bio, ret = async->submit_bio_start(async->inode, async->bio,
async->mirror_num, async->bio_flags, async->mirror_num, async->bio_flags,
async->bio_offset); async->bio_offset);
if (ret) if (ret)
...@@ -830,9 +829,8 @@ static void run_one_async_done(struct btrfs_work *work) ...@@ -830,9 +829,8 @@ static void run_one_async_done(struct btrfs_work *work)
return; return;
} }
async->submit_bio_done(async->inode, async->rw, async->bio, async->submit_bio_done(async->inode, async->bio, async->mirror_num,
async->mirror_num, async->bio_flags, async->bio_flags, async->bio_offset);
async->bio_offset);
} }
static void run_one_async_free(struct btrfs_work *work) static void run_one_async_free(struct btrfs_work *work)
...@@ -844,7 +842,7 @@ static void run_one_async_free(struct btrfs_work *work) ...@@ -844,7 +842,7 @@ static void run_one_async_free(struct btrfs_work *work)
} }
int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode, int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode,
int rw, struct bio *bio, int mirror_num, struct bio *bio, int mirror_num,
unsigned long bio_flags, unsigned long bio_flags,
u64 bio_offset, u64 bio_offset,
extent_submit_bio_hook_t *submit_bio_start, extent_submit_bio_hook_t *submit_bio_start,
...@@ -857,7 +855,6 @@ int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode, ...@@ -857,7 +855,6 @@ int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode,
return -ENOMEM; return -ENOMEM;
async->inode = inode; async->inode = inode;
async->rw = rw;
async->bio = bio; async->bio = bio;
async->mirror_num = mirror_num; async->mirror_num = mirror_num;
async->submit_bio_start = submit_bio_start; async->submit_bio_start = submit_bio_start;
...@@ -903,9 +900,8 @@ static int btree_csum_one_bio(struct bio *bio) ...@@ -903,9 +900,8 @@ static int btree_csum_one_bio(struct bio *bio)
return ret; return ret;
} }
static int __btree_submit_bio_start(struct inode *inode, int rw, static int __btree_submit_bio_start(struct inode *inode, struct bio *bio,
struct bio *bio, int mirror_num, int mirror_num, unsigned long bio_flags,
unsigned long bio_flags,
u64 bio_offset) u64 bio_offset)
{ {
/* /*
...@@ -915,7 +911,7 @@ static int __btree_submit_bio_start(struct inode *inode, int rw, ...@@ -915,7 +911,7 @@ static int __btree_submit_bio_start(struct inode *inode, int rw,
return btree_csum_one_bio(bio); return btree_csum_one_bio(bio);
} }
static int __btree_submit_bio_done(struct inode *inode, int rw, struct bio *bio, static int __btree_submit_bio_done(struct inode *inode, struct bio *bio,
int mirror_num, unsigned long bio_flags, int mirror_num, unsigned long bio_flags,
u64 bio_offset) u64 bio_offset)
{ {
...@@ -925,7 +921,7 @@ static int __btree_submit_bio_done(struct inode *inode, int rw, struct bio *bio, ...@@ -925,7 +921,7 @@ static int __btree_submit_bio_done(struct inode *inode, int rw, struct bio *bio,
* when we're called for a write, we're already in the async * when we're called for a write, we're already in the async
* submission context. Just jump into btrfs_map_bio * submission context. Just jump into btrfs_map_bio
*/ */
ret = btrfs_map_bio(BTRFS_I(inode)->root, rw, bio, mirror_num, 1); ret = btrfs_map_bio(BTRFS_I(inode)->root, bio, mirror_num, 1);
if (ret) { if (ret) {
bio->bi_error = ret; bio->bi_error = ret;
bio_endio(bio); bio_endio(bio);
...@@ -944,7 +940,7 @@ static int check_async_write(struct inode *inode, unsigned long bio_flags) ...@@ -944,7 +940,7 @@ static int check_async_write(struct inode *inode, unsigned long bio_flags)
return 1; return 1;
} }
static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, static int btree_submit_bio_hook(struct inode *inode, struct bio *bio,
int mirror_num, unsigned long bio_flags, int mirror_num, unsigned long bio_flags,
u64 bio_offset) u64 bio_offset)
{ {
...@@ -960,21 +956,19 @@ static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, ...@@ -960,21 +956,19 @@ static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
bio, BTRFS_WQ_ENDIO_METADATA); bio, BTRFS_WQ_ENDIO_METADATA);
if (ret) if (ret)
goto out_w_error; goto out_w_error;
ret = btrfs_map_bio(BTRFS_I(inode)->root, rw, bio, ret = btrfs_map_bio(BTRFS_I(inode)->root, bio, mirror_num, 0);
mirror_num, 0);
} else if (!async) { } else if (!async) {
ret = btree_csum_one_bio(bio); ret = btree_csum_one_bio(bio);
if (ret) if (ret)
goto out_w_error; goto out_w_error;
ret = btrfs_map_bio(BTRFS_I(inode)->root, rw, bio, ret = btrfs_map_bio(BTRFS_I(inode)->root, bio, mirror_num, 0);
mirror_num, 0);
} else { } else {
/* /*
* kthread helpers are used to submit writes so that * kthread helpers are used to submit writes so that
* checksumming can happen in parallel across all CPUs * checksumming can happen in parallel across all CPUs
*/ */
ret = btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info, ret = btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info,
inode, rw, bio, mirror_num, 0, inode, bio, mirror_num, 0,
bio_offset, bio_offset,
__btree_submit_bio_start, __btree_submit_bio_start,
__btree_submit_bio_done); __btree_submit_bio_done);
......
...@@ -122,7 +122,7 @@ void btrfs_csum_final(u32 crc, char *result); ...@@ -122,7 +122,7 @@ void btrfs_csum_final(u32 crc, char *result);
int btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio, int btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio,
enum btrfs_wq_endio_type metadata); enum btrfs_wq_endio_type metadata);
int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode, int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode,
int rw, struct bio *bio, int mirror_num, struct bio *bio, int mirror_num,
unsigned long bio_flags, u64 bio_offset, unsigned long bio_flags, u64 bio_offset,
extent_submit_bio_hook_t *submit_bio_start, extent_submit_bio_hook_t *submit_bio_start,
extent_submit_bio_hook_t *submit_bio_done); extent_submit_bio_hook_t *submit_bio_done);
......
...@@ -2418,8 +2418,7 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset, ...@@ -2418,8 +2418,7 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset,
pr_debug("Repair Read Error: submitting new read[%#x] to this_mirror=%d, in_validation=%d\n", pr_debug("Repair Read Error: submitting new read[%#x] to this_mirror=%d, in_validation=%d\n",
read_mode, failrec->this_mirror, failrec->in_validation); read_mode, failrec->this_mirror, failrec->in_validation);
ret = tree->ops->submit_bio_hook(inode, read_mode, bio, ret = tree->ops->submit_bio_hook(inode, bio, failrec->this_mirror,
failrec->this_mirror,
failrec->bio_flags, 0); failrec->bio_flags, 0);
if (ret) { if (ret) {
free_io_failure(inode, failrec); free_io_failure(inode, failrec);
...@@ -2740,9 +2739,8 @@ static int __must_check submit_one_bio(struct bio *bio, int mirror_num, ...@@ -2740,9 +2739,8 @@ static int __must_check submit_one_bio(struct bio *bio, int mirror_num,
bio_get(bio); bio_get(bio);
if (tree->ops && tree->ops->submit_bio_hook) if (tree->ops && tree->ops->submit_bio_hook)
ret = tree->ops->submit_bio_hook(page->mapping->host, ret = tree->ops->submit_bio_hook(page->mapping->host, bio,
bio->bi_rw, bio, mirror_num, mirror_num, bio_flags, start);
bio_flags, start);
else else
btrfsic_submit_bio(bio); btrfsic_submit_bio(bio);
...@@ -2756,8 +2754,8 @@ static int merge_bio(struct extent_io_tree *tree, struct page *page, ...@@ -2756,8 +2754,8 @@ static int merge_bio(struct extent_io_tree *tree, struct page *page,
{ {
int ret = 0; int ret = 0;
if (tree->ops && tree->ops->merge_bio_hook) if (tree->ops && tree->ops->merge_bio_hook)
ret = tree->ops->merge_bio_hook(bio_op(bio), page, offset, size, ret = tree->ops->merge_bio_hook(page, offset, size, bio,
bio, bio_flags); bio_flags);
BUG_ON(ret < 0); BUG_ON(ret < 0);
return ret; return ret;
......
...@@ -63,16 +63,16 @@ struct btrfs_root; ...@@ -63,16 +63,16 @@ struct btrfs_root;
struct btrfs_io_bio; struct btrfs_io_bio;
struct io_failure_record; struct io_failure_record;
typedef int (extent_submit_bio_hook_t)(struct inode *inode, int rw, typedef int (extent_submit_bio_hook_t)(struct inode *inode, struct bio *bio,
struct bio *bio, int mirror_num, int mirror_num, unsigned long bio_flags,
unsigned long bio_flags, u64 bio_offset); u64 bio_offset);
struct extent_io_ops { struct extent_io_ops {
int (*fill_delalloc)(struct inode *inode, struct page *locked_page, int (*fill_delalloc)(struct inode *inode, struct page *locked_page,
u64 start, u64 end, int *page_started, u64 start, u64 end, int *page_started,
unsigned long *nr_written); unsigned long *nr_written);
int (*writepage_start_hook)(struct page *page, u64 start, u64 end); int (*writepage_start_hook)(struct page *page, u64 start, u64 end);
extent_submit_bio_hook_t *submit_bio_hook; extent_submit_bio_hook_t *submit_bio_hook;
int (*merge_bio_hook)(int rw, struct page *page, unsigned long offset, int (*merge_bio_hook)(struct page *page, unsigned long offset,
size_t size, struct bio *bio, size_t size, struct bio *bio,
unsigned long bio_flags); unsigned long bio_flags);
int (*readpage_io_failed_hook)(struct page *page, int failed_mirror); int (*readpage_io_failed_hook)(struct page *page, int failed_mirror);
......
...@@ -1823,7 +1823,7 @@ static void btrfs_clear_bit_hook(struct inode *inode, ...@@ -1823,7 +1823,7 @@ static void btrfs_clear_bit_hook(struct inode *inode,
* extent_io.c merge_bio_hook, this must check the chunk tree to make sure * extent_io.c merge_bio_hook, this must check the chunk tree to make sure
* we don't create bios that span stripes or chunks * we don't create bios that span stripes or chunks
*/ */
int btrfs_merge_bio_hook(int rw, struct page *page, unsigned long offset, int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
size_t size, struct bio *bio, size_t size, struct bio *bio,
unsigned long bio_flags) unsigned long bio_flags)
{ {
...@@ -1855,9 +1855,8 @@ int btrfs_merge_bio_hook(int rw, struct page *page, unsigned long offset, ...@@ -1855,9 +1855,8 @@ int btrfs_merge_bio_hook(int rw, struct page *page, unsigned long offset,
* At IO completion time the cums attached on the ordered extent record * At IO completion time the cums attached on the ordered extent record
* are inserted into the btree * are inserted into the btree
*/ */
static int __btrfs_submit_bio_start(struct inode *inode, int rw, static int __btrfs_submit_bio_start(struct inode *inode, struct bio *bio,
struct bio *bio, int mirror_num, int mirror_num, unsigned long bio_flags,
unsigned long bio_flags,
u64 bio_offset) u64 bio_offset)
{ {
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_root *root = BTRFS_I(inode)->root;
...@@ -1876,14 +1875,14 @@ static int __btrfs_submit_bio_start(struct inode *inode, int rw, ...@@ -1876,14 +1875,14 @@ static int __btrfs_submit_bio_start(struct inode *inode, int rw,
* At IO completion time the cums attached on the ordered extent record * At IO completion time the cums attached on the ordered extent record
* are inserted into the btree * are inserted into the btree
*/ */
static int __btrfs_submit_bio_done(struct inode *inode, int rw, struct bio *bio, static int __btrfs_submit_bio_done(struct inode *inode, struct bio *bio,
int mirror_num, unsigned long bio_flags, int mirror_num, unsigned long bio_flags,
u64 bio_offset) u64 bio_offset)
{ {
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_root *root = BTRFS_I(inode)->root;
int ret; int ret;
ret = btrfs_map_bio(root, rw, bio, mirror_num, 1); ret = btrfs_map_bio(root, bio, mirror_num, 1);
if (ret) { if (ret) {
bio->bi_error = ret; bio->bi_error = ret;
bio_endio(bio); bio_endio(bio);
...@@ -1895,7 +1894,7 @@ static int __btrfs_submit_bio_done(struct inode *inode, int rw, struct bio *bio, ...@@ -1895,7 +1894,7 @@ static int __btrfs_submit_bio_done(struct inode *inode, int rw, struct bio *bio,
* extent_io.c submission hook. This does the right thing for csum calculation * extent_io.c submission hook. This does the right thing for csum calculation
* on write, or reading the csums from the tree before a read * on write, or reading the csums from the tree before a read
*/ */
static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, static int btrfs_submit_bio_hook(struct inode *inode, struct bio *bio,
int mirror_num, unsigned long bio_flags, int mirror_num, unsigned long bio_flags,
u64 bio_offset) u64 bio_offset)
{ {
...@@ -1932,7 +1931,7 @@ static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, ...@@ -1932,7 +1931,7 @@ static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
goto mapit; goto mapit;
/* we're doing a write, do the async checksumming */ /* we're doing a write, do the async checksumming */
ret = btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info, ret = btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info,
inode, rw, bio, mirror_num, inode, bio, mirror_num,
bio_flags, bio_offset, bio_flags, bio_offset,
__btrfs_submit_bio_start, __btrfs_submit_bio_start,
__btrfs_submit_bio_done); __btrfs_submit_bio_done);
...@@ -1944,7 +1943,7 @@ static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, ...@@ -1944,7 +1943,7 @@ static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
} }
mapit: mapit:
ret = btrfs_map_bio(root, rw, bio, mirror_num, 0); ret = btrfs_map_bio(root, bio, mirror_num, 0);
out: out:
if (ret < 0) { if (ret < 0) {
...@@ -7778,7 +7777,7 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock, ...@@ -7778,7 +7777,7 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
} }
static inline int submit_dio_repair_bio(struct inode *inode, struct bio *bio, static inline int submit_dio_repair_bio(struct inode *inode, struct bio *bio,
int rw, int mirror_num) int mirror_num)
{ {
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_root *root = BTRFS_I(inode)->root;
int ret; int ret;
...@@ -7792,7 +7791,7 @@ static inline int submit_dio_repair_bio(struct inode *inode, struct bio *bio, ...@@ -7792,7 +7791,7 @@ static inline int submit_dio_repair_bio(struct inode *inode, struct bio *bio,
if (ret) if (ret)
goto err; goto err;
ret = btrfs_map_bio(root, rw, bio, mirror_num, 0); ret = btrfs_map_bio(root, bio, mirror_num, 0);
err: err:
bio_put(bio); bio_put(bio);
return ret; return ret;
...@@ -7877,8 +7876,7 @@ static int dio_read_error(struct inode *inode, struct bio *failed_bio, ...@@ -7877,8 +7876,7 @@ static int dio_read_error(struct inode *inode, struct bio *failed_bio,
"Repair DIO Read Error: submitting new dio read[%#x] to this_mirror=%d, in_validation=%d\n", "Repair DIO Read Error: submitting new dio read[%#x] to this_mirror=%d, in_validation=%d\n",
read_mode, failrec->this_mirror, failrec->in_validation); read_mode, failrec->this_mirror, failrec->in_validation);
ret = submit_dio_repair_bio(inode, bio, read_mode, ret = submit_dio_repair_bio(inode, bio, failrec->this_mirror);
failrec->this_mirror);
if (ret) { if (ret) {
free_io_failure(inode, failrec); free_io_failure(inode, failrec);
bio_put(bio); bio_put(bio);
...@@ -8168,7 +8166,7 @@ static void btrfs_endio_direct_write(struct bio *bio) ...@@ -8168,7 +8166,7 @@ static void btrfs_endio_direct_write(struct bio *bio)
bio_put(bio); bio_put(bio);
} }
static int __btrfs_submit_bio_start_direct_io(struct inode *inode, int rw, static int __btrfs_submit_bio_start_direct_io(struct inode *inode,
struct bio *bio, int mirror_num, struct bio *bio, int mirror_num,
unsigned long bio_flags, u64 offset) unsigned long bio_flags, u64 offset)
{ {
...@@ -8261,7 +8259,7 @@ static inline int btrfs_lookup_and_bind_dio_csum(struct btrfs_root *root, ...@@ -8261,7 +8259,7 @@ static inline int btrfs_lookup_and_bind_dio_csum(struct btrfs_root *root,
} }
static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode, static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
int rw, u64 file_offset, int skip_sum, u64 file_offset, int skip_sum,
int async_submit) int async_submit)
{ {
struct btrfs_dio_private *dip = bio->bi_private; struct btrfs_dio_private *dip = bio->bi_private;
...@@ -8286,8 +8284,7 @@ static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode, ...@@ -8286,8 +8284,7 @@ static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
if (write && async_submit) { if (write && async_submit) {
ret = btrfs_wq_submit_bio(root->fs_info, ret = btrfs_wq_submit_bio(root->fs_info,
inode, rw, bio, 0, 0, inode, bio, 0, 0, file_offset,
file_offset,
__btrfs_submit_bio_start_direct_io, __btrfs_submit_bio_start_direct_io,
__btrfs_submit_bio_done); __btrfs_submit_bio_done);
goto err; goto err;
...@@ -8306,13 +8303,13 @@ static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode, ...@@ -8306,13 +8303,13 @@ static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
goto err; goto err;
} }
map: map:
ret = btrfs_map_bio(root, rw, bio, 0, async_submit); ret = btrfs_map_bio(root, bio, 0, async_submit);
err: err:
bio_put(bio); bio_put(bio);
return ret; return ret;
} }
static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip, static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip,
int skip_sum) int skip_sum)
{ {
struct inode *inode = dip->inode; struct inode *inode = dip->inode;
...@@ -8372,7 +8369,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip, ...@@ -8372,7 +8369,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
* before we're done setting it up * before we're done setting it up
*/ */
atomic_inc(&dip->pending_bios); atomic_inc(&dip->pending_bios);
ret = __btrfs_submit_dio_bio(bio, inode, rw, ret = __btrfs_submit_dio_bio(bio, inode,
file_offset, skip_sum, file_offset, skip_sum,
async_submit); async_submit);
if (ret) { if (ret) {
...@@ -8416,7 +8413,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip, ...@@ -8416,7 +8413,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
} }
submit: submit:
ret = __btrfs_submit_dio_bio(bio, inode, rw, file_offset, skip_sum, ret = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum,
async_submit); async_submit);
if (!ret) if (!ret)
return 0; return 0;
...@@ -8494,7 +8491,7 @@ static void btrfs_submit_direct(struct bio *dio_bio, struct inode *inode, ...@@ -8494,7 +8491,7 @@ static void btrfs_submit_direct(struct bio *dio_bio, struct inode *inode,
dio_data->unsubmitted_oe_range_end; dio_data->unsubmitted_oe_range_end;
} }
ret = btrfs_submit_direct_hook(dio_bio->bi_rw, dip, skip_sum); ret = btrfs_submit_direct_hook(dip, skip_sum);
if (!ret) if (!ret)
return; return;
......
...@@ -6053,7 +6053,7 @@ static noinline void btrfs_schedule_bio(struct btrfs_root *root, ...@@ -6053,7 +6053,7 @@ static noinline void btrfs_schedule_bio(struct btrfs_root *root,
static void submit_stripe_bio(struct btrfs_root *root, struct btrfs_bio *bbio, static void submit_stripe_bio(struct btrfs_root *root, struct btrfs_bio *bbio,
struct bio *bio, u64 physical, int dev_nr, struct bio *bio, u64 physical, int dev_nr,
int rw, int async) int async)
{ {
struct btrfs_device *dev = bbio->stripes[dev_nr].dev; struct btrfs_device *dev = bbio->stripes[dev_nr].dev;
...@@ -6061,15 +6061,14 @@ static void submit_stripe_bio(struct btrfs_root *root, struct btrfs_bio *bbio, ...@@ -6061,15 +6061,14 @@ static void submit_stripe_bio(struct btrfs_root *root, struct btrfs_bio *bbio,
btrfs_io_bio(bio)->stripe_index = dev_nr; btrfs_io_bio(bio)->stripe_index = dev_nr;
bio->bi_end_io = btrfs_end_bio; bio->bi_end_io = btrfs_end_bio;
bio->bi_iter.bi_sector = physical >> 9; bio->bi_iter.bi_sector = physical >> 9;
bio->bi_rw |= rw;
#ifdef DEBUG #ifdef DEBUG
{ {
struct rcu_string *name; struct rcu_string *name;
rcu_read_lock(); rcu_read_lock();
name = rcu_dereference(dev->name); name = rcu_dereference(dev->name);
pr_debug("btrfs_map_bio: rw %d, sector=%llu, dev=%lu " pr_debug("btrfs_map_bio: rw %d 0x%x, sector=%llu, dev=%lu "
"(%s id %llu), size=%u\n", rw, "(%s id %llu), size=%u\n", bio_op(bio), bio->bi_rw,
(u64)bio->bi_iter.bi_sector, (u_long)dev->bdev->bd_dev, (u64)bio->bi_iter.bi_sector, (u_long)dev->bdev->bd_dev,
name->str, dev->devid, bio->bi_iter.bi_size); name->str, dev->devid, bio->bi_iter.bi_size);
rcu_read_unlock(); rcu_read_unlock();
...@@ -6099,7 +6098,7 @@ static void bbio_error(struct btrfs_bio *bbio, struct bio *bio, u64 logical) ...@@ -6099,7 +6098,7 @@ static void bbio_error(struct btrfs_bio *bbio, struct bio *bio, u64 logical)
} }
} }
int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio, int btrfs_map_bio(struct btrfs_root *root, struct bio *bio,
int mirror_num, int async_submit) int mirror_num, int async_submit)
{ {
struct btrfs_device *dev; struct btrfs_device *dev;
...@@ -6166,7 +6165,7 @@ int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio, ...@@ -6166,7 +6165,7 @@ int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio,
bio = first_bio; bio = first_bio;
submit_stripe_bio(root, bbio, bio, submit_stripe_bio(root, bbio, bio,
bbio->stripes[dev_nr].physical, dev_nr, rw, bbio->stripes[dev_nr].physical, dev_nr,
async_submit); async_submit);
} }
btrfs_bio_counter_dec(root->fs_info); btrfs_bio_counter_dec(root->fs_info);
......
...@@ -391,7 +391,7 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans, ...@@ -391,7 +391,7 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
struct btrfs_root *extent_root, u64 type); struct btrfs_root *extent_root, u64 type);
void btrfs_mapping_init(struct btrfs_mapping_tree *tree); void btrfs_mapping_init(struct btrfs_mapping_tree *tree);
void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree); void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree);
int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio, int btrfs_map_bio(struct btrfs_root *root, struct bio *bio,
int mirror_num, int async_submit); int mirror_num, int async_submit);
int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
fmode_t flags, void *holder); fmode_t flags, void *holder);
......
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