Skip to contentSkip to conversation

Fix fstest case btrfs/219

PATCH New Flint.Wang 1 participant 1 message Jul 21, 2022 Btrfs file system

lore
Share & tools
lore

Flint.Wang

author
#0 lore raw

PATCH 1/1 Fix fstest case btrfs/219

Hi,
fstest btrfs/291 failed.

[How to reproduce]
mkdir -p /mnt/test/219.mnt
xfs_io -f -c "truncate 256m" /mnt/test/219.img1 mkfs.btrfs /mnt/test/219.img1
cp /mnt/test/219.img1 /mnt/test/219.img2 mount -o loop /mnt/test/219.img1 /mnt/test/219.mnt umount /mnt/test/219.mnt
losetup -f --show /mnt/test/219.img1 dev mount /dev/loop0 /mnt/test/219.mnt
umount /mnt/test/219.mnt
mount -o loop /mnt/test/219.img2 /mnt/test/219.mnt

[Root cause]
if (fs_devices->opened && found_transid < device->generation) {
/*
* That is if the FS is _not_ mounted and if you
* are here, that means there is more than one
* disk with same uuid and devid.We keep the one
* with larger generation number or the last-in if
* generation are equal.
*/
mutex_unlock(&fs_devices->device_list_mutex); return ERR_PTR(-EEXIST);
}

[Personal opinion]
User might back up a block device to another. I think it is improper to forbid user from mounting it.

---
 fs/btrfs/volumes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/volumes.c +1 -1
index 6aa6bc769569a..76af32032ac85 100644
@@ -900,7 +900,7 @@ static noinline struct btrfs_device *device_list_add(const char *path,
 		 * tracking a problem where systems fail mount by subvolume id
 		 * when we reject replacement on a mounted FS.
 		 */
-		if (!fs_devices->opened && found_transid < device->generation) {
+		if (fs_devices->opened && found_transid < device->generation) {
 			/*
 			 * That is if the FS is _not_ mounted and if you
 			 * are here, that means there is more than one
Signature · 1 line
2.37.0