All of lore.kernel.org
 help / color / mirror / Atom feed
* Can I see what device was used to mount btrfs?
@ 2017-04-30  5:47 Andrei Borzenkov
  2017-05-02  3:26 ` Anand Jain
  2017-05-02 13:58 ` Adam Borowski
  0 siblings, 2 replies; 17+ messages in thread
From: Andrei Borzenkov @ 2017-04-30  5:47 UTC (permalink / raw)
  To: linux-btrfs

I'm chasing issue with btrfs mounts under systemd
(https://github.com/systemd/systemd/issues/5781) - to summarize, systemd
waits for the final device that makes btrfs complete and mounts it using
this device name. But in /proc/self/mountinfo we actually see another
device name. Due to peculiarities of systemd implementation this device
"does not exist" from systemd PoV.

Looking at btrfs code I start to suspect that we actually do not know
what device was used to mount it at all. I.e.

static int btrfs_show_devname(struct seq_file *m, struct dentry *root)
{
...
        while (cur_devices) {
                head = &cur_devices->devices;
                list_for_each_entry(dev, head, dev_list) {
                        if (dev->missing)
                                continue;
                        if (!dev->name)
                                continue;
                        if (!first_dev || dev->devid < first_dev->devid)
                                first_dev = dev;
                }
                cur_devices = cur_devices->seed;
        }

        if (first_dev) {
                rcu_read_lock();
                name = rcu_dereference(first_dev->name);
                seq_escape(m, name->str, " \t\n\\");
                rcu_read_unlock();
...


So we always show device with the smallest devid, irrespectively of what
device was actually used to mount it.

Am I correct? What I have here is

localhost:~ # ll /dev/disk/by-label/
total 0
lrwxrwxrwx 1 root root 10 Apr 30 08:03 Storage -> ../../dm-1
localhost:~ # systemctl --no-pager status thin.mount
● thin.mount - /thin
   Loaded: loaded (/etc/fstab; generated; vendor preset: disabled)
   Active: active (mounted) since Sun 2017-04-30 08:03:07 MSK; 6min ago
    Where: /thin
     What: /dev/dm-0
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)
  Process: 982 ExecMount=/usr/bin/mount /dev/disk/by-label/Storage /thin
-t btrfs (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/thin.mount

Apr 30 08:03:07 localhost systemd[1]: Mounting /thin...
Apr 30 08:03:07 localhost systemd[1]: Mounted /thin.


bur mountinfo shows

localhost:~ # grep /thin /proc/self/mountinfo
96 59 0:63 / /thin rw,relatime shared:47 - btrfs /dev/dm-0
rw,space_cache,subvolid=5,subvol=/

which matches the above algorithm

localhost:~ # btrfs fi show /thin
Label: 'Storage'  uuid: a6f9dd05-460c-418b-83ab-ebdf81f2931a
	Total devices 2 FS bytes used 640.00KiB
	devid    1 size 20.00GiB used 2.01GiB path /dev/mapper/vg01-storage1
	devid    2 size 10.00GiB used 2.01GiB path /dev/mapper/vg01-storage2

localhost:~ # ll /dev/mapper/
total 0
crw------- 1 root root 10, 236 Apr 30 08:03 control
lrwxrwxrwx 1 root root       7 Apr 30 08:03 vg01-storage1 -> ../dm-0
lrwxrwxrwx 1 root root       7 Apr 30 08:03 vg01-storage2 -> ../dm-1

The original device is presumably stored in kernel somewhere but I do
not know how can I query it?

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

end of thread, other threads:[~2017-05-04  3:49 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-30  5:47 Can I see what device was used to mount btrfs? Andrei Borzenkov
2017-05-02  3:26 ` Anand Jain
2017-05-02 13:58 ` Adam Borowski
2017-05-02 14:19   ` Andrei Borzenkov
2017-05-02 18:49     ` Adam Borowski
2017-05-02 19:50       ` Goffredo Baroncelli
2017-05-02 20:15         ` Kai Krakow
2017-05-02 20:34           ` Adam Borowski
2017-05-03 11:32           ` Austin S. Hemmelgarn
2017-05-03 17:05           ` Goffredo Baroncelli
2017-05-03 18:43             ` Chris Murphy
2017-05-03 21:19               ` Duncan
2017-05-04  2:15                 ` Chris Murphy
2017-05-04  3:48               ` Andrei Borzenkov
2017-05-03 11:26         ` Austin S. Hemmelgarn
2017-05-03 18:12           ` Andrei Borzenkov
2017-05-03 18:53             ` Austin S. Hemmelgarn

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.