Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1361936 > unrolled thread

confusing mountinfo output when bind-mounting files

Started byTycho Andersen <tycho.andersen@canonical.com>
First post2016-03-21 16:30 +0100
Last post2016-03-21 19:00 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  confusing mountinfo output when bind-mounting files Tycho Andersen <tycho.andersen@canonical.com> - 2016-03-21 16:30 +0100
    Re: confusing mountinfo output when bind-mounting files Chris Murphy <lists@colorremedies.com> - 2016-03-21 18:30 +0100
      Re: confusing mountinfo output when bind-mounting files Tycho Andersen <tycho.andersen@canonical.com> - 2016-03-21 18:40 +0100
        Re: confusing mountinfo output when bind-mounting files "Austin S. Hemmelgarn" <ahferroin7@gmail.com> - 2016-03-21 19:00 +0100

#1361936 — confusing mountinfo output when bind-mounting files

FromTycho Andersen <tycho.andersen@canonical.com>
Date2016-03-21 16:30 +0100
Subjectconfusing mountinfo output when bind-mounting files
Message-ID<rf9Wi-7Az-21@gated-at.bofh.it>
Hi all,

I'm seeing some strange behavior when bind mounting files from a btrfs
subvolume. Consider the output below:

root@criu2:/tmp# mount -o loop /tmp/tester.btrfs /tmp/dir1
root@criu2:/tmp# touch dir1/file
root@criu2:/tmp# sudo mount --bind dir1/file dir2/file
root@criu2:/tmp# grep "/tmp/dir" /proc/self/mountinfo 
128 24 0:45 / /tmp/dir1 rw,relatime shared:107 - btrfs /dev/loop0 rw,space_cache,subvolid=5,subvol=/
129 24 0:45 /file /tmp/dir2/file rw,relatime shared:107 - btrfs /dev/loop0 rw,space_cache,subvolid=5,subvol=/file
root@criu2:/tmp# btrfs --version
btrfs-progs v4.4
root@criu2:/tmp# uname -a
Linux criu2 4.4.0-8-generic #23-Ubuntu SMP Wed Feb 24 20:45:30 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

The issue here is that the "subvol=" mount option for the target of the bind
mount is "/file" when no such subvolume actually exists. Is this
intended? It's confusing to say the least, but seems like a bug to me.

Tycho

[toc] | [next] | [standalone]


#1362023

FromChris Murphy <lists@colorremedies.com>
Date2016-03-21 18:30 +0100
Message-ID<rfbOq-qS-7@gated-at.bofh.it>
In reply to#1361936
On Mon, Mar 21, 2016 at 9:21 AM, Tycho Andersen
<tycho.andersen@canonical.com> wrote:
> Hi all,
>
> I'm seeing some strange behavior when bind mounting files from a btrfs
> subvolume. Consider the output below:
>
> root@criu2:/tmp# mount -o loop /tmp/tester.btrfs /tmp/dir1
> root@criu2:/tmp# touch dir1/file
> root@criu2:/tmp# sudo mount --bind dir1/file dir2/file
> root@criu2:/tmp# grep "/tmp/dir" /proc/self/mountinfo
> 128 24 0:45 / /tmp/dir1 rw,relatime shared:107 - btrfs /dev/loop0 rw,space_cache,subvolid=5,subvol=/
> 129 24 0:45 /file /tmp/dir2/file rw,relatime shared:107 - btrfs /dev/loop0 rw,space_cache,subvolid=5,subvol=/file
> root@criu2:/tmp# btrfs --version
> btrfs-progs v4.4
> root@criu2:/tmp# uname -a
> Linux criu2 4.4.0-8-generic #23-Ubuntu SMP Wed Feb 24 20:45:30 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
>
> The issue here is that the "subvol=" mount option for the target of the bind
> mount is "/file" when no such subvolume actually exists. Is this
> intended? It's confusing to say the least, but seems like a bug to me.

Since btrfs mount subvol=<name> is a bind mount behind the scene, I'm
not sure the mount info code distinguishes between bind mounts.

