Bug 110111 - btrfs fi usage reports bogus 16EiB free space
Summary: btrfs fi usage reports bogus 16EiB free space
Status: RESOLVED CODE_FIX
Alias: None
Product: File System
Classification: Unclassified
Component: btrfs (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Josef Bacik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-29 00:04 UTC by Chris Murphy
Modified: 2016-01-13 15:42 UTC (History)
1 user (show)

See Also:
Kernel Version: 4.4.0-0.rc6.git0.1.fc24.x86_64
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Chris Murphy 2015-12-29 00:04:43 UTC
btrfs-progs-4.3.1-1.fc23.x86_64

1. Used f3write to test a USB stick formatted with mkfs.btrfs -M, this fills the entire device.
2. btrfs fi usage <mp>

Actual results:

[root@f23m ~]# btrfs fi usage /mnt/king
WARNING: MIXED blockgroups not handled
Overall:
    Device size:		  14.91GiB
    Device allocated:		  29.82GiB
    Device unallocated:		  16.00EiB
    Device missing:		     0.00B
    Used:			  29.23GiB
    Free (estimated):		  16.00EiB	(min: 16.00EiB)    !!!!!!!
    Data ratio:			      1.00
    Metadata ratio:		      1.00
    Global reserve:		 300.00MiB	(used: 0.00B)

Data+Metadata,single: Size:14.91GiB, Used:14.62GiB
   /dev/sdd	  14.91GiB

System,single: Size:4.00MiB, Used:4.00KiB
   /dev/sdd	   4.00MiB

Unallocated:
   /dev/sdd	     0.00B

[root@f23m ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
[..snip...]
/dev/sdd         15G   15G  301M  99% /mnt/king

[root@f23m ~]# btrfs fi df /mnt/king/
System, single: total=4.00MiB, used=4.00KiB
Data+Metadata, single: total=14.91GiB, used=14.62GiB
GlobalReserve, single: total=300.00MiB, used=0.00B

[root@f23m ~]# btrfs fi show /mnt/king
Label: none  uuid: 8040969d-6809-4c7a-9126-afbbb127a719
	Total devices 1 FS bytes used 14.62GiB
	devid    1 size 14.91GiB used 14.91GiB path /dev/sdd



Expected:

Should report in the vicinity of 300MiB free, not 16.00EiB.
Comment 1 Chris Murphy 2015-12-29 02:51:08 UTC
Regression testing.

With a new mkfs, and mounting the new empty fs, I get this:

[root@f23m ~]# btrfs fi usage /mnt/king
WARNING: MIXED blockgroups not handled
Overall:
    Device size:		  14.91GiB
    Device allocated:		  20.00MiB
    Device unallocated:		  14.89GiB
    Device missing:		     0.00B
    Used:			  60.00KiB
    Free (estimated):		  14.90GiB	(min: 14.90GiB)
    Data ratio:			      1.00
    Metadata ratio:		      1.00
    Global reserve:		   4.00MiB	(used: 0.00B)

Data+Metadata,single: Size:8.00MiB, Used:28.00KiB
   /dev/sdd	   8.00MiB

System,single: Size:4.00MiB, Used:4.00KiB
   /dev/sdd	   4.00MiB

Unallocated:
   /dev/sdd	  14.90GiB


And then after copying ~837MiB file, the problem still doesn't happen.


[root@f23m ~]# btrfs fi usage /mnt/king/
WARNING: MIXED blockgroups not handled
Overall:
    Device size:		  14.91GiB
    Device allocated:		   2.02GiB
    Device unallocated:		  12.89GiB
    Device missing:		     0.00B
    Used:			   1.64GiB
    Free (estimated):		  13.08GiB	(min: 13.08GiB)
    Data ratio:			      1.00
    Metadata ratio:		      1.00
    Global reserve:		  20.00MiB	(used: 0.00B)

Data+Metadata,single: Size:1.01GiB, Used:837.86MiB
   /dev/sdd	   1.01GiB

System,single: Size:4.00MiB, Used:4.00KiB
   /dev/sdd	   4.00MiB

Unallocated:
   /dev/sdd	  13.90GiB


However, the Used amount is off by a factor of 2x.

[root@f23m king]# btrfs fi df /mnt/king/
System, single: total=4.00MiB, used=4.00KiB
Data+Metadata, single: total=1.01GiB, used=837.86MiB
GlobalReserve, single: total=20.00MiB, used=0.00B


Around 48% used (per conventional df, which matches up reasonably well with btrfs fi df), "fi usage" flips from a sane looking (but still wrong) value to 16.00EiB.

This may be due to the lack of support for mixedbg by 'fi usage'.
Comment 2 David Sterba 2016-01-13 15:42:56 UTC
Mixed block groups reporting in 'fi usage' should be fixed in devel, queued for 4.4.

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