diff mbox series

[03/11] btrfs-progs: metadata_uuid: add new member btrfs_fs_devices::fsid_change

Message ID 20191212110204.11128-4-Damenly_Su@gmx.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: metadata_uuid feature fixes and portation | expand

Commit Message

Su Yue Dec. 12, 2019, 11:01 a.m. UTC
From: Su Yue <Damenly_Su@gmx.com>

Like what is done in kernel, we need extra information for split-brain
cases.
The new member btrfs_fs_devices::fsid_change records whether the
devices are with FSID_CHANGING_V2 flag.

The existing btrfs_fs_devices::last_transid can be used like the
last_generation field in kernel. It records the highest generation of
the fs_devices.

Signed-off-by: Su Yue <Damenly_Su@gmx.com>
---
 volumes.c | 4 +++-
 volumes.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/volumes.c b/volumes.c
index 143164f02ac0..88e926e98d5b 100644
--- a/volumes.c
+++ b/volumes.c
@@ -214,7 +214,8 @@  static int device_list_add(const char *path,
 	u64 found_transid = btrfs_super_generation(disk_super);
 	bool metadata_uuid = (btrfs_super_incompat_flags(disk_super) &
 		BTRFS_FEATURE_INCOMPAT_METADATA_UUID);
-
+	bool fsid_change_in_progress = (btrfs_super_flags(disk_super) &
+					BTRFS_SUPER_FLAG_CHANGING_FSID_V2);
 	if (metadata_uuid)
 		fs_devices = find_fsid(disk_super->fsid,
 				       disk_super->metadata_uuid);
@@ -238,6 +239,7 @@  static int device_list_add(const char *path,
 		fs_devices->latest_devid = devid;
 		fs_devices->latest_trans = found_transid;
 		fs_devices->lowest_devid = (u64)-1;
+		fs_devices->fsid_change = fsid_change_in_progress;
 		device = NULL;
 	} else {
 		device = find_device(fs_devices, devid,
diff --git a/volumes.h b/volumes.h
index 41574f21dd23..1c734b515346 100644
--- a/volumes.h
+++ b/volumes.h
@@ -72,6 +72,7 @@  struct btrfs_device {
 struct btrfs_fs_devices {
 	u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
 	u8 metadata_uuid[BTRFS_FSID_SIZE]; /* FS specific uuid */
+	bool fsid_change;
 
 	/* the device with this id has the most recent copy of the super */
 	u64 latest_devid;