• Home
  • Raw
  • Download

Lines Matching refs:bbio

5576 static void sort_parity_stripes(struct btrfs_bio *bbio, int num_stripes)  in sort_parity_stripes()  argument
5585 if (bbio->raid_map[i] > bbio->raid_map[i + 1]) { in sort_parity_stripes()
5586 swap(bbio->stripes[i], bbio->stripes[i + 1]); in sort_parity_stripes()
5587 swap(bbio->raid_map[i], bbio->raid_map[i + 1]); in sort_parity_stripes()
5596 struct btrfs_bio *bbio = kzalloc( in alloc_btrfs_bio() local
5610 atomic_set(&bbio->error, 0); in alloc_btrfs_bio()
5611 refcount_set(&bbio->refs, 1); in alloc_btrfs_bio()
5613 bbio->tgtdev_map = (int *)(bbio->stripes + total_stripes); in alloc_btrfs_bio()
5614 bbio->raid_map = (u64 *)(bbio->tgtdev_map + real_stripes); in alloc_btrfs_bio()
5616 return bbio; in alloc_btrfs_bio()
5619 void btrfs_get_bbio(struct btrfs_bio *bbio) in btrfs_get_bbio() argument
5621 WARN_ON(!refcount_read(&bbio->refs)); in btrfs_get_bbio()
5622 refcount_inc(&bbio->refs); in btrfs_get_bbio()
5625 void btrfs_put_bbio(struct btrfs_bio *bbio) in btrfs_put_bbio() argument
5627 if (!bbio) in btrfs_put_bbio()
5629 if (refcount_dec_and_test(&bbio->refs)) in btrfs_put_bbio()
5630 kfree(bbio); in btrfs_put_bbio()
5644 struct btrfs_bio *bbio; in __btrfs_map_block_for_discard() local
5727 bbio = alloc_btrfs_bio(num_stripes, 0); in __btrfs_map_block_for_discard()
5728 if (!bbio) { in __btrfs_map_block_for_discard()
5734 bbio->stripes[i].physical = in __btrfs_map_block_for_discard()
5737 bbio->stripes[i].dev = map->stripes[stripe_index].dev; in __btrfs_map_block_for_discard()
5741 bbio->stripes[i].length = stripes_per_dev * in __btrfs_map_block_for_discard()
5745 bbio->stripes[i].length += in __btrfs_map_block_for_discard()
5757 bbio->stripes[i].length -= in __btrfs_map_block_for_discard()
5763 bbio->stripes[i].length -= in __btrfs_map_block_for_discard()
5769 bbio->stripes[i].length = length; in __btrfs_map_block_for_discard()
5779 *bbio_ret = bbio; in __btrfs_map_block_for_discard()
5780 bbio->map_type = map->type; in __btrfs_map_block_for_discard()
5781 bbio->num_stripes = num_stripes; in __btrfs_map_block_for_discard()
5805 struct btrfs_bio *bbio = NULL; in get_extra_mirror_from_replace() local
5814 logical, &length, &bbio, 0, 0); in get_extra_mirror_from_replace()
5816 ASSERT(bbio == NULL); in get_extra_mirror_from_replace()
5820 num_stripes = bbio->num_stripes; in get_extra_mirror_from_replace()
5827 btrfs_put_bbio(bbio); in get_extra_mirror_from_replace()
5837 if (bbio->stripes[i].dev->devid != srcdev_devid) in get_extra_mirror_from_replace()
5845 physical_of_found <= bbio->stripes[i].physical) in get_extra_mirror_from_replace()
5850 physical_of_found = bbio->stripes[i].physical; in get_extra_mirror_from_replace()
5853 btrfs_put_bbio(bbio); in get_extra_mirror_from_replace()
5869 struct btrfs_bio *bbio = *bbio_ret; in handle_ops_on_dev_replace() local
5892 if (bbio->stripes[i].dev->devid == srcdev_devid) { in handle_ops_on_dev_replace()
5895 bbio->stripes + index_where_to_add; in handle_ops_on_dev_replace()
5897 bbio->stripes + i; in handle_ops_on_dev_replace()
5902 bbio->tgtdev_map[i] = index_where_to_add; in handle_ops_on_dev_replace()
5922 if (bbio->stripes[i].dev->devid == srcdev_devid) { in handle_ops_on_dev_replace()
5930 bbio->stripes[i].physical) in handle_ops_on_dev_replace()
5934 physical_of_found = bbio->stripes[i].physical; in handle_ops_on_dev_replace()
5939 bbio->stripes + num_stripes; in handle_ops_on_dev_replace()
5943 bbio->stripes[index_srcdev].length; in handle_ops_on_dev_replace()
5945 bbio->tgtdev_map[index_srcdev] = num_stripes; in handle_ops_on_dev_replace()
5954 bbio->num_tgtdevs = tgtdev_indexes; in handle_ops_on_dev_replace()
5955 *bbio_ret = bbio; in handle_ops_on_dev_replace()
6081 struct btrfs_bio *bbio = NULL; in __btrfs_map_block() local
6233 bbio = alloc_btrfs_bio(num_alloc_stripes, tgtdev_indexes); in __btrfs_map_block()
6234 if (!bbio) { in __btrfs_map_block()
6240 bbio->stripes[i].physical = map->stripes[stripe_index].physical + in __btrfs_map_block()
6242 bbio->stripes[i].dev = map->stripes[stripe_index].dev; in __btrfs_map_block()
6258 bbio->raid_map[(i+rot) % num_stripes] = in __btrfs_map_block()
6261 bbio->raid_map[(i+rot) % map->num_stripes] = RAID5_P_STRIPE; in __btrfs_map_block()
6263 bbio->raid_map[(i+rot+1) % num_stripes] = in __btrfs_map_block()
6266 sort_parity_stripes(bbio, num_stripes); in __btrfs_map_block()
6274 handle_ops_on_dev_replace(op, &bbio, dev_replace, &num_stripes, in __btrfs_map_block()
6278 *bbio_ret = bbio; in __btrfs_map_block()
6279 bbio->map_type = map->type; in __btrfs_map_block()
6280 bbio->num_stripes = num_stripes; in __btrfs_map_block()
6281 bbio->max_errors = max_errors; in __btrfs_map_block()
6282 bbio->mirror_num = mirror_num; in __btrfs_map_block()
6291 bbio->stripes[0].dev = dev_replace->tgtdev; in __btrfs_map_block()
6292 bbio->stripes[0].physical = physical_to_patch_in_first_stripe; in __btrfs_map_block()
6293 bbio->mirror_num = map->num_stripes + 1; in __btrfs_map_block()
6325 static inline void btrfs_end_bbio(struct btrfs_bio *bbio, struct bio *bio) in btrfs_end_bbio() argument
6327 bio->bi_private = bbio->private; in btrfs_end_bbio()
6328 bio->bi_end_io = bbio->end_io; in btrfs_end_bbio()
6331 btrfs_put_bbio(bbio); in btrfs_end_bbio()
6336 struct btrfs_bio *bbio = bio->bi_private; in btrfs_end_bio() local
6340 atomic_inc(&bbio->error); in btrfs_end_bio()
6358 if (bio == bbio->orig_bio) in btrfs_end_bio()
6361 btrfs_bio_counter_dec(bbio->fs_info); in btrfs_end_bio()
6363 if (atomic_dec_and_test(&bbio->stripes_pending)) { in btrfs_end_bio()
6366 bio = bbio->orig_bio; in btrfs_end_bio()
6369 btrfs_io_bio(bio)->mirror_num = bbio->mirror_num; in btrfs_end_bio()
6373 if (atomic_read(&bbio->error) > bbio->max_errors) { in btrfs_end_bio()
6383 btrfs_end_bbio(bbio, bio); in btrfs_end_bio()
6389 static void submit_stripe_bio(struct btrfs_bio *bbio, struct bio *bio, in submit_stripe_bio() argument
6392 struct btrfs_fs_info *fs_info = bbio->fs_info; in submit_stripe_bio()
6394 bio->bi_private = bbio; in submit_stripe_bio()
6410 static void bbio_error(struct btrfs_bio *bbio, struct bio *bio, u64 logical) in bbio_error() argument
6412 atomic_inc(&bbio->error); in bbio_error()
6413 if (atomic_dec_and_test(&bbio->stripes_pending)) { in bbio_error()
6415 WARN_ON(bio != bbio->orig_bio); in bbio_error()
6417 btrfs_io_bio(bio)->mirror_num = bbio->mirror_num; in bbio_error()
6419 if (atomic_read(&bbio->error) > bbio->max_errors) in bbio_error()
6423 btrfs_end_bbio(bbio, bio); in bbio_error()
6438 struct btrfs_bio *bbio = NULL; in btrfs_map_bio() local
6445 &map_length, &bbio, mirror_num, 1); in btrfs_map_bio()
6451 total_devs = bbio->num_stripes; in btrfs_map_bio()
6452 bbio->orig_bio = first_bio; in btrfs_map_bio()
6453 bbio->private = first_bio->bi_private; in btrfs_map_bio()
6454 bbio->end_io = first_bio->bi_end_io; in btrfs_map_bio()
6455 bbio->fs_info = fs_info; in btrfs_map_bio()
6456 atomic_set(&bbio->stripes_pending, bbio->num_stripes); in btrfs_map_bio()
6458 if ((bbio->map_type & BTRFS_BLOCK_GROUP_RAID56_MASK) && in btrfs_map_bio()
6463 ret = raid56_parity_write(fs_info, bio, bbio, in btrfs_map_bio()
6466 ret = raid56_parity_recover(fs_info, bio, bbio, in btrfs_map_bio()
6482 dev = bbio->stripes[dev_nr].dev; in btrfs_map_bio()
6487 bbio_error(bbio, first_bio, logical); in btrfs_map_bio()
6496 submit_stripe_bio(bbio, bio, bbio->stripes[dev_nr].physical, dev); in btrfs_map_bio()