← Back to team overview

touch-packages team mailing list archive

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

 

I reviewed and uploaded the trusty version of the patch.  ~ubuntu-sru is
already subscribed, so I believe that's it from my side.

-- 
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:
  Fix Released
Status in coreutils source package in Trusty:
  In Progress
Status in coreutils source package in Vivid:
  Fix Committed
Status in coreutils source package in Wily:
  Fix Released

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.

   * In order to solve this issue, I have written patches and got them integrated upstream.
  gnulib commit: http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commit;h=c6148bca89e9465fd6ba3a10d273ec4cb58c2dbe and
  coreutils commit: http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commit;h=3babaf83875ceac896c8dd3a64248e955dfecef9
  have been authored by me.

  While attempting to push these patches into Ubuntu, it became apparent
  that our version of coreutils does not contain the requisite patches
  to correctly support /proc/self/mountinfo.  /proc/self/mountinfo gives
  more complete information than /proc/self/mounts which /etc/mtab now
  points to. Using /proc/self/mountinfo is the upstream way of doing
  things, and it allows us to resolve this specific bug.

  Patches required in order to support /proc/self/mountinfo are.
  Origin: upstream, gnulib - http://git.savannah.gnu.org/gitweb/?p=gnulib.git
  commit: http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commit;h=3ea43e02541ece750ffc6cd1dfe34195421b4ef3
  commit: http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commit;h=2768ceb7994506e2cfba88be3b6bd13ef5440a90
  commit: http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commit;h=de1cbdd48244c66c51a3e2bc1594ac3ad32ce038
  commit: http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commit;h=3fb6e360363744462ce15c381f0b116c6fc4ce82

  Origin: upstream, coreutils - http://git.savannah.gnu.org/gitweb/?p=coreutils.git
  commit: http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commit;h=1b1c40e1d6f8cf30b6c7c9d31bbddbc3d5cc72e6
  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