Enhancement #76420
closedInterruptible Allocator::foreach()
0%
Description
1. Background
https://github.com/ceph/ceph/blob/main/src/os/bluestore/Allocator.h
```BlueStore::Allocator::foreach()``` is a function that retrieves all free extents.
2. Problem
```foreach()``` can take a long time to execute and does it under the lock.
In some cases lock is desired - for example shutting down requires exact state.
In others, it is a problem:
in BlueStore::MempoolThread::entry we periodically call Allocator::get_fragmentation_score
(https://github.com/ceph/ceph/blob/main/src/os/bluestore/BlueStore.cc#L5666).
Holding allocator lock causes visible glitch in bluestore write operations every 1h.
3. Solution
a) Expand ```BlueStore::Allocator``` interface with a ranged / interruptible variant.
Temp name: foreach_interruptible; propose better.
New call should allow to retrieve all free extents, but in a way to release lock periodically.
It is perfectly ok for retrieval to be off by some recently allocated / released extents, but not more;
the procedure must not get confused with extents being split / merged.
It will be best if arguments include: range begin, range end, max extents to process.
Document foreach_interruptible contract, limitations, caveats etc.
b) There should be a way to detect that specific Allocator does not implement foreach_interruptible.
c) Add to Allocator a convenience function that does ```foreach()``` logic, but if possible using foreach_interruptible.
Document the function.
d) Implement foreach_interruptible for some allocators.
NOTE: I am not sure if all existing allocators are always listing extents in order (hybrid!).
e) Unittests proving required features work.
Maybe measure cost of splitting foreach in smaller and chunks.
NN Updated by Naveen Naidu 7 months ago
- Status changed from New to In Progress
YH Updated by Yaarit Hatuka 7 months ago
- Pull request ID set to 69039
NN Updated by Naveen Naidu 5 months ago
- Status changed from In Progress to Fix Under Review
UB Updated by Upkeep Bot 4 months ago
- Status changed from Fix Under Review to Resolved
- Merge Commit set to 27051e9c3747ccd7f6c60ffedf2ac043541c786e
- Fixed In set to v21.3.0-2162-g27051e9c37
- Upkeep Timestamp set to 2026-08-19T09:45:05+00:00