Will fstrim discard unused parts of chunks?
I try to understand what exactly is trimmed in case of btrfs. Using installation in QEMU I see that host file size is about 9GB, allocated size in guest approximately matches it and used space in guest is 7.6GB. After some experimenting it looks like host size follows "Device allocated" value in "btrfs filesystem usage" which leads me to believe trim only considers space outside of allocated chunks. Is it correct?
Quoted 6 lines · Andrei Borzenkov
I try to understand what exactly is trimmed in case of btrfs. Using installation in QEMU I see that host file size is about 9GB, allocated size in guest approximately matches it and used space in guest is 7.6GB. After some experimenting it looks like host size follows "Device allocated" value in "btrfs filesystem usage" which leads me to believe trim only considers space outside of allocated chunks. Is it correct?
It should consider all available space. The code iterates over all block groups and trims free space and then iterates over free dev extents, which is all of the unallocated space.
Which kernel version are you using? This stuff was broken for a while but was fixed in 4.3.
-Jeff
Signature · 2 lines
Jeff Mahoney SUSE Labs
Quoted 8 lines · Jeff Mahoney
Quoted 6 lines · Andrei Borzenkov
I try to understand what exactly is trimmed in case of btrfs. Using installation in QEMU I see that host file size is about 9GB, allocated size in guest approximately matches it and used space in guest is 7.6GB. After some experimenting it looks like host size follows "Device allocated" value in "btrfs filesystem usage" which leads me to believe trim only considers space outside of allocated chunks. Is it correct?
Quoted 6 lines
It should consider all available space. The code iterates over all block groups and trims free space and then iterates over free dev extents, which is all of the unallocated space.
Which kernel version are you using? This stuff was broken for a while but was fixed in 4.3.
Appears for some time now, since I think 4.6 or 4.7, to only trim unallocated space.
[chris@f25h ~]$ sudo btrfs fi us /
Overall:
Device size: 73.83GiB
Device allocated: 25.03GiB
Device unallocated: 48.80GiB
Device missing: 0.00B
Used: 21.29GiB
Free (estimated): 52.21GiB (min: 52.21GiB)
Data ratio: 1.00
Metadata ratio: 1.00
Global reserve: 71.16MiB (used: 0.00B)
Data,single: Size:24.00GiB, Used:20.59GiB
/dev/nvme0n1p4 20.00GiB
/dev/nvme0n1p6 4.00GiB
Metadata,single: Size:1.00GiB, Used:722.42MiB
/dev/nvme0n1p4 1.00GiB
System,single: Size:32.00MiB, Used:16.00KiB
/dev/nvme0n1p4 32.00MiB
Unallocated:
/dev/nvme0n1p4 3.97GiB
/dev/nvme0n1p6 44.83GiB
[chris@f25h ~]$ sudo fstrim -v /
[sudo] password for chris:
/: 48.8 GiB (52393148416 bytes) trimmed
[chris@f25h ~]$
Otherwise, it should have trimmed ~52GiB.
Signature · 1 line
Chris Murphy
Quoted 44 lines · Chris Murphy
Quoted 8 lines · Jeff Mahoney
Quoted 6 lines · Andrei Borzenkov
I try to understand what exactly is trimmed in case of btrfs. Using installation in QEMU I see that host file size is about 9GB, allocated size in guest approximately matches it and used space in guest is 7.6GB. After some experimenting it looks like host size follows "Device allocated" value in "btrfs filesystem usage" which leads me to believe trim only considers space outside of allocated chunks. Is it correct?
Quoted 6 lines
It should consider all available space. The code iterates over all block groups and trims free space and then iterates over free dev extents, which is all of the unallocated space.
Which kernel version are you using? This stuff was broken for a while but was fixed in 4.3.
Appears for some time now, since I think 4.6 or 4.7, to only trim unallocated space.
[chris@f25h ~]$ sudo btrfs fi us /
Overall:
Device size: 73.83GiB
Device allocated: 25.03GiB
Device unallocated: 48.80GiB
Device missing: 0.00B
Used: 21.29GiB
Free (estimated): 52.21GiB (min: 52.21GiB)
Data ratio: 1.00
Metadata ratio: 1.00
Global reserve: 71.16MiB (used: 0.00B)Data,single: Size:24.00GiB, Used:20.59GiB
/dev/nvme0n1p420.00GiB
/dev/nvme0n1p64.00GiBMetadata,single: Size:1.00GiB, Used:722.42MiB
/dev/nvme0n1p41.00GiBSystem,single: Size:32.00MiB, Used:16.00KiB
/dev/nvme0n1p432.00MiBUnallocated:
/dev/nvme0n1p4 3.97GiB /dev/nvme0n1p6 44.83GiB
Quoted 7 lines
[chris@f25h ~]$ sudo fstrim -v /
[sudo] password for chris:
/: 48.8 GiB (52393148416 bytes) trimmed
[chris@f25h ~]$Otherwise, it should have trimmed ~52GiB.
This was done with 4.8.15-300.fc25.x86_64
Signature · 1 line
Chris Murphy
03.01.2017 00:02, Jeff Mahoney пишет:
Quoted 8 lines · Andrei Borzenkov
Quoted 6 lines
I try to understand what exactly is trimmed in case of btrfs. Using installation in QEMU I see that host file size is about 9GB, allocated size in guest approximately matches it and used space in guest is 7.6GB. After some experimenting it looks like host size follows "Device allocated" value in "btrfs filesystem usage" which leads me to believe trim only considers space outside of allocated chunks. Is it correct?
Quoted 7 lines
It should consider all available space. The code iterates over all block groups and trims free space and then iterates over free dev extents, which is all of the unallocated space.
Which kernel version are you using? This stuff was broken for a while but was fixed in 4.3.
openSUSE TW 4.9.0-2-default.