Merge tag 'for-6.2-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
[sfrench/cifs-2.6.git] / fs / btrfs / bio.c
index b8fb7ef6b520600994a33e723d1c44993df13e24..8affc88b0e0a4b68ed61e08fd1552331fd9c8517 100644 (file)
@@ -329,7 +329,16 @@ int btrfs_repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
                                      &map_length, &bioc, mirror_num);
                if (ret)
                        goto out_counter_dec;
-               BUG_ON(mirror_num != bioc->mirror_num);
+               /*
+                * This happens when dev-replace is also running, and the
+                * mirror_num indicates the dev-replace target.
+                *
+                * In this case, we don't need to do anything, as the read
+                * error just means the replace progress hasn't reached our
+                * read range, and later replace routine would handle it well.
+                */
+               if (mirror_num != bioc->mirror_num)
+                       goto out_counter_dec;
        }
 
        sector = bioc->stripes[bioc->mirror_num - 1].physical >> 9;