Skip to content

Commit

Permalink
Btrfs-progs: try other mirrors on read failure
Browse files Browse the repository at this point in the history
If we hit a bad disk and the read doesn't work, try other mirrors in case we
have other disks with good copies.  Thanks,

Signed-off-by: Josef Bacik <[email protected]>
  • Loading branch information
Josef Bacik authored and kdave committed Mar 18, 2013
1 parent 9969ea4 commit 23bfbf0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cmds-restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,16 @@ static int copy_one_extent(struct btrfs_root *root, int fd,

done = pread(dev_fd, inbuf+count, length, dev_bytenr);
if (done < length) {
ret = -1;
fprintf(stderr, "Short read %d\n", errno);
goto out;
num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
bytenr, length);
mirror_num++;
if (mirror_num >= num_copies) {
ret = -1;
fprintf(stderr, "Exhausted mirrors trying to read\n");
goto out;
}
fprintf(stderr, "Trying another mirror\n");
goto again;
}

count += length;
Expand Down

0 comments on commit 23bfbf0

Please sign in to comment.