Skip to contentSkip to conversation

Discrepant st_rdev and st_dev stats in btrfs block and fs device ids

DISCUSSION Marcus 3 participants 3 messages Sep 6, 2009 – Sep 7, 2009 Btrfs file system

lore
Share & tools
lore

Marcus

author
#0 lore raw

Hello,

I think I found a btrfs 0.19 problem when used in an lvm2 volume; btrfs is returning a st_dev stat from the mounted filesystem / that is different from the lvm2 blockdevice st_rdev stat in /dev/mapper/vg0-os0.

This btrfs behavior is different from ext4, where the st_dev and st_rdev stats match (http://pastebin.com/m64e90a8e or a summary below). Because of that, in grub2, 'grub-probe -t device / ' fails with ' grub-probe: error: cannot find a device for /. ' , and so update-grub2 fails causing cascading problems all around.

Can anyone repeat this? Any ideas why this could be happening? Is this = expected?

Thanks,
Marcus
--

# uname -a
Linux frog 2.6.31-9-generic #29-Ubuntu SMP Sun Aug 30 17:39:23 UTC
2009 i686 GNU/Linux
# btrfs-show
Label: none=A0 uuid: c5bffbe1-6968-4eee-a800-8346df56459a
=A0=A0=A0 Total devices 1 FS bytes used 2.15GB
=A0=A0=A0 devid=A0=A0=A0 1 size 10.00GB used 10.00GB path /dev/mapper/v=
g0-os0
Btrfs Btrfs v0.19
# mount
/dev/mapper/vg0-os0 on / type btrfs (rw,errors=3Dremount-ro)
/dev/mapper/vg0-os0 on /tmp/os0 type btrfs (rw)
/dev/mapper/vg0-os1 on /tmp/os1 type ext4 (rw)

stat.st_rdev for /dev/mapper/vg0-os0:64512
stat.st_rdev for /dev/mapper/vg0-os1:64513
stat.st_dev for /:16
stat.st_dev for /tmp/os0:16
stat.st_dev for /tmp/os1:64513

--
PS:
Btw, in case someone else comes across this problem, a quick workaround for grub2 is to modify /usr/sbin/grub-mkconfig so that GRUB_DEVICE points directly to your btrfs lvm2 block device:

# diff grub-mkconfig.orig grub-mkconfig
1122c122
< GRUB_DEVICE=3D"`${grub_probe} --target=3Ddevice /`"
---
Quoted 1 line

GRUB_DEVICE=3D"/dev/mapper/vg0-os0"

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

#1 lore raw
Quoted 7 lines · Marcus

Hello,

I think I found a btrfs 0.19 problem when used in an lvm2 volume; btrfs is returning a st_dev stat from the mounted filesystem / that is different from the lvm2 blockdevice st_rdev stat in /dev/mapper/vg0-os0.

Quoted 8 lines

This btrfs behavior is different from ext4, where the st_dev and st_rdev stats match (http://pastebin.com/m64e90a8e or a summary below). Because of that, in grub2, 'grub-probe -t device / ' fails with ' grub-probe: error: cannot find a device for /. ' , and so update-grub2 fails causing cascading problems all around.

Can anyone repeat this? Any ideas why this could be happening? Is this expected?

Yes this is expected. Because of the way that btrfs can have multiple disks and snapshot and such, it creates this sort of virtual device as its backing device in the kernel to keep track of everything, so it's st_dev will not match the actual device it resides on. Thanks,

Josef

#2 lore raw
In reply to Marcus

Hey,

Quoted 2 lines

Can anyone repeat this? Any ideas why this could be happening? Is this expected?

There was some discussion about this some time ago, see

http://news.gmane.org/find-root.php?message_id=%3c7b13a0f80904120735r41736455hb7e226ab8ad30bd7%40mail.gmail.com%3e

I don't think it's resolved yet - the work-around I currently use in devkit-disks-daemon (which is used by e.g. GNOME to show names and icons for storage devices) looks like this:

http://cgit.freedesktop.org/DeviceKit/DeviceKit-disks/tree/src/devkit-disks-mount-monitor.c?id=006#n351

and I don't think this will work for multi-disk btrfs filesystems. Thinking about this again, we probably want to treat such btrfs multi-disk filesystems in the UI the same way we treat e.g. md raid devices....

David