Bug 80951 - df reports bogus filesystem usage when mounted degraded
Summary: df reports bogus filesystem usage when mounted degraded
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: btrfs (show other bugs)
Hardware: All Linux
: P1 high
Assignee: Josef Bacik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-23 02:33 UTC by Chris Murphy
Modified: 2016-03-20 11:24 UTC (History)
1 user (show)

See Also:
Kernel Version: 3.16.0-0.rc6.git0.1.fc21.1.x86_64
Tree: Fedora
Regression: No


Attachments

Description Chris Murphy 2014-07-23 02:33:21 UTC
Summary: When Btrfs volume is mounted degraded, df reports wrong Avail and Use% values; gdm/gnome bogus complaint that there's ~60MB space left on device, becomes unstable, slow, and then produces a sad face and the GUI isn't usable at all.

Looks like statfs is computing the wrong value for f_bavail when degraded.


THIS OUTPUT IS WHILE NORMALLY MOUNTED

[root@localhost ~]# btrfs fi df /mnt
Data, RAID1: total=6.00GiB, used=5.99GiB
System, RAID1: total=32.00MiB, used=32.00KiB
Metadata, RAID1: total=1.00GiB, used=412.38MiB
unknown, single: total=160.00MiB, used=0.00

[root@localhost ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/fedora-root   50G  3.3G   47G   7% /
devtmpfs                 1.3G     0  1.3G   0% /dev
tmpfs                    1.3G     0  1.3G   0% /dev/shm
tmpfs                    1.3G  660K  1.3G   1% /run
tmpfs                    1.3G     0  1.3G   0% /sys/fs/cgroup
tmpfs                    1.3G     0  1.3G   0% /tmp
/dev/mapper/fedora-home   27G   33M   27G   1% /home
/dev/sda1                497M  170M  328M  35% /boot
tmpfs                    251M     0  251M   0% /run/user/0
/dev/sdb                  26G   13G   12G  54% /mnt

[root@localhost ~]# btrfs fi show
Label: 'Rawhide2'  uuid: f857c336-b8f5-4f5d-9500-a705ee1b6977
	Total devices 2 FS bytes used 6.39GiB
	devid    1 size 12.58GiB used 7.03GiB path /dev/sdb
	devid    2 size 12.58GiB used 7.03GiB path /dev/sdc

Btrfs v3.14.2

## snippet from strace df -h
statfs("/mnt", {f_type=0x9123683e, f_bsize=4096, f_blocks=6595746, f_bfree=3244004, f_bavail=2913970, f_files=0, f_ffree=0, f_fsid={1834443827, 1458447919}, f_namelen=255, f_frsize=4096}) = 0
open("/usr/lib64/gconv/gconv-modules.cache", O_RDONLY) = 3



THIS OUTPUT IS WHILE MOUNTED DEGRADED WITH ONE DEVICE MISSING

[root@localhost ~]# btrfs fi df /mnt
Data, RAID1: total=6.00GiB, used=5.99GiB
System, RAID1: total=32.00MiB, used=32.00KiB
Metadata, RAID1: total=1.00GiB, used=412.38MiB
unknown, single: total=160.00MiB, used=0.00
[root@localhost ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/fedora-root   50G  3.3G   47G   7% /
devtmpfs                 1.3G     0  1.3G   0% /dev
tmpfs                    1.3G     0  1.3G   0% /dev/shm
tmpfs                    1.3G  596K  1.3G   1% /run
tmpfs                    1.3G     0  1.3G   0% /sys/fs/cgroup
tmpfs                    1.3G     0  1.3G   0% /tmp
/dev/mapper/fedora-home   27G   33M   27G   1% /home
/dev/sda1                497M  170M  328M  35% /boot
tmpfs                    251M     0  251M   0% /run/user/0
/dev/sdb                  26G   13G   21M 100% /mnt
[root@localhost ~]# btrfs fi show
Label: 'Rawhide2'  uuid: f857c336-b8f5-4f5d-9500-a705ee1b6977
	Total devices 2 FS bytes used 6.39GiB
	devid    1 size 12.58GiB used 7.03GiB path /dev/sdb
	*** Some devices missing

Btrfs v3.14.2

statfs("/mnt", {f_type=0x9123683e, f_bsize=4096, f_blocks=6595746, f_bfree=3244004, f_bavail=5138, f_files=0, f_ffree=0, f_fsid={1834443827, 1458447919}, f_namelen=255, f_frsize=4096}) = 0
open("/usr/lib64/gconv/gconv-modules.cache", O_RDONLY) = 3

The notable part is Avail has gone from 12G to 20M, and Use% from 54% to 100%. This isn't correct behavior.

From the two strace df's, f_bavail goes from 2913970 to 5138 when degraded.
Comment 1 Chris Murphy 2014-07-24 01:19:45 UTC
OK I think this is not a bug. When degraded, statfs is showing free blocks remaining in already allocated Btrfs chunks. It isn't showing free space on the partition. If I try to bust the reported Available space, I do in fact get "No space left on device" messages. So the df reporting is likely correct, even though it's confusing.

More info here:
http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg35760.html

Note You need to log in before you can comment on or make changes to this bug.