Project

General

Profile

Actions

Enhancement #76420

closed
AK NN

Interruptible Allocator::foreach()

Enhancement #76420: Interruptible Allocator::foreach()

Added by Adam Kupczyk 7 months ago. Updated 4 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
Target version:
-
Due date:
% Done:

0%

Source:
Backport:
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Tags (freeform):
Fixed In:
v21.3.0-2162-g27051e9c37
Released In:
Upkeep Timestamp:
2026-08-19T09:45:05+00:00

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 Actions #1

  • Status changed from New to In Progress

YH Updated by Yaarit Hatuka 7 months ago Actions #2

  • Pull request ID set to 69039

NN Updated by Naveen Naidu 5 months ago Actions #3

  • Status changed from In Progress to Fix Under Review

UB Updated by Upkeep Bot 4 months ago Actions #4

  • 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
Actions

Also available in: PDF Atom