aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne Jansen <sensille@gmx.net>2012-02-25 03:09:47 -0500
committerDavid Sterba <dsterba@suse.cz>2012-04-18 13:12:44 -0400
commit207a232ccac0a8cb79d304bd17298dbc96e2e082 (patch)
treebaed843e078e80d04ff28054751dea22e98bea0b
parent8c9c2bf7a3c4f7e9d158c0be9c49f372fb943ad2 (diff)
btrfs: don't add both copies of DUP to reada extent tree
Normally when there are 2 copies of a block, we add both to the reada extent tree and prefetch only the one that is easier to reach. This way we can better utilize multiple devices. In case of DUP this makes no sense as both copies reside on the same device. Signed-off-by: Arne Jansen <sensille@gmx.net>
-rw-r--r--fs/btrfs/reada.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index 8dec650099c..ac5d0108588 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -326,6 +326,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
326 struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree; 326 struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree;
327 struct btrfs_bio *bbio = NULL; 327 struct btrfs_bio *bbio = NULL;
328 struct btrfs_device *dev; 328 struct btrfs_device *dev;
329 struct btrfs_device *prev_dev;
329 u32 blocksize; 330 u32 blocksize;
330 u64 length; 331 u64 length;
331 int nzones = 0; 332 int nzones = 0;
@@ -405,8 +406,20 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
405 spin_unlock(&fs_info->reada_lock); 406 spin_unlock(&fs_info->reada_lock);
406 goto error; 407 goto error;
407 } 408 }
409 prev_dev = NULL;
408 for (i = 0; i < nzones; ++i) { 410 for (i = 0; i < nzones; ++i) {
409 dev = bbio->stripes[i].dev; 411 dev = bbio->stripes[i].dev;
412 if (dev == prev_dev) {
413 /*
414 * in case of DUP, just add the first zone. As both
415 * are on the same device, there's nothing to gain
416 * from adding both.
417 * Also, it wouldn't work, as the tree is per device
418 * and adding would fail with EEXIST
419 */
420 continue;
421 }
422 prev_dev = dev;
410 ret = radix_tree_insert(&dev->reada_extents, index, re); 423 ret = radix_tree_insert(&dev->reada_extents, index, re);
411 if (ret) { 424 if (ret) {
412 while (--i >= 0) { 425 while (--i >= 0) {