RFC btrfs: make autodefrag to defrag and only defrag small write ranges
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest3 patches 8 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | btrfs: remove an unused parameter of btrfs_add_inode_defrag()fs/ fs/ fs/ | +4 | 0 replies | |
| 2/3 | btrfs: introduce IO_TREE_AUTODEFRAG owner typefs/ fs/ | +17 | 0 replies | |
| 3/3 | btrfs: make autodefrag to defrag small writes without rescanning the whole filefs/ fs/ fs/ +1 more | +116 | 7 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH RFC 0/3] btrfs: make autodefrag to defrag and only defrag small write ranges
Previously autodefrag works by scanning the whole file with a minimal generation threshold.
Although we have various optimization to skip ranges which don't meet the generation requirement, it can still waste some time on scanning the whole file, especially if the inode got an almost full overwrite.
There is another problem, there is a gap between our small writes and defrag extent size threshold.
In fact, for compressed writes, <16K will be considered as small writes, while for uncompressed writes, <32K will be considered as small writes.
On the other hand, autodefrag uses 256K as default extent size threshold.
This means if one file has a lot of writes larger than 32K, which normally will not trigger autodefrag, but if one small write happens, all writes between 32K and 256K will be defragged.
This double standards is causing extra IO.
This patchset will address it by only defragging the small writes which trigger autodefrag.
This rework will cause the following behavior change:
- Only small write ranges will be defragged
Exactly what we want.
- Enlarged critical section for fs_info::defrag_inodes_lock Now we need to not only add the inode_defrag structure to rb tree, but also call set_extent_bits() inside the critical section.
Thus defrag_inodes_lock is upgraded to mutex.
No benchmark for the possible performance impact though.
- No inode re-queue if there are large sectors to defrag
Not sure if this will make a difference, as we no longer requeue, and only scan forward.
Reason for RFC:
I'm not sure if this is the correct way to go, but with my biased eyes, it looks very solid.
Another concern is how to backport for v5.16.
Qu Wenruo (3):
btrfs: remove an unused parameter of btrfs_add_inode_defrag()
btrfs: introduce IO_TREE_AUTODEFRAG owner type
btrfs: make autodefrag to defrag small writes without rescanning the
whole file
fs/btrfs/ctree.h | 5 +- fs/btrfs/disk-io.c | 2 +- fs/btrfs/extent-io-tree.h | 1 + fs/btrfs/file.c | 217 +++++++++++++++++++++----------------- fs/btrfs/inode.c | 2 +- 5 files changed, 125 insertions(+), 102 deletions(-)
Signature · 1 line
2.35.0