Bug 1152615

Summary: df incorrectly reports free space when filesystem is double-mounted
Product: Red Hat Enterprise Linux 6 Reporter: Byron S <bsorgdrager>
Component: coreutilsAssignee: Kamil Dudka <kdudka>
Status: CLOSED WONTFIX QA Contact: Branislav Blaškovič <bblaskov>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.5CC: agk, bblaskov, kdudka
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-29 13:17:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
[PATCH] deal better with over-mount devices ovasik: review+

Description Byron S 2014-10-14 14:13:20 UTC
Description of problem:

When mounting multiple devices to the same mount point, df reports only the last-mounted disk's size (total, used, free) correctly. 

Method:

Take two disks with different UUIDs and mount them on top of each other on the same mount point. For example:

Two distinct devices (output of 'blkid'):
/dev/cciss/c0d0p6: LABEL="/u1" UUID="21234567-0e66-46ed-85fd-3452e3918267" TYPE="ext3"
/dev/cciss/c0d1p1: LABEL="/u1" UUID="39876543-672a-4afc-a3b1-809508d11fcd" TYPE="ext4"

Mount them on the same mount point:

mount /dev/cciss/c0d0p6 /u1/
mount /dev/cciss/c0d1p1 /u1/

Mounted on same mount point (output of 'mount'):
/dev/cciss/c0d0p6 on /u1 type ext3 (rw)
/dev/cciss/c0d1p1 on /u1 type ext4 (rw)

Actual results:

Output of 'df':
[~]# df -h | grep u1
/dev/cciss/c0d0p6  135G   48G   88G  35% /u1
/dev/cciss/c0d1p1  135G   48G   88G  35% /u1

[~]# df -a | grep u1
/dev/cciss/c0d0p6 140956600 49251652  91688564  35% /u1
/dev/cciss/c0d1p1 140956600 49251652  91688564  35% /u1

Expected results:

Expected to see 46G, not 135G as disk

/dev/cciss/c0d0p6   46G   31G   16G  66% /u1
/dev/cciss/c0d1p1  135G   48G   88G  35% /u1

As below:

[~]# df -h | grep fubar
/dev/cciss/c0d0p6   46G   31G   16G  66% /fubar

[~]# df -a | grep fubar
/dev/cciss/c0d0p6  48077160 31604408  16472752  66% /fubar

Additional info:

[~]# fdisk -l | grep 'Disk /'
Disk /dev/cciss/c0d0: 73.4 GB, 73372631040 bytes
Disk /dev/cciss/c0d1: 146.8 GB, 146778685440 bytes

Incorrect sizes (total, used, free) are reported for c0d0.

Version: coreutils-8.4-31.el6.x86_64

Comment 2 Pádraig Brady 2014-10-14 14:27:26 UTC
There are changes in upstream and RHEL7 to deal with this.
The behavior should be to show the last device mounted at a particular point,
and previous devices are not accessible to the user (nor to df to get the stats)

Comment 4 Kamil Dudka 2016-01-15 09:02:24 UTC
Created attachment 1115059 [details]
[PATCH] deal better with over-mount devices

I have backported 5 upstream commits to address this issue.  It was non-trivial to isolate the code from the mount entry de-duplication feature, which we probably do not want to introduce in RHEL-6 at this point.  A quick demo follows:

# df
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/vda1       16381864 10641408   4901648  69% /
/dev/vdb1        1968368    35756   1832620   2% /boot

# mount /dev/vdb2 /boot
# df
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/vda1       16381864 10641408   4901648  69% /
/dev/vdb1              -        -         -    - /boot
/dev/vdb2        7743112    17592   7325524   1% /boot

# df /boot
Filesystem     1K-blocks  Used Available Use% Mounted on
/dev/vdb2        7743112 17592   7325524   1% /boot

# df /dev/vdb1
df: cannot access `/dev/vdb1': over-mounted by another device
df: no file systems processed

# df /dev/vdb2
Filesystem     1K-blocks  Used Available Use% Mounted on
/dev/vdb2        7743112 17592   7325524   1% /boot

# df -a
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/vda1       16381864 10641408   4901648  69% /
proc                   0        0         0    - /proc
sysfs                  0        0         0    - /sys
devpts                 0        0         0    - /dev/pts
/dev/vdb1              -        -         -    - /boot
/dev/vdb2        7743112    17592   7325524   1% /boot


The related upstream test could not be picked because it does not work with the legacy /etc/mtab file containing source files instead of /dev/loop* in case of loopback mounts.

A review would be appreciated...

Comment 5 Ondrej Vasik 2016-02-12 13:58:31 UTC
Makes sense, thanks for the patch. Looks sane to me... I agree with not doing deduplication effort on RHEL 6 - it is required in the case of huge amount of duplicates - when /proc/mounts is symlink to /etc/mtab - on RHEL 6 it would only cause change in behaviour and confusion.

Comment 7 Byron S 2016-02-12 16:12:29 UTC
Patch looks good, thank you!

Comment 17 Kamil Dudka 2016-07-29 13:17:42 UTC
Per bug #1325347 comment #14, closing WONTFIX.