← Back to team overview

touch-packages team mailing list archive

[Bug 1432871] Re: `df` shows bind mounts instead of real mounts.

 

** Description changed:

  [Impact]
  
   * df displays bind mounts instead of "real" mounts if the bind mount is
  mounted to a shorter directory.
  
   * justification - This is a change of behavior from precise
  
   * Explanation - This patch checks to see if the source directory of a
  mount is contains the destination directory of the mount it's replacing
  *(check if it's bind mount from the original directory).
  
  [Test Case]
  
   * $ mount
  <snip>
- 192.168.1.2:/raid on /raid type nfs 
+ 192.168.1.2:/raid on /raid type nfs
  /dev/sdc5 on /data type ext4 (rw)
  <snip>
  /data/a on /a type none (rw,bind)
  /raid/temp on /b type none (rw,bind)
  
  $df
  Filesystem           1K-blocks       Used  Available Use% Mounted on
  <snip>
  /data/a              449830616  229975284  196982196  54% /a
  /raid/temp          7752072192 5581343744 1780023296  76% /b
  </snip>
  
  I'd expect to see the real mount prioritized over the bind mount.  Like so.
  $df
  Filesystem           1K-blocks       Used  Available Use% Mounted on
  <snip>
  /dev/sdc5            449830616  229975284  196982196  54% /data
  192.168.1.2:/raid   7752072192 5581438976 1779929088  76% /raid
  <snip>
  
  [Regression Potential]
  
-  * Patch is not upstream, and will not be upstreamed *(see other info)
+  * Patch is upstreamed.
  
-  * df command could stop working if I wrote the patch poorly.  df might
- not process mounts correctly.
+  * df command now relies on /proc/self/mountinfo
  
  [Other Info]
  
-  * The behavior of df, mount and similar number of other commands has changed going forward.  Previously these commands all processed /etc/mtab which was maintained by the mount command.  Going forward they still process /etc/mtab, but this is simply a symlink to /proc/mounts now which is maintained by the kernel and likely significantly more accurate.  Unlike the mount command, the kernel makes no distinction between bind mounts and normal mounts.  This is evident by the fact that you can mount a device, bind mount from that device, and then unmount the original mount.  The default behavior of df in this case is to simply pick the mounted directory for a device that is the shortest since it has no other information to go on from /proc/mounts.
-  * Theoretically df, mount and a number of other commands could be modified to run ioctl commands to determine if the mount is from a root inode of the mounted filesystem to determine preference, but that is really more of an upstream exercise.
+  * The behavior of df, mount and similar number of other commands has
+ changed going forward.  Previously these commands all processed
+ /etc/mtab which was maintained by the mount command.  Going forward they
+ still process /etc/mtab, but this is simply a symlink to /proc/mounts
+ now which is maintained by the kernel and slightly more accurate.
+ Unlike the mount command, the kernel makes no distinction between bind
+ mounts and normal mounts.  This is evident by the fact that you can
+ mount a device, bind mount from that device, and then unmount the
+ original mount.  The default behavior of df in this case is to simply
+ pick the mounted directory for a device that is the shortest since it
+ has no other information to go on from /proc/mounts.  Moving to using
+ /proc/self/mountinfo resolves this issue, and is what upstream is doing
+ moving forward.
  
  Original bug.
  ________________________________________________________________________
  Depending on mount path length df sometimes prioritizes showing bind mounts over real mounts
  
  for example.
  $ mount
  <snip>
  192.168.1.2:/raid on /raid type nfs (rw,nosuid,nodev,noexec,vers=4,addr=192.168.1.2,clientaddr=192.168.1.3)
  /dev/sdc5 on /data type ext4 (rw)
  <snip>
  /data/a on /a type none (rw,bind)
  /raid/temp on /b type none (rw,bind)
  
  $df
  Filesystem           1K-blocks       Used  Available Use% Mounted on
  <snip>
  /data/a              449830616  229975284  196982196  54% /a
  /raid/temp          7752072192 5581343744 1780023296  76% /b
  </snip>
  
  I'd expect to see the real mount prioritized over the bind mount.  Like so.
  $df
  Filesystem           1K-blocks       Used  Available Use% Mounted on
  <snip>
  /dev/sdc5            449830616  229975284  196982196  54% /data
  192.168.1.2:/raid   7752072192 5581438976 1779929088  76% /raid
  <snip>

** Description changed:

  [Impact]
  
   * df displays bind mounts instead of "real" mounts if the bind mount is
  mounted to a shorter directory.
  
-  * justification - This is a change of behavior from precise
+  * justification - When trusty moved to using /proc/mounts this changed
+ behavior from precise.  Additionally it doesn't make sense that a bind
+ mount should show up in df over a real root mount.
  
-  * Explanation - This patch checks to see if the source directory of a
- mount is contains the destination directory of the mount it's replacing
- *(check if it's bind mount from the original directory).
+  * Explanation - These patches change behavior of df to rely on
+ /proc/self/mountinfo which has more complete info than /proc/mounts.
+ Such as what directory of the filesystem was used as the source of the
+ mount.  Additionally given this new information there is a patch on df
+ itself to make use of this new information.
  
  [Test Case]
  
   * $ mount
  <snip>
  192.168.1.2:/raid on /raid type nfs
  /dev/sdc5 on /data type ext4 (rw)
  <snip>
  /data/a on /a type none (rw,bind)
  /raid/temp on /b type none (rw,bind)
  
  $df
  Filesystem           1K-blocks       Used  Available Use% Mounted on
  <snip>
  /data/a              449830616  229975284  196982196  54% /a
  /raid/temp          7752072192 5581343744 1780023296  76% /b
  </snip>
  
  I'd expect to see the real mount prioritized over the bind mount.  Like so.
  $df
  Filesystem           1K-blocks       Used  Available Use% Mounted on
  <snip>
  /dev/sdc5            449830616  229975284  196982196  54% /data
  192.168.1.2:/raid   7752072192 5581438976 1779929088  76% /raid
  <snip>
  
  [Regression Potential]
  
   * Patch is upstreamed.
  
   * df command now relies on /proc/self/mountinfo
  
  [Other Info]
  
   * The behavior of df, mount and similar number of other commands has
  changed going forward.  Previously these commands all processed
  /etc/mtab which was maintained by the mount command.  Going forward they
  still process /etc/mtab, but this is simply a symlink to /proc/mounts
  now which is maintained by the kernel and slightly more accurate.
  Unlike the mount command, the kernel makes no distinction between bind
  mounts and normal mounts.  This is evident by the fact that you can
  mount a device, bind mount from that device, and then unmount the
  original mount.  The default behavior of df in this case is to simply
  pick the mounted directory for a device that is the shortest since it
  has no other information to go on from /proc/mounts.  Moving to using
  /proc/self/mountinfo resolves this issue, and is what upstream is doing
  moving forward.
  
  Original bug.
  ________________________________________________________________________
  Depending on mount path length df sometimes prioritizes showing bind mounts over real mounts
  
  for example.
  $ mount
  <snip>
  192.168.1.2:/raid on /raid type nfs (rw,nosuid,nodev,noexec,vers=4,addr=192.168.1.2,clientaddr=192.168.1.3)
  /dev/sdc5 on /data type ext4 (rw)
  <snip>
  /data/a on /a type none (rw,bind)
  /raid/temp on /b type none (rw,bind)
  
  $df
  Filesystem           1K-blocks       Used  Available Use% Mounted on
  <snip>
  /data/a              449830616  229975284  196982196  54% /a
  /raid/temp          7752072192 5581343744 1780023296  76% /b
  </snip>
  
  I'd expect to see the real mount prioritized over the bind mount.  Like so.
  $df
  Filesystem           1K-blocks       Used  Available Use% Mounted on
  <snip>
  /dev/sdc5            449830616  229975284  196982196  54% /data
  192.168.1.2:/raid   7752072192 5581438976 1779929088  76% /raid
  <snip>

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to coreutils in Ubuntu.
https://bugs.launchpad.net/bugs/1432871

Title:
  `df` shows bind mounts instead of real mounts.

Status in coreutils package in Ubuntu:
  Incomplete

Bug description:
  [Impact]

   * df displays bind mounts instead of "real" mounts if the bind mount
  is mounted to a shorter directory.

   * justification - When trusty moved to using /proc/mounts this
  changed behavior from precise.  Additionally it doesn't make sense
  that a bind mount should show up in df over a real root mount.

   * Explanation - These patches change behavior of df to rely on
  /proc/self/mountinfo which has more complete info than /proc/mounts.
  Such as what directory of the filesystem was used as the source of the
  mount.  Additionally given this new information there is a patch on df
  itself to make use of this new information.

  [Test Case]

   * $ mount
  <snip>
  192.168.1.2:/raid on /raid type nfs
  /dev/sdc5 on /data type ext4 (rw)
  <snip>
  /data/a on /a type none (rw,bind)
  /raid/temp on /b type none (rw,bind)

  $df
  Filesystem           1K-blocks       Used  Available Use% Mounted on
  <snip>
  /data/a              449830616  229975284  196982196  54% /a
  /raid/temp          7752072192 5581343744 1780023296  76% /b
  </snip>

  I'd expect to see the real mount prioritized over the bind mount.  Like so.
  $df
  Filesystem           1K-blocks       Used  Available Use% Mounted on
  <snip>
  /dev/sdc5            449830616  229975284  196982196  54% /data
  192.168.1.2:/raid   7752072192 5581438976 1779929088  76% /raid
  <snip>

  [Regression Potential]

   * Patch is upstreamed.

   * df command now relies on /proc/self/mountinfo

  [Other Info]

   * The behavior of df, mount and similar number of other commands has
  changed going forward.  Previously these commands all processed
  /etc/mtab which was maintained by the mount command.  Going forward
  they still process /etc/mtab, but this is simply a symlink to
  /proc/mounts now which is maintained by the kernel and slightly more
  accurate.  Unlike the mount command, the kernel makes no distinction
  between bind mounts and normal mounts.  This is evident by the fact
  that you can mount a device, bind mount from that device, and then
  unmount the original mount.  The default behavior of df in this case
  is to simply pick the mounted directory for a device that is the
  shortest since it has no other information to go on from /proc/mounts.
  Moving to using /proc/self/mountinfo resolves this issue, and is what
  upstream is doing moving forward.

  Original bug.
  ________________________________________________________________________
  Depending on mount path length df sometimes prioritizes showing bind mounts over real mounts

  for example.
  $ mount
  <snip>
  192.168.1.2:/raid on /raid type nfs (rw,nosuid,nodev,noexec,vers=4,addr=192.168.1.2,clientaddr=192.168.1.3)
  /dev/sdc5 on /data type ext4 (rw)
  <snip>
  /data/a on /a type none (rw,bind)
  /raid/temp on /b type none (rw,bind)

  $df
  Filesystem           1K-blocks       Used  Available Use% Mounted on
  <snip>
  /data/a              449830616  229975284  196982196  54% /a
  /raid/temp          7752072192 5581343744 1780023296  76% /b
  </snip>

  I'd expect to see the real mount prioritized over the bind mount.  Like so.
  $df
  Filesystem           1K-blocks       Used  Available Use% Mounted on
  <snip>
  /dev/sdc5            449830616  229975284  196982196  54% /data
  192.168.1.2:/raid   7752072192 5581438976 1779929088  76% /raid
  <snip>

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/1432871/+subscriptions