btrfs: reada: add all reachable mirrors into reada device list
If some device is not reachable, we should bypass and continus addingb next, instead of break on bad device. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
a3f7fde243
commit
6a159d2ae4
@ -328,7 +328,6 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
|
|||||||
u64 length;
|
u64 length;
|
||||||
int real_stripes;
|
int real_stripes;
|
||||||
int nzones = 0;
|
int nzones = 0;
|
||||||
int i;
|
|
||||||
unsigned long index = logical >> PAGE_CACHE_SHIFT;
|
unsigned long index = logical >> PAGE_CACHE_SHIFT;
|
||||||
int dev_replace_is_ongoing;
|
int dev_replace_is_ongoing;
|
||||||
|
|
||||||
@ -375,9 +374,9 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
|
|||||||
dev = bbio->stripes[nzones].dev;
|
dev = bbio->stripes[nzones].dev;
|
||||||
zone = reada_find_zone(fs_info, dev, logical, bbio);
|
zone = reada_find_zone(fs_info, dev, logical, bbio);
|
||||||
if (!zone)
|
if (!zone)
|
||||||
break;
|
continue;
|
||||||
|
|
||||||
re->zones[nzones] = zone;
|
re->zones[re->nzones++] = zone;
|
||||||
spin_lock(&zone->lock);
|
spin_lock(&zone->lock);
|
||||||
if (!zone->elems)
|
if (!zone->elems)
|
||||||
kref_get(&zone->refcnt);
|
kref_get(&zone->refcnt);
|
||||||
@ -387,8 +386,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
|
|||||||
kref_put(&zone->refcnt, reada_zone_release);
|
kref_put(&zone->refcnt, reada_zone_release);
|
||||||
spin_unlock(&fs_info->reada_lock);
|
spin_unlock(&fs_info->reada_lock);
|
||||||
}
|
}
|
||||||
re->nzones = nzones;
|
if (re->nzones == 0) {
|
||||||
if (nzones == 0) {
|
|
||||||
/* not a single zone found, error and out */
|
/* not a single zone found, error and out */
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -413,8 +411,9 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
|
|||||||
prev_dev = NULL;
|
prev_dev = NULL;
|
||||||
dev_replace_is_ongoing = btrfs_dev_replace_is_ongoing(
|
dev_replace_is_ongoing = btrfs_dev_replace_is_ongoing(
|
||||||
&fs_info->dev_replace);
|
&fs_info->dev_replace);
|
||||||
for (i = 0; i < nzones; ++i) {
|
for (nzones = 0; nzones < re->nzones; ++nzones) {
|
||||||
dev = bbio->stripes[i].dev;
|
dev = re->zones[nzones]->device;
|
||||||
|
|
||||||
if (dev == prev_dev) {
|
if (dev == prev_dev) {
|
||||||
/*
|
/*
|
||||||
* in case of DUP, just add the first zone. As both
|
* in case of DUP, just add the first zone. As both
|
||||||
@ -445,8 +444,8 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
|
|||||||
prev_dev = dev;
|
prev_dev = dev;
|
||||||
ret = radix_tree_insert(&dev->reada_extents, index, re);
|
ret = radix_tree_insert(&dev->reada_extents, index, re);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
while (--i >= 0) {
|
while (--nzones >= 0) {
|
||||||
dev = bbio->stripes[i].dev;
|
dev = re->zones[nzones]->device;
|
||||||
BUG_ON(dev == NULL);
|
BUG_ON(dev == NULL);
|
||||||
/* ignore whether the entry was inserted */
|
/* ignore whether the entry was inserted */
|
||||||
radix_tree_delete(&dev->reada_extents, index);
|
radix_tree_delete(&dev->reada_extents, index);
|
||||||
@ -465,10 +464,9 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
|
|||||||
return re;
|
return re;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
while (nzones) {
|
for (nzones = 0; nzones < re->nzones; ++nzones) {
|
||||||
struct reada_zone *zone;
|
struct reada_zone *zone;
|
||||||
|
|
||||||
--nzones;
|
|
||||||
zone = re->zones[nzones];
|
zone = re->zones[nzones];
|
||||||
kref_get(&zone->refcnt);
|
kref_get(&zone->refcnt);
|
||||||
spin_lock(&zone->lock);
|
spin_lock(&zone->lock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user