btrfs: use bio fields for op and flags
authorMike Christie <mchristi@redhat.com>
Sun, 5 Jun 2016 19:31:54 +0000 (14:31 -0500)
committerJens Axboe <axboe@fb.com>
Tue, 7 Jun 2016 19:41:38 +0000 (13:41 -0600)
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: Mike Christie <mchristi@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
fs/btrfs/compression.c
fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/disk-io.h
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h
fs/btrfs/inode.c
fs/btrfs/volumes.c
fs/btrfs/volumes.h

index 029bd799df22d937278cc4bc102276fdae44b996..cefedabf0a92fd6aaa4c4986d4899fc9cac3b859 100644 (file)
@@ -374,7 +374,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
                page = compressed_pages[pg_index];
                page->mapping = inode->i_mapping;
                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,
                                                           bio, 0);
                else
@@ -402,7 +402,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
                                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 */
 
                        bio_put(bio);
@@ -433,7 +433,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
                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 */
 
        bio_put(bio);
@@ -659,7 +659,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
                page->index = em_start >> PAGE_SHIFT;
 
                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,
                                                        comp_bio, 0);
                else
@@ -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,
                                             root->sectorsize);
 
-                       ret = btrfs_map_bio(root, READ, comp_bio,
-                                           mirror_num, 0);
+                       ret = btrfs_map_bio(root, comp_bio, mirror_num, 0);
                        if (ret) {
                                bio->bi_error = ret;
                                bio_endio(comp_bio);
@@ -721,7 +720,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
                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) {
                bio->bi_error = ret;
                bio_endio(comp_bio);
index 101c3cfd3f7cddd43e07462fd74ebfb06cb4039e..4088d7f044e2eb6a06c4fdb1173df698bc36df75 100644 (file)
@@ -3091,7 +3091,7 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
                             struct btrfs_root *new_root,
                             struct btrfs_root *parent_root,
                             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,
                         unsigned long bio_flags);
 int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
index 93278c2f6af217249733b6cb3c217c030ea6b72b..e80ef6eb17e6cd5c73aa18eb4074f336931deeef 100644 (file)
@@ -124,7 +124,6 @@ struct async_submit_bio {
        struct list_head list;
        extent_submit_bio_hook_t *submit_bio_start;
        extent_submit_bio_hook_t *submit_bio_done;
-       int rw;
        int mirror_num;
        unsigned long bio_flags;
        /*
@@ -797,7 +796,7 @@ static void run_one_async_start(struct btrfs_work *work)
        int ret;
 
        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->bio_offset);
        if (ret)
@@ -830,9 +829,8 @@ static void run_one_async_done(struct btrfs_work *work)
                return;
        }
 
-       async->submit_bio_done(async->inode, async->rw, async->bio,
-                              async->mirror_num, async->bio_flags,
-                              async->bio_offset);
+       async->submit_bio_done(async->inode, async->bio, async->mirror_num,
+                              async->bio_flags, async->bio_offset);
 }
 
 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 rw, struct bio *bio, int mirror_num,
+                       struct bio *bio, int mirror_num,
                        unsigned long bio_flags,
                        u64 bio_offset,
                        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,
                return -ENOMEM;
 
        async->inode = inode;
-       async->rw = rw;
        async->bio = bio;
        async->mirror_num = mirror_num;
        async->submit_bio_start = submit_bio_start;
@@ -903,9 +900,8 @@ static int btree_csum_one_bio(struct bio *bio)
        return ret;
 }
 
-static int __btree_submit_bio_start(struct inode *inode, int rw,
-                                   struct bio *bio, int mirror_num,
-                                   unsigned long bio_flags,
+static int __btree_submit_bio_start(struct inode *inode, struct bio *bio,
+                                   int mirror_num, unsigned long bio_flags,
                                    u64 bio_offset)
 {
        /*
@@ -915,7 +911,7 @@ static int __btree_submit_bio_start(struct inode *inode, int rw,
        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,
                                 u64 bio_offset)
 {
@@ -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
         * 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) {
                bio->bi_error = ret;
                bio_endio(bio);
@@ -944,7 +940,7 @@ static int check_async_write(struct inode *inode, unsigned long bio_flags)
        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,
                                 u64 bio_offset)
 {
@@ -960,21 +956,19 @@ static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
                                          bio, BTRFS_WQ_ENDIO_METADATA);
                if (ret)
                        goto out_w_error;
-               ret = btrfs_map_bio(BTRFS_I(inode)->root, rw, bio,
-                                   mirror_num, 0);
+               ret = btrfs_map_bio(BTRFS_I(inode)->root, bio, mirror_num, 0);
        } else if (!async) {
                ret = btree_csum_one_bio(bio);
                if (ret)
                        goto out_w_error;
-               ret = btrfs_map_bio(BTRFS_I(inode)->root, rw, bio,
-                                   mirror_num, 0);
+               ret = btrfs_map_bio(BTRFS_I(inode)->root, bio, mirror_num, 0);
        } else {
                /*
                 * kthread helpers are used to submit writes so that
                 * checksumming can happen in parallel across all CPUs
                 */
                ret = btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info,
-                                         inode, rw, bio, mirror_num, 0,
+                                         inode, bio, mirror_num, 0,
                                          bio_offset,
                                          __btree_submit_bio_start,
                                          __btree_submit_bio_done);
