Description of problem: When listing, the free and used spaces for btrfs volumes is incorrect. Version-Release number of selected component (if applicable): system-storage-manager-0.2-1.fc18.noarch How reproducible: Always. Steps to Reproduce: 1. Install Fedora 18 to a btrfs volume, made of a single 80GiB disk. 2. ssm list 3. Actual results: 1. first data block (device) reports 573.44 KB free whereas other blocks report 72.13 GB free. 2. second data block (pool) reports total space and used space are identical, which would mean free space is 0, but free space is significantly non-zero. Expected results: As only 4GB is used, I expect list to indicated used amount to be in the realm of 4GB; and free in the realm of 70GB. Additional info: Curiously, btrfs fi show indicates all of the data chunks created have been used which is unexpected. [root@f18v ~]# ssm list --------------------------------------------------------------- Device Free Used Total Pool Mount point --------------------------------------------------------------- /dev/sda 80.00 GB PARTITIONED /dev/sda1 573.44 KB 76.06 GB 76.06 GB fedora /dev/sda2 3.94 GB SWAP /dev/sdb 8.00 GB /dev/sdb1 0.00 KB 7.97 GB 8.00 GB thegroup /dev/sdc 8.00 GB /dev/sdc1 0.00 KB 7.97 GB 8.00 GB thegroup --------------------------------------------------------------- ------------------------------------------------------ Pool Type Devices Free Used Total ------------------------------------------------------ thegroup lvm 2 0.00 KB 15.94 GB 15.94 GB fedora btrfs 1 72.13 GB 76.06 GB 76.06 GB ------------------------------------------------------ ---------------------------------------------------------------------------------- Volume Pool Volume size FS FS size Free Type Mount point ---------------------------------------------------------------------------------- /dev/thegroup/vol1 thegroup 2.78 GB ext4 2.78 GB 2.53 GB linear /dev/thegroup/vol2 thegroup 5.78 GB ext4 5.78 GB 5.27 GB linear /dev/thegroup/vol3 thegroup 7.38 GB ext4 7.38 GB 6.75 GB linear fedora fedora 76.06 GB btrfs 76.06 GB 72.13 GB btrfs / ---------------------------------------------------------------------------------- [root@f18v ~]# btrfs fi show failed to read /dev/sr0 Label: 'fedora' uuid: 780b8553-4097-4136-92a4-c6fd48779b0c Total devices 1 FS bytes used 3.93GB devid 1 size 76.06GB used 76.06GB path /dev/sda1 [root@f18v ~]# btrfs fi df / Data: total=72.03GB, used=3.67GB System, DUP: total=8.00MB, used=16.00KB System: total=4.00MB, used=0.00 Metadata, DUP: total=2.00GB, used=257.54MB Metadata: total=8.00MB, used=0.00 [root@f18v ~]# df -h Filesystem Size Used Avail Use% Mounted on rootfs 77G 4.2G 69G 6% / devtmpfs 985M 0 985M 0% /dev tmpfs 1002M 312K 1002M 1% /dev/shm tmpfs 1002M 2.8M 1000M 1% /run tmpfs 1002M 0 1002M 0% /sys/fs/cgroup rpc_pipefs 77G 4.2G 69G 6% /var/lib/nfs/rpc_pipefs /dev/sda1 77G 4.2G 69G 6% / tmpfs 1002M 52K 1002M 1% /tmp /dev/sda1 77G 4.2G 69G 6% /home /dev/sda1 77G 4.2G 69G 6% /boot none 238G 46G 192G 20% /media/sf_VirtualBox_VMs
[chris@f18v ~]$ sudo btrfs balance status / 73 out of about 77 chunks balanced (74 considered), 5% left Again, interesting that during OS install (and 2-3 yum updates) ~77GB worth of chunks were allocated for only 4-5GB. This rebalance went quickly. [chris@f18v ~]$ sudo btrfs fi show failed to read /dev/sr0 Label: 'fedora' uuid: 780b8553-4097-4136-92a4-c6fd48779b0c Total devices 1 FS bytes used 3.91GB devid 1 size 76.06GB used 9.13GB path /dev/sda1 Btrfs Btrfs v0.19 [chris@f18v ~]$ sudo btrfs fi df / Data: total=5.00GB, used=3.66GB System, DUP: total=64.00MB, used=4.00KB System: total=4.00MB, used=0.00 Metadata, DUP: total=2.00GB, used=256.84MB And now: [root@f18v ~]# ssm list ------------------------------------------------------------- Device Free Used Total Pool Mount point ------------------------------------------------------------- /dev/sda 80.00 GB PARTITIONED /dev/sda1 66.93 GB 9.13 GB 76.06 GB fedora /dev/sda2 3.94 GB SWAP /dev/sdb 8.00 GB /dev/sdb1 0.00 KB 7.97 GB 8.00 GB thegroup /dev/sdc 8.00 GB /dev/sdc1 0.00 KB 7.97 GB 8.00 GB thegroup ------------------------------------------------------------- ------------------------------------------------------ Pool Type Devices Free Used Total ------------------------------------------------------ thegroup lvm 2 0.00 KB 15.94 GB 15.94 GB fedora btrfs 1 72.15 GB 76.06 GB 76.06 GB ------------------------------------------------------ ---------------------------------------------------------------------------------- Volume Pool Volume size FS FS size Free Type Mount point ---------------------------------------------------------------------------------- /dev/thegroup/vol1 thegroup 2.78 GB ext4 2.78 GB 2.53 GB linear /dev/thegroup/vol2 thegroup 5.78 GB ext4 5.78 GB 5.27 GB linear /dev/thegroup/vol3 thegroup 7.38 GB ext4 7.38 GB 6.75 GB linear fedora fedora 76.06 GB btrfs 76.06 GB 72.15 GB btrfs / ---------------------------------------------------------------------------------- So is there a bug? The first block ssm list returns (device) is clearly calculating free space differently than the other two blocks. 72.15 free vs 66.93 free is still a big difference, esp if the user isn't particularly familiar with btrfs.
Hi Chris, thanks a lot for the report. The first block (Device list) shows how much of the device is actually used for the volume (in this case btrfs file system) and it might not be even related to the file system size. In the first case, before the rebalance most of the space on the device was allocated by btrfs (for whatever weird reason) [root@f18v ~]# btrfs fi show failed to read /dev/sr0 Label: 'fedora' uuid: 780b8553-4097-4136-92a4-c6fd48779b0c Total devices 1 FS bytes used 3.93GB devid 1 size 76.06GB used 76.06GB path /dev/sda1 and the Device listing just presented that information /dev/sda1 573.44 KB 76.06 GB 76.06 GB fedora On the other hand after the rebalance the btrfs could free some of the chunks so actually have smaller portion of the device allocated: [chris@f18v ~]$ sudo btrfs fi show failed to read /dev/sr0 Label: 'fedora' uuid: 780b8553-4097-4136-92a4-c6fd48779b0c Total devices 1 FS bytes used 3.91GB devid 1 size 76.06GB used 9.13GB path /dev/sda1 So again we just present that information /dev/sda1 66.93 GB 9.13 GB 76.06 GB fedora Important to mention is that the portion of the device which is used might not correspond with the file system size, or even how much data is actually used in the file system. Well, it actually corresponds a little bit in the way that it will be always bigger than amount of data used by the file system (not talking about RAID). It is similar to the lvm where lvm can use just a part of the device to create logical volume. In this case we will show how much of the device is actually used and how much of it is free. Does it make sense for you ? Is there anything we can make to make this distinction more obvious ? Thanks! -Lukas
It does make sense. I think this is less a bug than it is (initially) unexpected behavior due in large part how btrfs can report usage. I wonder if the device list should represent information the user would find from parted, instead of being file system related? If the interface reveals information general to specific, you have the device list in a good position as the most general view. Maybe instead of free/used/total space based on the file systems (a more specific concept) on those devices, it's based on sectors (in human readable values). As you point out, with file systems like btrfs, we can end up with a situation where the free space reported is larger than the physical device, and in a device list I think that's confusing. If the device list is strictly about device size, that might make more sense. And then leave the file system used/free information in the pool and volume listings.
So the Total in the device listing should represent the device size. Granted that I should probably rename it to Size so it is more obvious. 'Free' and 'Used' represents how much of the device is used for a volume. It does not have nothing to do with file system in particular, but since btrfs has volume management accidentally this is file system related information in this case. But if we talk about lvm, then it is not. So this is "storage" related information in general and I think is incredibly useful to see how much (if any) space is actually used by the volume. Consider adding a device to the btrfs, or lvm pool. At that point the device is part of the pool, but it is not used at all so the 'Used' part of the device reports 0, which is useful information to have, because you immediately know that you could reuse that device for something else without much hassle. I am not sure what you mean about sector based information about the device. The information about the Size ("Total") of the device is gathered from /proc/partitions, and it is presented in human readable format. Also, in other volume management backends such as lvm, you do not have to use the whole device for a single volume and you can use one device for several volumes, so the 'Used' size adds up. So I think it is good to have such information. Or maybe I misunderstood you point ? Thanks! -Lukas
I think part of what's confusing is how btrfs fi show and fi df currently show used space. This is currently being discussed on the linux-btrfs list, looks like some changes for fi df (and possibly fi show) are being bounced around.
Yeah, I am going through the thread right now. So if you do not mind, I'll close this BZ with NOTABUG. Feel free to reopen it if you realize that there might still be a problem. Thanks! -Lukas