btrfs: defrag: what if v5.15 is doing proper defrag
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 15 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | btrfs: defrag: don't defrag preallocated extentsfs/ | +10 | 0 replies | |
| 2/2 | btrfs: defrag: limit cluster size to the first hole/prealloc rangefs/ | +31 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [POC for v5.15 0/2] btrfs: defrag: what if v5.15 is doing proper defrag
** DON'T MERGE, THIS IS JUST A PROOF OF CONCEPT **
There are several reports about v5.16 btrfs autodefrag is causing more IO than v5.15.
But it turns out that, commit f458a3873ae ("btrfs: fix race when defragmenting leads to unnecessary IO") is making defrags doing less work than it should.
Thus damping the IO for autodefrag.
This POC series is to make v5.15 kernel to do proper defrag of all good candidates while still not defrag any hole/preallocated range.
The test script here looks like this:
wipefs -fa $dev
mkfs.btrfs -f $dev -U $uuid > /dev/null mount $dev $mnt -o autodefrag
$fsstress -w -n 2000 -p 1 -d $mnt -s 1642319517 sync
echo "=== baseline ==="
cat /sys/fs/btrfs/$uuid/debug/io_accounting/data_write echo 0 > /sys/fs/btrfs/$uuid/debug/cleaner_trigger sleep 3
sync
echo "=== after autodefrag ==="
cat /sys/fs/btrfs/$uuid/debug/io_accounting/data_write umount $mnt
<uuid>/debug/io_accounting/data_write is the new debug features showing how many bytes has been written for a btrfs.
The numbers are before chunk mapping.cleaer_trigger is the trigger to wake up cleaner_kthread so autodefrag can do its work.
Now there is result:
| Data bytes written | Diff to baseline
----------------+--------------------+------------------
no autodefrag | 36896768 | 0 v5.15 vanilla | 40079360 | +8.6% v5.15 POC | 42491904 | +15.2%
v5.16 fixes | 42536960 | +15.3%
The data shows, although v5.15 vanilla is really causing the least amount of IO for autodefrag, if v5.15 is patched with POC to do proper defrag, the final IO is almost the same as v5.16 with submitted fixes.
So this proves that, the v5.15 has lower IO is not a valid default, but a regression which leads to less efficient defrag.
And the IO increase is in fact a proof of a regression being fixed.
Qu Wenruo (2):
btrfs: defrag: don't defrag preallocated extents
btrfs: defrag: limit cluster size to the first hole/prealloc range
fs/btrfs/ioctl.c | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-)
Signature · 1 line
2.34.1