index 8e79d0070bcf57d26f6792e7775fde0117834810..73c21a2969e1c52677640c351d9584881c5803d2 100644 (file)
@@ -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,
                        enum btrfs_wq_endio_type metadata);
 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,
                        extent_submit_bio_hook_t *submit_bio_start,
                        extent_submit_bio_hook_t *submit_bio_done);
index 3d5ac79a6e3c332ac926975fc50d0e7f673cad59..4f8bace0fd1b47c4c4c05e8debe833a1131dfae1 100644 (file)
@@ -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",
                 read_mode, failrec->this_mirror, failrec->in_validation);
 
-       ret = tree->ops->submit_bio_hook(inode, read_mode, bio,
-                                        failrec->this_mirror,
+       ret = tree->ops->submit_bio_hook(inode, bio, failrec->this_mirror,
                                         failrec->bio_flags, 0);
        if (ret) {
                free_io_failure(inode, failrec);
@@ -2740,9 +2739,8 @@ static int __must_check submit_one_bio(struct bio *bio, int mirror_num,
        bio_get(bio);
 
        if (tree->ops && tree->ops->submit_bio_hook)
-               ret = tree->ops->submit_bio_hook(page->mapping->host,
-                                                bio->bi_rw, bio, mirror_num,
-                                                bio_flags, start);
+               ret = tree->ops->submit_bio_hook(page->mapping->host, bio,
+                                          mirror_num, bio_flags, start);
        else
                btrfsic_submit_bio(bio);
 
@@ -2756,8 +2754,8 @@ static int merge_bio(struct extent_io_tree *tree, struct page *page,
 {
        int ret = 0;
        if (tree->ops && tree->ops->merge_bio_hook)
-               ret = tree->ops->merge_bio_hook(bio_op(bio), page, offset, size,
-                                               bio, bio_flags);
+               ret = tree->ops->merge_bio_hook(page, offset, size, bio,
+                                               bio_flags);
        BUG_ON(ret < 0);
        return ret;
 
index 1baf19c9b79d2f48d407549b7dcdf03ce0faed3c..fb9dcc9f46beea36aec30f0815c141f032be38a7 100644 (file)
@@ -63,16 +63,16 @@ struct btrfs_root;
 struct btrfs_io_bio;
 struct io_failure_record;
 
-typedef        int (extent_submit_bio_hook_t)(struct inode *inode, int rw,
-                                      struct bio *bio, int mirror_num,
-                                      unsigned long bio_flags, u64 bio_offset);
+typedef        int (extent_submit_bio_hook_t)(struct inode *inode, struct bio *bio,
+                                      int mirror_num, unsigned long bio_flags,
+                                      u64 bio_offset);
 struct extent_io_ops {
        int (*fill_delalloc)(struct inode *inode, struct page *locked_page,
                             u64 start, u64 end, int *page_started,
                             unsigned long *nr_written);
        int (*writepage_start_hook)(struct page *page, u64 start, u64 end);
        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,
                              unsigned long bio_flags);
        int (*readpage_io_failed_hook)(struct page *page, int failed_mirror);
index 8835ce332123377855743d8231cf7ffc1f63c8ab..ec61db64c4c9c16124042df70f71f657d4d24683 100644 (file)
@@ -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
  * 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,
                         unsigned long bio_flags)
 {
@@ -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
  * are inserted into the btree
  */
-static int __btrfs_submit_bio_start(struct inode *inode, int rw,
-                                   struct bio *bio, int mirror_num,
-                                   unsigned long bio_flags,
+static int __btrfs_submit_bio_start(struct inode *inode, struct bio *bio,
+                                   int mirror_num, unsigned long bio_flags,
                                    u64 bio_offset)
 {
        struct btrfs_root *root = BTRFS_I(inode)->root;
@@ -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
  * 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,
                          u64 bio_offset)
 {
        struct btrfs_root *root = BTRFS_I(inode)->root;
        int ret;
 
-       ret = btrfs_map_bio(root, rw, bio, mirror_num, 1);
+       ret = btrfs_map_bio(root, bio, mirror_num, 1);
        if (ret) {
                bio->bi_error = ret;
                bio_endio(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
  * 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,
                          u64 bio_offset)
 {
@@ -1932,7 +1931,7 @@ static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
                        goto mapit;
                /* we're doing a write, do the async checksumming */
                ret = btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info,
-                                  inode, rw, bio, mirror_num,
+                                  inode, bio, mirror_num,
                                   bio_flags, bio_offset,
                                   __btrfs_submit_bio_start,
                                   __btrfs_submit_bio_done);
@@ -1944,7 +1943,7 @@ static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
        }
 
 mapit:
-       ret = btrfs_map_bio(root, rw, bio, mirror_num, 0);
+       ret = btrfs_map_bio(root, bio, mirror_num, 0);
 
 out:
        if (ret < 0) {
@@ -7778,7 +7777,7 @@ err:
 }
 
 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;
        int ret;
@@ -7792,7 +7791,7 @@ static inline int submit_dio_repair_bio(struct inode *inode, struct bio *bio,
        if (ret)
                goto err;
 
-       ret = btrfs_map_bio(root, rw, bio, mirror_num, 0);
+       ret = btrfs_map_bio(root, bio, mirror_num, 0);
 err:
        bio_put(bio);
        return ret;
@@ -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",
                    read_mode, failrec->this_mirror, failrec->in_validation);
 
-       ret = submit_dio_repair_bio(inode, bio, read_mode,
-                                   failrec->this_mirror);
+       ret = submit_dio_repair_bio(inode, bio, failrec->this_mirror);
        if (ret) {
                free_io_failure(inode, failrec);
                bio_put(bio);
@@ -8168,7 +8166,7 @@ static void btrfs_endio_direct_write(struct bio *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,
                                    unsigned long bio_flags, u64 offset)
 {
@@ -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,
-                                        int rw, u64 file_offset, int skip_sum,
+                                        u64 file_offset, int skip_sum,
                                         int async_submit)
 {
        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,
 
        if (write && async_submit) {
                ret = btrfs_wq_submit_bio(root->fs_info,
-                                  inode, rw, bio, 0, 0,
-                                  file_offset,
+                                  inode, bio, 0, 0, file_offset,
                                   __btrfs_submit_bio_start_direct_io,
                                   __btrfs_submit_bio_done);
                goto err;
@@ -8306,13 +8303,13 @@ static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
                        goto err;
        }
 map:
-       ret = btrfs_map_bio(root, rw, bio, 0, async_submit);
+       ret = btrfs_map_bio(root, bio, 0, async_submit);
 err:
        bio_put(bio);
        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)
 {
        struct inode *inode = dip->inode;
@@ -8372,7 +8369,7 @@ next_block:
                         * before we're done setting it up
                         */
                        atomic_inc(&dip->pending_bios);
-                       ret = __btrfs_submit_dio_bio(bio, inode, rw,
+                       ret = __btrfs_submit_dio_bio(bio, inode,
                                                     file_offset, skip_sum,
                                                     async_submit);
                        if (ret) {
@@ -8416,7 +8413,7 @@ next_block:
        }
 
 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);
        if (!ret)
                return 0;
@@ -8494,7 +8491,7 @@ static void btrfs_submit_direct(struct bio *dio_bio, struct inode *inode,
                        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)
                return;
 
index 146f02acb75298d4fb8d5fc07bb6180f53e36180..14b2d19c842c054c64768e072801fe8a684d496c 100644 (file)
@@ -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,
                              struct bio *bio, u64 physical, int dev_nr,
-                             int rw, int async)
+                             int async)
 {
        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,
        btrfs_io_bio(bio)->stripe_index = dev_nr;
        bio->bi_end_io = btrfs_end_bio;
        bio->bi_iter.bi_sector = physical >> 9;
-       bio->bi_rw |= rw;
 #ifdef DEBUG
        {
                struct rcu_string *name;
 
                rcu_read_lock();
                name = rcu_dereference(dev->name);
-               pr_debug("btrfs_map_bio: rw %d, sector=%llu, dev=%lu "
-                        "(%s id %llu), size=%u\n", rw,
+               pr_debug("btrfs_map_bio: rw %d 0x%x, sector=%llu, dev=%lu "
+                        "(%s id %llu), size=%u\n", bio_op(bio), bio->bi_rw,
                         (u64)bio->bi_iter.bi_sector, (u_long)dev->bdev->bd_dev,
                         name->str, dev->devid, bio->bi_iter.bi_size);
                rcu_read_unlock();
@@ -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)
 {
        struct btrfs_device *dev;
@@ -6166,7 +6165,7 @@ int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio,
                        bio = first_bio;
 
                submit_stripe_bio(root, bbio, bio,
-                                 bbio->stripes[dev_nr].physical, dev_nr, rw,
+                                 bbio->stripes[dev_nr].physical, dev_nr,
                                  async_submit);
        }
        btrfs_bio_counter_dec(root->fs_info);
index 3b78700cf30a546158c1d186a4eb1b83843b97cc..6613e6335ca29e12e4ebd8fc6cc515638ffc416d 100644 (file)
@@ -391,7 +391,7 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
                      struct btrfs_root *extent_root, u64 type);
 void btrfs_mapping_init(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 btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
                       fmode_t flags, void *holder);