These two functions will write flags to all supers before and after
fsid/chunk tree id change, informing kernel not to mount a inconsistent
fs.
Signed-off-by: Qu Wenruo <quwenruo@xxxxxxxxxxxxxx>
---
v2:
Newly introduced to inform kernel and progs not to open fs with
unfinished uuid change.
---
props.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/props.c b/props.c
index 59e09b3..0a1bc1e 100644
--- a/props.c
+++ b/props.c
@@ -351,6 +351,38 @@ out:
return ret;
}
+static int change_id_prepare(struct btrfs_fs_info *fs_info)
+{
+ u64 flags = btrfs_super_flags(fs_info->super_copy);
+
+ if (!fs_info->new_fsid && !fs_info->new_chunk_tree_uuid)
+ return 0;
+
+ if (fs_info->new_fsid)
+ flags |= BTRFS_SUPER_FLAG_CHANGING_FSID;
+ if (fs_info->new_chunk_tree_uuid)
+ flags |= BTRFS_SUPER_FLAG_CHANGING_CHUNK_TREE_ID;
+ btrfs_set_super_flags(fs_info->super_copy, flags);
+
+ return write_all_supers(fs_info->tree_root);
+}
+
+static int change_id_done(struct btrfs_fs_info *fs_info)
+{
+ u64 flags = btrfs_super_flags(fs_info->super_copy);
+
+ if (!fs_info->new_fsid && !fs_info->new_chunk_tree_uuid)
+ return 0;
+
+ if (fs_info->new_fsid)
+ flags &= ~BTRFS_SUPER_FLAG_CHANGING_FSID;
+ if (fs_info->new_chunk_tree_uuid)
+ flags &= ~BTRFS_SUPER_FLAG_CHANGING_CHUNK_TREE_ID;
+ btrfs_set_super_flags(fs_info->super_copy, flags);
+
+ return write_all_supers(fs_info->tree_root);
+}
+
const struct prop_handler prop_handlers[] = {
{"ro", "Set/get read-only flag of subvolume.", 0, prop_object_subvol,
prop_read_only},
--
2.4.0
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html