From: Tomasz Sterna <tomek@xiaoka.com>
To: linux-btrfs@vger.kernel.org
Subject: stat(2) returning device ID not existing in mountinfo
Date: Fri, 16 Sep 2016 22:28:11 +0200 [thread overview]
Message-ID: <1474057691.16275.16.camel@xiaoka.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2185 bytes --]
Hi.
I have spotted an issue with stat(2) call on files on btrfs.
It is giving me dev_t st_dev number that does not correspond to any
mounted filesystem in proc's mountinfo.
A quick example:
$ grep btrfs /proc/self/mountinfo
61 0 0:36 /root / rw,relatime shared:1 - btrfs /dev/bcache0 rw,ssd,space_cache,subvolid=535,subvol=/root
75 61 0:36 /home /home rw,relatime shared:30 - btrfs /dev/bcache0 rw,ssd,space_cache,subvolid=258,subvol=/home
As you can see both btrfs subvolumes are 0:36, but files on these:
$ stat -c "%d" /etc/passwd
38
$ stat -c "%d" /home/smoku/test.txt
44
Passing these through major(3)/minor(3) give: 0:38 and 0:44
There is clearly something fishy going on. :-)
Simple one-liner shows that only btrfs and autofs misbehave like this:
$ </proc/self/mountinfo cut -d' ' -f3,5,9 | while read DEV PATH FS; do echo $DEV $(/usr/bin/stat -c "%d" $PATH) $FS; done
0:16 16 sysfs
0:4 4 proc
0:6 6 devtmpfs
0:17 17 securityfs
0:18 18 tmpfs
0:19 19 devpts
0:20 20 tmpfs
0:21 21 tmpfs
0:22 22 cgroup
0:23 23 pstore
0:24 24 efivarfs
0:25 25 cgroup
0:26 26 cgroup
0:27 27 cgroup
0:28 28 cgroup
0:29 29 cgroup
0:30 30 cgroup
0:31 31 cgroup
0:32 32 cgroup
0:33 33 cgroup
0:34 34 cgroup
0:35 35 configfs
0:36 38 btrfs
0:15 15 hugetlbfs
0:39 68 autofs
0:14 14 mqueue
0:40 40 tmpfs
0:7 7 debugfs
0:42 42 nfsd
0:36 44 btrfs
8:2 2050 ext3
8:1 2049 vfat
0:47 47 rpc_pipefs
0:50 50 fusectl
0:51 51 tmpfs
0:49 49 fuse.gvfsd-fuse
0:68 68 binfmt_misc
I already attempted a illinformed-patch in fs/btrfs/super.c:
@@ -1127,6 +1127,7 @@ static int btrfs_fill_super(struct super_block *sb,
goto fail_close;
}
+ sb->s_dev = inode->i_sb->s_dev;
sb->s_root = d_make_root(inode);
if (!sb->s_root) {
err = -ENOMEM;
but it didn't help.
I would like to dig deeper and fix it, but first I have to ask:
- Which number is wrong?
The one returned by stat() or the one in mountinfo?
I am running:
$ uname -a
Linux lair.home.lan 4.7.3-200.pf3.fc24.x86_64 #1 SMP Tue Sep 13 12:34:03 CEST 2016 x86_64 x86_64 x86_64 GNU/Linux
--
smoku @ http://abadcafe.pl/ @ http://xiaoka.com/
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next reply other threads:[~2016-09-16 20:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-16 20:28 Tomasz Sterna [this message]
2016-09-20 13:15 ` stat(2) returning device ID not existing in mountinfo Jeff Mahoney
2017-02-13 19:21 ` Goffredo Baroncelli
2017-02-15 18:25 ` Goffredo Baroncelli
2017-02-17 8:13 ` Duncan
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=1474057691.16275.16.camel@xiaoka.com \
--to=tomek@xiaoka.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).