At the moment, this is something of a secret decoder ring where if you
see subvolid=5 first, then anything after that other than / is just
not true (can't be). Hence probably why both subvolid and subvol are
listed for now; you kinda have to parse them both.



-- 
Chris Murphy

[toc] | [prev] | [next] | [standalone]


#1362040

FromTycho Andersen <tycho.andersen@canonical.com>
Date2016-03-21 18:40 +0100
Message-ID<rfbY8-vn-41@gated-at.bofh.it>
In reply to#1362023
On Mon, Mar 21, 2016 at 11:22:06AM -0600, Chris Murphy wrote:
> On Mon, Mar 21, 2016 at 9:21 AM, Tycho Andersen
> <tycho.andersen@canonical.com> wrote:
> > Hi all,
> >
> > I'm seeing some strange behavior when bind mounting files from a btrfs
> > subvolume. Consider the output below:
> >
> > root@criu2:/tmp# mount -o loop /tmp/tester.btrfs /tmp/dir1
> > root@criu2:/tmp# touch dir1/file
> > root@criu2:/tmp# sudo mount --bind dir1/file dir2/file
> > root@criu2:/tmp# grep "/tmp/dir" /proc/self/mountinfo
> > 128 24 0:45 / /tmp/dir1 rw,relatime shared:107 - btrfs /dev/loop0 rw,space_cache,subvolid=5,subvol=/
> > 129 24 0:45 /file /tmp/dir2/file rw,relatime shared:107 - btrfs /dev/loop0 rw,space_cache,subvolid=5,subvol=/file
> > root@criu2:/tmp# btrfs --version
> > btrfs-progs v4.4
> > root@criu2:/tmp# uname -a
> > Linux criu2 4.4.0-8-generic #23-Ubuntu SMP Wed Feb 24 20:45:30 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
> >
> > The issue here is that the "subvol=" mount option for the target of the bind
> > mount is "/file" when no such subvolume actually exists. Is this
> > intended? It's confusing to say the least, but seems like a bug to me.
> 
> Since btrfs mount subvol=<name> is a bind mount behind the scene, I'm
> not sure the mount info code distinguishes between bind mounts.
> 
> At the moment, this is something of a secret decoder ring where if you
> see subvolid=5 first, then anything after that other than / is just
> not true (can't be). Hence probably why both subvolid and subvol are
> listed for now; you kinda have to parse them both.

Ok, so if I'm trying to compare superblocks from userspace, I should
look for subvolid and see if those match, and if that isn't present
then look for subvol?

Tycho

[toc] | [prev] | [next] | [standalone]


#1362048

From"Austin S. Hemmelgarn" <ahferroin7@gmail.com>
Date2016-03-21 19:00 +0100
Message-ID<rfchs-Dm-1@gated-at.bofh.it>
In reply to#1362040
On 2016-03-21 13:29, Tycho Andersen wrote:
> On Mon, Mar 21, 2016 at 11:22:06AM -0600, Chris Murphy wrote:
>> On Mon, Mar 21, 2016 at 9:21 AM, Tycho Andersen
>> <tycho.andersen@canonical.com> wrote:
>>> Hi all,
>>>
>>> I'm seeing some strange behavior when bind mounting files from a btrfs
>>> subvolume. Consider the output below:
>>>
>>> root@criu2:/tmp# mount -o loop /tmp/tester.btrfs /tmp/dir1
>>> root@criu2:/tmp# touch dir1/file
>>> root@criu2:/tmp# sudo mount --bind dir1/file dir2/file
>>> root@criu2:/tmp# grep "/tmp/dir" /proc/self/mountinfo
>>> 128 24 0:45 / /tmp/dir1 rw,relatime shared:107 - btrfs /dev/loop0 rw,space_cache,subvolid=5,subvol=/
>>> 129 24 0:45 /file /tmp/dir2/file rw,relatime shared:107 - btrfs /dev/loop0 rw,space_cache,subvolid=5,subvol=/file
>>> root@criu2:/tmp# btrfs --version
>>> btrfs-progs v4.4
>>> root@criu2:/tmp# uname -a
>>> Linux criu2 4.4.0-8-generic #23-Ubuntu SMP Wed Feb 24 20:45:30 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
>>>
>>> The issue here is that the "subvol=" mount option for the target of the bind
>>> mount is "/file" when no such subvolume actually exists. Is this
>>> intended? It's confusing to say the least, but seems like a bug to me.
>>
>> Since btrfs mount subvol=<name> is a bind mount behind the scene, I'm
>> not sure the mount info code distinguishes between bind mounts.
>>
>> At the moment, this is something of a secret decoder ring where if you
>> see subvolid=5 first, then anything after that other than / is just
>> not true (can't be). Hence probably why both subvolid and subvol are
>> listed for now; you kinda have to parse them both.
>
> Ok, so if I'm trying to compare superblocks from userspace, I should
> look for subvolid and see if those match, and if that isn't present
> then look for subvol?
That depends on what you mean by 'compare superblocks'.

Internal to the kernel, there is exactly one super-block structure 
shared between all mounts of a given BTRFS filesystem, regardless of 
subvolume or bind-mount (the same is actually also true if you mount a 
XFS or ext4 filesystem more than once on the same system), so if you're 
trying to differentiate filesystems, you need to match on something like 
the block device or label.

If however, you're trying to differentiate where something is mounted 
from, you should be matching on both subvolid and subvol (I think, but I 
may be wrong), but that may not always work (I don't use bind mounts of 
BTRFS filesystems often outside of subvolume mounts, so I don't have 
much experience with this particular case).

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web