Skip to content

Commit 6a159d2

Browse files
zhaoleiddkdave
authored andcommitted
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 <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent a3f7fde commit 6a159d2

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

fs/btrfs/reada.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
328328
u64 length;
329329
int real_stripes;
330330
int nzones = 0;
331-
int i;
332331
unsigned long index = logical >> PAGE_CACHE_SHIFT;
333332
int dev_replace_is_ongoing;
334333

@@ -375,9 +374,9 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
375374
dev = bbio->stripes[nzones].dev;
376375
zone = reada_find_zone(fs_info, dev, logical, bbio);
377376
if (!zone)
378-
break;
377+
continue;
379378

380-
re->zones[nzones] = zone;
379+
re->zones[re->nzones++] = zone;
381380
spin_lock(&zone->lock);
382381
if (!zone->elems)
383382
kref_get(&zone->refcnt);
@@ -387,8 +386,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
387386
kref_put(&zone->refcnt, reada_zone_release);
388387
spin_unlock(&fs_info->reada_lock);
389388
}
390-
re->nzones = nzones;
391-
if (nzones == 0) {
389+
if (re->nzones == 0) {
392390
/* not a single zone found, error and out */
393391
goto error;
394392
}
@@ -413,8 +411,9 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
413411
prev_dev = NULL;
414412
dev_replace_is_ongoing = btrfs_dev_replace_is_ongoing(
415413
&fs_info->dev_replace);
416-
for (i = 0; i < nzones; ++i) {
417-
dev = bbio->stripes[i].dev;
414+
for (nzones = 0; nzones < re->nzones; ++nzones) {
415+
dev = re->zones[nzones]->device;
416+
418417
if (dev == prev_dev) {
419418
/*
420419
* 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,
445444
prev_dev = dev;
446445
ret = radix_tree_insert(&dev->reada_extents, index, re);
447446
if (ret) {
448-
while (--i >= 0) {
449-
dev = bbio->stripes[i].dev;
447+
while (--nzones >= 0) {
448+
dev = re->zones[nzones]->device;
450449
BUG_ON(dev == NULL);
451450
/* ignore whether the entry was inserted */
452451
radix_tree_delete(&dev->reada_extents, index);
@@ -465,10 +464,9 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
465464
return re;
466465

467466
error:
468-
while (nzones) {
467+
for (nzones = 0; nzones < re->nzones; ++nzones) {
469468
struct reada_zone *zone;
470469

471-
--nzones;
472470
zone = re->zones[nzones];
473471
kref_get(&zone->refcnt);
474472
spin_lock(&zone->lock);

0 commit comments

Comments
 (0)