linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]btrfs: Fix fstest case btrfs/219
@ 2022-07-21  8:36 Flint.Wang
  2022-07-21 13:37 ` Nikolay Borisov
  0 siblings, 1 reply; 7+ messages in thread
From: Flint.Wang @ 2022-07-21  8:36 UTC (permalink / raw)
  To: anand.jain
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, linux-kernel

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.

Signed-off-by: Flint.Wang <hmsjwzb@zoho.com>
---
 fs/btrfs/volumes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 6aa6bc769569a..76af32032ac85 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -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
-- 
2.37.0


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

end of thread, other threads:[~2022-08-03  6:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-21  8:36 [PATCH]btrfs: Fix fstest case btrfs/219 Flint.Wang
2022-07-21 13:37 ` Nikolay Borisov
2022-07-22  5:34   ` hmsjwzb
2022-07-22  8:52     ` Nikolay Borisov
2022-07-26 18:38     ` David Sterba
2022-08-03  6:19       ` Anand Jain
2022-07-27  9:16     ` [PATCH] btrfs/219: fix problems with mount old generation Flint.Wang

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).