Bug 94911

Summary: Wrong size of device unallocated and wrong size of free (estimated): 8EiB or 16EiB
Product: File System Reporter: raffix
Component: btrfsAssignee: Josef Bacik (josef)
Status: RESOLVED CODE_FIX    
Severity: normal CC: dsterba
Priority: P1    
Hardware: x86-64   
OS: Linux   
Kernel Version: 3.16.0 Subsystem:
Regression: No Bisected commit-id:

Description raffix 2015-03-16 15:01:03 UTC
btrfs-tools version is 3.18.2

I have two 1.5TB drives in a RAID1 configuration.

sudo btrfs fi df /home
Data, RAID1: total=972.00GiB, used=962.17GiB
System, RAID1: total=32.00MiB, used=176.00KiB
Metadata, RAID1: total=3.00GiB, used=1.18GiB
GlobalReserve, single: total=416.00MiB, used=0.00B

For testing purposes I switched off one of them and mounted the left one in degraded mode:

sudo btrfs fi sh /home
Label: none  uuid: 6f5413f9-c99c-499c-b6ed-2440cb5acd2f
	Total devices 2 FS bytes used 963.33GiB
	devid    1 size 1.36TiB used 975.03GiB path /dev/sdb1
	*** Some devices missing

However, the command: "btrfs fi us /home" shows a complete wrong result. The entry "Device unallocated" says 16.00EiB (Exbibyte !!).
I can assure you, I have only one 1.5TB device. ;-)

sudo btrfs fi us /home
Overall:
    Device size:		   1.36TiB
    Device allocated:		   1.90TiB
    Device unallocated:		  16.00EiB    <--- WRONG!!
    Used:			   1.88TiB
    Free (estimated):		   8.00EiB	(min: 8.00EiB)   <--- WRONG!!
    Data ratio:			      2.00
    Metadata ratio:		      2.00
    Global reserve:		 416.00MiB	(used: 0.00B)

Data,RAID1: Size:972.00GiB, Used:962.15GiB
   	 972.00GiB
   /dev/sdb1	 972.00GiB

Metadata,RAID1: Size:3.00GiB, Used:1.18GiB
   	   3.00GiB
   /dev/sdb1	   3.00GiB

System,RAID1: Size:32.00MiB, Used:176.00KiB
   	  32.00MiB
   /dev/sdb1	  32.00MiB

Unallocated:
   	 422.23GiB
   /dev/sdb1	 422.23GiB
Comment 1 David Sterba 2015-03-17 10:17:58 UTC
8.00EiB is a result of interpretting a negative signed 64bit number as unsigned. The negative number is probably caused by wrong calculations, in your case probably due to the degraded mount.
Comment 2 David Sterba 2015-03-17 13:38:15 UTC
Reproduced and fix will be sent to mailinglist.
Comment 3 raffix 2015-03-17 16:05:33 UTC
Thank you very much for your work!