summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2018-06-18 17:11:33 +0200
committerDavid Sterba <dsterba@suse.com>2018-08-06 14:59:19 +0200
commit47cbb3c9b26aa60bcffc1809c98268a11f1bf2b5 (patch)
tree714b06e207773f9db3d09ce4c65ebecd433ee4d4
parente7e89d93c284218dafed8caf46835cd3620e5577 (diff)
btrfs-progs: add new flag to read superblock with mismatched fsids
New flag that mimics OPEN_CTREE_IGNORE_FSID_MISMATCH but only for reading the superblock. It should be passed around to various helpers like scan or mount checks as they'd fail before we'd get to the final caller that can do something useful with the filesystem. This will be used for an interrupted 'btrfstune -u'. Note to __open_ctree_fd: the RECOVERY mode is not compatible with that flag Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--disk-io.c3
-rw-r--r--disk-io.h6
2 files changed, 9 insertions, 0 deletions
diff --git a/disk-io.c b/disk-io.c
index 4a609a89..1caa7cd0 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -1125,6 +1125,9 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path,
if (flags & OPEN_CTREE_TEMPORARY_SUPER)
sbflags = SBREAD_TEMPORARY;
+ if (flags & OPEN_CTREE_IGNORE_FSID_MISMATCH)
+ sbflags |= SBREAD_IGNORE_FSID_MISMATCH;
+
ret = btrfs_scan_fs_devices(fp, path, &fs_devices, sb_bytenr, sbflags,
(flags & OPEN_CTREE_NO_DEVICES));
if (ret)
diff --git a/disk-io.h b/disk-io.h
index fefdb0a7..b4a1b104 100644
--- a/disk-io.h
+++ b/disk-io.h
@@ -100,6 +100,12 @@ enum btrfs_read_sb_flags {
* SBREAD_RECOVER
*/
SBREAD_TEMPORARY = (1 << 1),
+
+ /*
+ * Equivalent of OPEN_CTREE_IGNORE_FSID_MISMATCH, allow to read
+ * superblock that has mismatched sb::fsid and sb::dev_item.fsid
+ */
+ SBREAD_IGNORE_FSID_MISMATCH = (1 << 2),
};
/*