if (!path)
return -ENOMEM;
- path->reada = 0;
+ path->reada = 1;
key.objectid = bytenr;
btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY);
key.offset = num_bytes;
btrfs_release_path(root->fs_info->extent_root, path);
- path->reada = 0;
+ path->reada = 1;
ret = btrfs_insert_extent_backref(trans, root->fs_info->extent_root,
path, bytenr, root_objectid,
ref_generation, owner, owner_offset);
WARN_ON(num_bytes < root->sectorsize);
path = btrfs_alloc_path();
- path->reada = 0;
+ path->reada = 1;
key.objectid = bytenr;
key.offset = num_bytes;
btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY);
if (!path)
return -ENOMEM;
- path->reada = 0;
+ path->reada = 1;
ret = lookup_extent_backref(trans, extent_root, path,
bytenr, root_objectid,
ref_generation,
else if (mirror_num) {
stripe_index = mirror_num - 1;
} else {
- int i;
- u64 least = (u64)-1;
- struct btrfs_device *cur;
-
- for (i = 0; i < map->num_stripes; i++) {
- cur = map->stripes[i].dev;
- spin_lock(&cur->io_lock);
- if (cur->total_ios < least) {
- least = cur->total_ios;
- stripe_index = i;
- }
- spin_unlock(&cur->io_lock);
- }
+ u64 orig_stripe_nr = stripe_nr;
+ stripe_index = do_div(orig_stripe_nr, num_stripes);
}
} else if (map->type & BTRFS_BLOCK_GROUP_DUP) {
if (rw & (1 << BIO_RW))
stripe_index = mirror_num - 1;
} else if (map->type & BTRFS_BLOCK_GROUP_RAID10) {
int factor = map->num_stripes / map->sub_stripes;
- int orig_stripe_nr = stripe_nr;
stripe_index = do_div(stripe_nr, factor);
stripe_index *= map->sub_stripes;
num_stripes = map->sub_stripes;
else if (mirror_num)
stripe_index += mirror_num - 1;
- else
- stripe_index += orig_stripe_nr % map->sub_stripes;
+ else {
+ u64 orig_stripe_nr = stripe_nr;
+ stripe_index += do_div(orig_stripe_nr,
+ map->sub_stripes);
+ }
} else {
/*
* after this do_div call, stripe_nr is the number of stripes