From ab747f84cad2047dcc7eb2850f4c9251437eb50b Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Fri, 15 May 2015 14:36:35 +0800 Subject: btrfs-progs: btrfstune: fix a bug which makes unfinished fsid change unrecoverable This bug is found by making break point after change_fsid_prepare() and then kill the unfinished change, then try to restore the unfinished fsid change. If fsid change is canceled, open_ctree will still fail even with IGNORE_FSID_MIMATCH open ctree flag, since it can't find device with mismatched fsid, making it unable to restoring. Now add ignore_fsid_mismatch judgment in btrfs_find_device() to fix the bug and allow later restore to work as expected. Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- volumes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'volumes.c') diff --git a/volumes.c b/volumes.c index 14ce33ef..f7462c58 100644 --- a/volumes.c +++ b/volumes.c @@ -1510,7 +1510,8 @@ struct btrfs_device *btrfs_find_device(struct btrfs_root *root, u64 devid, cur_devices = root->fs_info->fs_devices; while (cur_devices) { if (!fsid || - !memcmp(cur_devices->fsid, fsid, BTRFS_UUID_SIZE)) { + (!memcmp(cur_devices->fsid, fsid, BTRFS_UUID_SIZE) || + root->fs_info->ignore_fsid_mismatch)) { device = __find_device(&cur_devices->devices, devid, uuid); if (device) -- cgit v1.2.3