From: Andrei Borzenkov <arvidjaar@gmail.com>
To: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Can I see what device was used to mount btrfs?
Date: Sun, 30 Apr 2017 08:47:43 +0300 [thread overview]
Message-ID: <1e2e2e5c-5ee8-85c1-1db4-74293d8c9c1e@gmail.com> (raw)
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?
next reply other threads:[~2017-04-30 5:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-30 5:47 Andrei Borzenkov [this message]
2017-05-02 3:26 ` Can I see what device was used to mount btrfs? 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1e2e2e5c-5ee8-85c1-1db4-74293d8c9c1e@gmail.com \
--to=arvidjaar@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).