Thread (2 messages) 2 messages, 2 authors, 2021-12-15

Re: BUG: btrfs confused by two different fs with the same UUID mounted in different moment

From: Nikolay Borisov <hidden>
Date: 2021-12-15 14:24:28


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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help