summaryrefslogtreecommitdiff
path: root/disk-io.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fb.com>2015-02-03 09:48:57 -0500
committerJosef Bacik <jbacik@fb.com>2015-02-09 14:53:15 -0500
commit34a5ec12eedbd13f47c92108e4fb27e08598219a (patch)
treec11c54bc5f5fc737e50d8ed0a98c5175079f88a9 /disk-io.c
parentc6b388ef2d2bf0f7ff8d87fe82cdeddb6427eb67 (diff)
downloadbtrfs-progs-34a5ec12eedbd13f47c92108e4fb27e08598219a.tar.gz
Btrfs-progs: skip opening all devices with restore
When we go to fixup the dev items after a restore we scan all existing devices. If you happen to be a btrfs developer you could possibly open up some random device that you didn't just restore onto, which gives you weird errors and makes you super cranky and waste a day trying to figure out what is failing. This will make it so that we use the fd we've already opened for opening our ctree. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com>
Diffstat (limited to 'disk-io.c')
-rw-r--r--disk-io.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/disk-io.c b/disk-io.c
index ca39f17..0aec56e 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -1006,7 +1006,8 @@ void btrfs_cleanup_all_caches(struct btrfs_fs_info *fs_info)
int btrfs_scan_fs_devices(int fd, const char *path,
struct btrfs_fs_devices **fs_devices,
- u64 sb_bytenr, int super_recover)
+ u64 sb_bytenr, int super_recover,
+ int skip_devices)
{
u64 total_devs;
u64 dev_size;
@@ -1033,7 +1034,7 @@ int btrfs_scan_fs_devices(int fd, const char *path,
return ret;
}
- if (total_devs != 1) {
+ if (!skip_devices && total_devs != 1) {
ret = btrfs_scan_lblkid();
if (ret)
return ret;
@@ -1114,7 +1115,8 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path,
fs_info->on_restoring = 1;
ret = btrfs_scan_fs_devices(fp, path, &fs_devices, sb_bytenr,
- (flags & OPEN_CTREE_RECOVER_SUPER));
+ (flags & OPEN_CTREE_RECOVER_SUPER),
+ (flags & OPEN_CTREE_NO_DEVICES));
if (ret)
goto out;