On Sun, Nov 19, 2017 at 7:13 PM, Qu Wenruo <quwenruo.bt...@gmx.com> wrote: > > > On 2017年11月19日 14:17, Chris Murphy wrote: >> fstrim should trim free space, but it only trims unallocated. This is >> with kernel 4.14.0 and the entire 4.13 series. I'm pretty sure it >> behaved this way with 4.12 also. > > Tested with 4.14-rc7, can't reproduce it.
$ sudo btrfs fi us / Overall: Device size: 70.00GiB Device allocated: 31.03GiB Device unallocated: 38.97GiB Device missing: 0.00B Used: 22.12GiB Free (estimated): 47.62GiB (min: 47.62GiB) ...snip... $ sudo fstrim -v / /: 39 GiB (41841328128 bytes) trimmed Then I run btrfs-debug -b / and find the least used block group, at 8% usage; block group offset 174202028032 len 1073741824 used 89206784 chunk_objectid 256 flags 1 usage 0.08 And balance that block group: $ sudo btrfs balance start -dvrange=174202028032..174202028033 -dlimit=1 / Done, had to relocate 1 out of 32 chunks And trim again: /: 39 GiB (41841328128 bytes) trimmed > Any special mount options or setup? > (BTW, I also tried space_cache=v2 and default v1, no obvious difference) /dev/nvme0n1p8 on / type btrfs (rw,relatime,seclabel,ssd,space_cache,subvolid=333,subvol=/root27) Would a strace of fstrim help? -- Chris Murphy -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html