]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
btrfs: update __btrfs_map_block for REQ_OP transition
authorMike Christie <mchristi@redhat.com>
Sun, 5 Jun 2016 19:31:53 +0000 (14:31 -0500)
committerJens Axboe <axboe@fb.com>
Tue, 7 Jun 2016 19:41:38 +0000 (13:41 -0600)
We no longer pass in a bitmap of rq_flag_bits bits to __btrfs_map_block.
It will always be a REQ_OP, or the btrfs specific REQ_GET_READ_MIRRORS,
so this drops the bit tests.

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/extent-tree.c
fs/btrfs/inode.c
fs/btrfs/volumes.c
fs/btrfs/volumes.h

index 689d25ac6a6818f84aad0fcdbe7810d3dda417df..5796c4a9eec6e7983d9ba7e4ffe66e89c85d84bb 100644 (file)
@@ -2048,7 +2048,7 @@ int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr,
         */
        btrfs_bio_counter_inc_blocked(root->fs_info);
        /* Tell the block device(s) that the sectors can be discarded */
-       ret = btrfs_map_block(root->fs_info, REQ_DISCARD,
+       ret = btrfs_map_block(root->fs_info, REQ_OP_DISCARD,
                              bytenr, &num_bytes, &bbio, 0);
        /* Error condition is -ENOMEM */
        if (!ret) {
index b4a98c31433f0bdc6c3320891325b9dad0fb1452..8835ce332123377855743d8231cf7ffc1f63c8ab 100644 (file)
@@ -1838,7 +1838,7 @@ int btrfs_merge_bio_hook(int rw, struct page *page, unsigned long offset,
 
        length = bio->bi_iter.bi_size;
        map_length = length;
-       ret = btrfs_map_block(root->fs_info, rw, logical,
+       ret = btrfs_map_block(root->fs_info, bio_op(bio), logical,
                              &map_length, NULL, 0);
        /* Will always return 0 with map_multi == NULL */
        BUG_ON(ret < 0);
index 705b562cecbf8f6cdaeeb94ca3f16c039f5eb5f6..146f02acb75298d4fb8d5fc07bb6180f53e36180 100644 (file)
@@ -5259,7 +5259,7 @@ void btrfs_put_bbio(struct btrfs_bio *bbio)
                kfree(bbio);
 }
 
-static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
+static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int op,
                             u64 logical, u64 *length,
                             struct btrfs_bio **bbio_ret,
                             int mirror_num, int need_raid_map)
@@ -5345,7 +5345,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
                raid56_full_stripe_start *= full_stripe_len;
        }
 
-       if (rw & REQ_DISCARD) {
+       if (op == REQ_OP_DISCARD) {
                /* we don't discard raid56 yet */
                if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
                        ret = -EOPNOTSUPP;
@@ -5358,7 +5358,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
                   For other RAID types and for RAID[56] reads, just allow a single
                   stripe (on a single disk). */
                if ((map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) &&
-                   (rw & REQ_WRITE)) {
+                   (op == REQ_OP_WRITE)) {
                        max_len = stripe_len * nr_data_stripes(map) -
                                (offset - raid56_full_stripe_start);
                } else {
@@ -5383,8 +5383,8 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
                btrfs_dev_replace_set_lock_blocking(dev_replace);
 
        if (dev_replace_is_ongoing && mirror_num == map->num_stripes + 1 &&
-           !(rw & (REQ_WRITE | REQ_DISCARD | REQ_GET_READ_MIRRORS)) &&
-           dev_replace->tgtdev != NULL) {
+           op != REQ_OP_WRITE && op != REQ_OP_DISCARD &&
+           op != REQ_GET_READ_MIRRORS && dev_replace->tgtdev != NULL) {
                /*
                 * in dev-replace case, for repair case (that's the only
                 * case where the mirror is selected explicitly when
@@ -5471,15 +5471,17 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
                            (offset + *length);
 
        if (map->type & BTRFS_BLOCK_GROUP_RAID0) {
-               if (rw & REQ_DISCARD)
+               if (op == REQ_OP_DISCARD)
                        num_stripes = min_t(u64, map->num_stripes,
                                            stripe_nr_end - stripe_nr_orig);
                stripe_nr = div_u64_rem(stripe_nr, map->num_stripes,
                                &stripe_index);
-               if (!(rw & (REQ_WRITE | REQ_DISCARD | REQ_GET_READ_MIRRORS)))
+               if (op != REQ_OP_WRITE && op != REQ_OP_DISCARD &&
+                   op != REQ_GET_READ_MIRRORS)
                        mirror_num = 1;
        } else if (map->type & BTRFS_BLOCK_GROUP_RAID1) {
-               if (rw & (REQ_WRITE | REQ_DISCARD | REQ_GET_READ_MIRRORS))
+               if (op == REQ_OP_WRITE || op == REQ_OP_DISCARD ||
+                   op == REQ_GET_READ_MIRRORS)
                        num_stripes = map->num_stripes;
                else if (mirror_num)
                        stripe_index = mirror_num - 1;
@@ -5492,7 +5494,8 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
                }
 
        } else if (map->type & BTRFS_BLOCK_GROUP_DUP) {
-               if (rw & (REQ_WRITE | REQ_DISCARD | REQ_GET_READ_MIRRORS)) {
+               if (op == REQ_OP_WRITE || REQ_OP_DISCARD ||
+                   op == REQ_GET_READ_MIRRORS) {
                        num_stripes = map->num_stripes;
                } else if (mirror_num) {
                        stripe_index = mirror_num - 1;
@@ -5506,9 +5509,9 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
                stripe_nr = div_u64_rem(stripe_nr, factor, &stripe_index);
                stripe_index *= map->sub_stripes;
 
-               if (rw & (REQ_WRITE | REQ_GET_READ_MIRRORS))
+               if (op == REQ_OP_WRITE || op == REQ_GET_READ_MIRRORS)
                        num_stripes = map->sub_stripes;
-               else if (rw & REQ_DISCARD)
+               else if (op == REQ_OP_DISCARD)
                        num_stripes = min_t(u64, map->sub_stripes *
                                            (stripe_nr_end - stripe_nr_orig),
                                            map->num_stripes);
@@ -5526,7 +5529,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
 
        } else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
                if (need_raid_map &&
-                   ((rw & (REQ_WRITE | REQ_GET_READ_MIRRORS)) ||
+                   (op == REQ_OP_WRITE || op == REQ_GET_READ_MIRRORS ||
                     mirror_num > 1)) {
                        /* push stripe_nr back to the start of the full stripe */
                        stripe_nr = div_u64(raid56_full_stripe_start,
@@ -5554,8 +5557,8 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
                        /* We distribute the parity blocks across stripes */
                        div_u64_rem(stripe_nr + stripe_index, map->num_stripes,
                                        &stripe_index);
-                       if (!(rw & (REQ_WRITE | REQ_DISCARD |
-                                   REQ_GET_READ_MIRRORS)) && mirror_num <= 1)
+                       if ((op != REQ_OP_WRITE && op != REQ_OP_DISCARD &&
+                           op != REQ_GET_READ_MIRRORS) && mirror_num <= 1)
                                mirror_num = 1;
                }
        } else {
@@ -5578,9 +5581,9 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
 
        num_alloc_stripes = num_stripes;
        if (dev_replace_is_ongoing) {
-               if (rw & (REQ_WRITE | REQ_DISCARD))
+               if (op == REQ_OP_WRITE || op == REQ_OP_DISCARD)
                        num_alloc_stripes <<= 1;
-               if (rw & REQ_GET_READ_MIRRORS)
+               if (op == REQ_GET_READ_MIRRORS)
                        num_alloc_stripes++;
                tgtdev_indexes = num_stripes;
        }
@@ -5595,7 +5598,8 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
 
        /* build raid_map */
        if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK &&
-           need_raid_map && ((rw & (REQ_WRITE | REQ_GET_READ_MIRRORS)) ||
+           need_raid_map &&
+           ((op == REQ_OP_WRITE || op == REQ_GET_READ_MIRRORS) ||
            mirror_num > 1)) {
                u64 tmp;
                unsigned rot;
@@ -5620,7 +5624,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
                                RAID6_Q_STRIPE;
        }
 
-       if (rw & REQ_DISCARD) {
+       if (op == REQ_OP_DISCARD) {
                u32 factor = 0;
                u32 sub_stripes = 0;
                u64 stripes_per_dev = 0;
@@ -5700,14 +5704,15 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
                }
        }
 
-       if (rw & (REQ_WRITE | REQ_GET_READ_MIRRORS))
+       if (op == REQ_OP_WRITE || op == REQ_GET_READ_MIRRORS)
                max_errors = btrfs_chunk_max_errors(map);
 
        if (bbio->raid_map)
                sort_parity_stripes(bbio, num_stripes);
 
        tgtdev_indexes = 0;
-       if (dev_replace_is_ongoing && (rw & (REQ_WRITE | REQ_DISCARD)) &&
+       if (dev_replace_is_ongoing &&
+          (op == REQ_OP_WRITE || op == REQ_OP_DISCARD) &&
            dev_replace->tgtdev != NULL) {
                int index_where_to_add;
                u64 srcdev_devid = dev_replace->srcdev->devid;
@@ -5742,7 +5747,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
                        }
                }
                num_stripes = index_where_to_add;
-       } else if (dev_replace_is_ongoing && (rw & REQ_GET_READ_MIRRORS) &&
+       } else if (dev_replace_is_ongoing && (op == REQ_GET_READ_MIRRORS) &&
                   dev_replace->tgtdev != NULL) {
                u64 srcdev_devid = dev_replace->srcdev->devid;
                int index_srcdev = 0;
@@ -5814,21 +5819,21 @@ out:
        return ret;
 }
 
-int btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
+int btrfs_map_block(struct btrfs_fs_info *fs_info, int op,
                      u64 logical, u64 *length,
                      struct btrfs_bio **bbio_ret, int mirror_num)
 {
-       return __btrfs_map_block(fs_info, rw, logical, length, bbio_ret,
+       return __btrfs_map_block(fs_info, op, logical, length, bbio_ret,
                                 mirror_num, 0);
 }
 
 /* For Scrub/replace */
-int btrfs_map_sblock(struct btrfs_fs_info *fs_info, int rw,
+int btrfs_map_sblock(struct btrfs_fs_info *fs_info, int op,
                     u64 logical, u64 *length,
                     struct btrfs_bio **bbio_ret, int mirror_num,
                     int need_raid_map)
 {
-       return __btrfs_map_block(fs_info, rw, logical, length, bbio_ret,
+       return __btrfs_map_block(fs_info, op, logical, length, bbio_ret,
                                 mirror_num, need_raid_map);
 }
 
index 0ac90f8d85bdc8565acd1efee6c7c3228c83a5b5..3b78700cf30a546158c1d186a4eb1b83843b97cc 100644 (file)
@@ -375,10 +375,10 @@ int btrfs_account_dev_extents_size(struct btrfs_device *device, u64 start,
                                   u64 end, u64 *length);
 void btrfs_get_bbio(struct btrfs_bio *bbio);
 void btrfs_put_bbio(struct btrfs_bio *bbio);
-int btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
+int btrfs_map_block(struct btrfs_fs_info *fs_info, int op,
                    u64 logical, u64 *length,
                    struct btrfs_bio **bbio_ret, int mirror_num);
-int btrfs_map_sblock(struct btrfs_fs_info *fs_info, int rw,
+int btrfs_map_sblock(struct btrfs_fs_info *fs_info, int op,
                     u64 logical, u64 *length,
                     struct btrfs_bio **bbio_ret, int mirror_num,
                     int need_raid_map);