linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: When devices with same dev uuid occurs, only add the one with largest generation.
@ 2014-06-10  8:53 Qu Wenruo
  2014-06-13  4:35 ` Anand Jain
  0 siblings, 1 reply; 2+ messages in thread
From: Qu Wenruo @ 2014-06-10  8:53 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Anand Jain

Since btrfs currently use dulicated dev uuid when doing device replace,
the following problem will happen:

1) mount with device A missing using degraded mode.
2) replace device A with device B.
3) device A reappears.
4) umount btrfs fs.
5) mount btrfs fs.

After step 5), btrfs will still use device A even device B has a larger
generation.

The patch will judge generation when difference device with same dev
uuid.
And the patch should be applied after Anand's patch:
https://patchwork.kernel.org/patch/4309651/

Cc: Anand Jain <Anand.Jain@oracle.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 fs/btrfs/volumes.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 0a5017a..07f0cf7 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -508,7 +508,8 @@ static noinline int device_list_add(const char *path,
 
 		ret = 1;
 		device->fs_devices = fs_devices;
-	} else if (!device->name || strcmp(device->name->str, path)) {
+	} else if (!device->name || (strcmp(device->name->str, path) &&
+		   found_transid > device->generation)) {
 		/*
 		 * When FS is already mounted.
 		 * 1. If you are here and if the device->name is NULL that means
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-13  4:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-10  8:53 [PATCH] btrfs: When devices with same dev uuid occurs, only add the one with largest generation Qu Wenruo
2014-06-13  4:35 ` Anand Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).