diff options
author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2015-05-13 16:41:51 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2015-05-14 15:41:08 +0200 |
commit | d275dbd1832bcfad6338dd14d16d619fd016b94a (patch) | |
tree | 4c13f0453df0c9b74b1a3b889de60b8552b5abc6 /btrfstune.c | |
parent | 01cdf01ecfb66dac2a66c88f54f3b91039604a90 (diff) |
btrfs-progs: Introduce change_fsid_prepare and change_fsid_done functions
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>
[removed chunk tree super flag]
Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'btrfstune.c')
-rw-r--r-- | btrfstune.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/btrfstune.c b/btrfstune.c index 77a8b7ac..9a63f41b 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -262,6 +262,34 @@ out: return ret; } +static int change_fsid_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; + btrfs_set_super_flags(fs_info->super_copy, flags); + + return write_all_supers(fs_info->tree_root); +} + +static int change_fsid_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; + btrfs_set_super_flags(fs_info->super_copy, flags); + + return write_all_supers(fs_info->tree_root); +} + static void print_usage(void) { fprintf(stderr, "usage: btrfstune [options] device\n"); |