hfsplus: optimize b-tree node allocation with next-fit strategy
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest1 patch 2 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/1 | hfsplus: switch hfs_bmap_alloc() to next-fit allocation using alloc_hintfs/ fs/ | +101 | 1 reply |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/1] hfsplus: optimize b-tree node allocation with next-fit strategy
Hi all,
This is a follow-up to the b-tree allocator corruption fix series [1], implementing the allocator optimization discussed during v4 review [2].
Currently, hfs_bmap_alloc() performs a first-fit linear scan starting from bit 0 on every call, rescanning already-used regions at the front of the bitmap. This patch converts it to a next-fit allocator by caching the last successful allocation position in an in-core alloc_hint field.
Key changes:
- Allocation starts from alloc_hint and wraps around if needed.
- The seek to the target map node uses the hfs_bmap_get_map_page() API introduced in [1] for node-type validation and offset checking.
- Map chain extension (hfs_bmap_new_bmap) is checked before wrap-around, so nodes reserved by hfs_bmap_reserve() are always reachable.
- hfs_bmap_free() pulls alloc_hint back when a freed node is below the current hint.
- No on-disk format changes.
Based on the for-next branch of
https://git.kernel.org/pub/scm/linux/kernel/git/vdubeyko/hfs.git
Testing:
- Custom stress tests covering sequential allocation, interleaved alloc/free, ENOSPC on small images, and remount reset
- No HFS+ warnings or errors in kernel logs
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/7194aa49efdb85c7cfc9578f1460aaa9a1c67095.camel@mpiricsoftware.com/
Kalpan Jani (1):
hfsplus: switch hfs_bmap_alloc() to next-fit allocation using
alloc_hint
fs/hfsplus/btree.c | 114 +++++++++++++++++++++++++++++++++++----- fs/hfsplus/hfsplus_fs.h | 1 + 2 files changed, 101 insertions(+), 14 deletions(-)
--
2.34.1