[PATCH] btrfs: When devices with same dev uuid occurs, only add the one with largest generation.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Signed-off-by: Qu Wenruo <quwenruo@xxxxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux