@@ -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},
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@cn.fujitsu.com> --- v2: Newly introduced to inform kernel and progs not to open fs with unfinished uuid change. --- props.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)