All of lore.kernel.org
 help / color / mirror / Atom feed
* BUG: btrfs confused by two different fs with the same UUID mounted in different moment
@ 2021-12-14 22:45 Goffredo Baroncelli
  2021-12-15 14:24 ` Nikolay Borisov
  0 siblings, 1 reply; 2+ messages in thread
From: Goffredo Baroncelli @ 2021-12-14 22:45 UTC (permalink / raw)
  To: linux-btrfs

Hi all,

I found this bug during a develop of a test for BTRFS. Steps to reproduce


# create a filesystem with TWO loop-devices; mount it then *destroy it*
UUID=292afefb-6e8c-4fb3-9d12-8c4ecb1f2374
rm /tmp/d1
rm /tmp/d2
truncate -s 1G /tmp/d1
truncate -s 1G /tmp/d2
sudo losetup /dev/loop1 /tmp/d1
sudo losetup /dev/loop2 /tmp/d2
sudo mkfs.btrfs -U $UUID /dev/loop1 /dev/loop2
sudo mount /dev/loop1 /mnt/btrfs1
sudo umount /dev/loop1
sudo losetup -d /dev/loop2	# <---- NOTE HERE
sudo losetup -d /dev/loop1	# <---- NOTE HERE

# create a new filesystem with only ONE loop-device; mount it
rm /tmp/d1
truncate -s 1G /tmp/d1
sudo losetup /dev/loop1 /tmp/d1
sudo mkfs.btrfs -U $UUID /dev/loop1
sudo mount /dev/loop1 /mnt/btrfs1

# BUG: now under $UUID/devinfo there are TWO devices
# expected behavior: only one device is showed
ls /sys/fs/btrfs/$UUID/devinfo
1  2

# under $UUID/devices there is ONE device1
ls /sys/fs/btrfs/$UUID/devices
loop1



Obviously this is caused by the fact that the two filesystem have the same UUID. However I think that in any case $UUID/devices and $UUID/devinfo should show the same devices.


BR

-- 
gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5

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

* Re: BUG: btrfs confused by two different fs with the same UUID mounted in different moment
  2021-12-14 22:45 BUG: btrfs confused by two different fs with the same UUID mounted in different moment Goffredo Baroncelli
@ 2021-12-15 14:24 ` Nikolay Borisov
  0 siblings, 0 replies; 2+ messages in thread
From: Nikolay Borisov @ 2021-12-15 14:24 UTC (permalink / raw)
  To: kreijack, linux-btrfs



On 15.12.21 г. 0:45, Goffredo Baroncelli wrote:
> Hi all,
> 
> I found this bug during a develop of a test for BTRFS. Steps to reproduce
> 
> 
> # create a filesystem with TWO loop-devices; mount it then *destroy it*
> UUID=292afefb-6e8c-4fb3-9d12-8c4ecb1f2374
> rm /tmp/d1
> rm /tmp/d2
> truncate -s 1G /tmp/d1
> truncate -s 1G /tmp/d2
> sudo losetup /dev/loop1 /tmp/d1
> sudo losetup /dev/loop2 /tmp/d2
> sudo mkfs.btrfs -U $UUID /dev/loop1 /dev/loop2
> sudo mount /dev/loop1 /mnt/btrfs1
> sudo umount /dev/loop1
> sudo losetup -d /dev/loop2    # <---- NOTE HERE
> sudo losetup -d /dev/loop1    # <---- NOTE HERE
> 
> # create a new filesystem with only ONE loop-device; mount it
> rm /tmp/d1
> truncate -s 1G /tmp/d1
> sudo losetup /dev/loop1 /tmp/d1
> sudo mkfs.btrfs -U $UUID /dev/loop1
> sudo mount /dev/loop1 /mnt/btrfs1
> 
> # BUG: now under $UUID/devinfo there are TWO devices
> # expected behavior: only one device is showed
> ls /sys/fs/btrfs/$UUID/devinfo
> 1  2
> 
> # under $UUID/devices there is ONE device1
> ls /sys/fs/btrfs/$UUID/devices
> loop1
> 
> 
> 
> Obviously this is caused by the fact that the two filesystem have the
> same UUID. However I think that in any case $UUID/devices and
> $UUID/devinfo should show the same devices.


You are right, this happens because essentially loop2 becomes stale from
the POV of the 2nd filesystem. One way to fix this would be to run

btrfs device scan -u - which will scann all devices and forget stale
ones. But in any case in the presence of stale devices we shouldn't be
adding one to devinfo. I will send a patch in a bit.

> 
> 
> BR
> 

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

end of thread, other threads:[~2021-12-15 14:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 22:45 BUG: btrfs confused by two different fs with the same UUID mounted in different moment Goffredo Baroncelli
2021-12-15 14:24 ` Nikolay Borisov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.