From: damenly.su@gmail.com
To: linux-btrfs@vger.kernel.org
Cc: Su Yue <Damenly_Su@gmx.com>
Subject: [PATCH 4/6] btrfs: split-brain case for scanned changed device without INCOMPAT_METADATA_UUID
Date: Thu, 12 Dec 2019 19:01:30 +0800 [thread overview]
Message-ID: <20191212110132.11063-5-Damenly_Su@gmx.com> (raw)
In-Reply-To: <20191212110132.11063-1-Damenly_Su@gmx.com>
From: Su Yue <Damenly_Su@gmx.com>
This patch adds the case for scanned not changing device without
INCOMPAT_METADATA_UUID.
For this situation, the origin code only handles the case
the devices already pulled into disk with INCOMPAT_METADATA_UUID set.
There is an another case that the successful changed devices synced
without INCOMPAT_METADATA_UUID. And the scanned device is the exactly
changed one.
So we should check if there is any changing fs_devices with
INCOMPAT_METADATA_UUID.
Signed-off-by: Su Yue <Damenly_Su@gmx.com>
---
fs/btrfs/volumes.c | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 61b4a107bb58..faf9cdd14f33 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -741,6 +741,35 @@ static struct btrfs_fs_devices *find_fsid_changing_metada_uuid(
return find_fsid(disk_super->fsid, disk_super->metadata_uuid);
}
+static struct btrfs_fs_devices *find_fsid_changing(
+ struct btrfs_super_block *disk_super)
+{
+ struct btrfs_fs_devices *fs_devices;
+
+ /*
+ * Handles the case where scanned device is part of an fs that had
+ * multiple successful changes of FSID but currently device didn't
+ * observe it.
+ * Since the scanned devices does not own the metadata_uuid feature,
+ * fsid and metadata_uuid of the changing devices must differ, and
+ * their metadata_uuid must be same as disk_super->fsid.
+ */
+ list_for_each_entry(fs_devices, &fs_uuids, fs_list) {
+ if (!fs_devices->fsid_change)
+ continue;
+ if (memcmp(fs_devices->fsid, fs_devices->metadata_uuid,
+ BTRFS_FSID_SIZE) != 0 &&
+ memcmp(fs_devices->metadata_uuid, disk_super->fsid,
+ BTRFS_FSID_SIZE) == 0)
+ return fs_devices;
+ }
+
+ /*
+ * Back to find newer fs_devices is changeing or some in same stage.
+ */
+ return find_fsid(disk_super->fsid, NULL);
+}
+
/*
* Add new device to list of registered devices
*
@@ -782,7 +811,7 @@ static noinline struct btrfs_device *device_list_add(const char *path,
} else if (has_metadata_uuid) {
fs_devices = find_fsid_changing_metada_uuid(disk_super);
} else {
- fs_devices = find_fsid(disk_super->fsid, NULL);
+ fs_devices = find_fsid_changing(disk_super);
}
if (!fs_devices) {
--
2.21.0 (Apple Git-122.2)
next prev parent reply other threads:[~2019-12-12 11:01 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-12 11:01 [PATCH 0/6] btrfs: metadata uuid fixes and enhancements damenly.su
2019-12-12 11:01 ` [PATCH 1/6] btrfs: metadata_uuid: fix failed assertion due to unsuccessful device scan damenly.su
2019-12-12 14:15 ` Nikolay Borisov
2019-12-13 2:30 ` Su Yue
2019-12-13 2:46 ` [PATCH 1/6] btrfs: metadata_uuid: fix failed assertion due to unsuccessful device scan (reformatted) Su Yue
2019-12-13 5:36 ` Anand Jain
2019-12-13 7:15 ` Su Yue
2019-12-13 8:51 ` Anand Jain
2019-12-13 10:10 ` Su Yue
2019-12-12 11:01 ` [PATCH 2/6] btrfs: metadata_uuid: move split-brain handling from fs_id() to new function damenly.su
2019-12-12 13:05 ` Nikolay Borisov
2019-12-12 13:32 ` Su Yue
2019-12-12 11:01 ` [PATCH 3/6] btrfs: split-brain case for scanned changing device with INCOMPAT_METADATA_UUID damenly.su
2019-12-12 13:24 ` Su Yue
2019-12-12 13:34 ` Nikolay Borisov
2019-12-12 14:19 ` Su Yue
2019-12-12 11:01 ` damenly.su [this message]
2019-12-12 11:01 ` [PATCH 5/6] btrfs: copy fsid and metadata_uuid for pulled disk without INCOMPAT_METADATA_UUID damenly.su
2020-01-06 15:12 ` Nikolay Borisov
2020-01-07 1:31 ` Su Yue
2020-01-07 7:18 ` Nikolay Borisov
2020-01-07 7:34 ` Su Yue
2019-12-12 11:01 ` [PATCH 6/6] btrfs: metadata_uuid: move partly logic into find_fsid_inprogress() damenly.su
2019-12-12 13:37 ` Nikolay Borisov
2019-12-13 8:03 ` [PATCH 0/6] btrfs: metadata uuid fixes and enhancements Nikolay Borisov
2019-12-16 0:49 ` Su Yue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191212110132.11063-5-Damenly_Su@gmx.com \
--to=damenly.su@gmail.com \
--cc=Damenly_Su@gmx.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox