Bug #80241
closedosdc: EC split-op completion holds rwlock across user callback, causing lockdep cycle with image_lock
100%
Description
When an EC pool read completes through Objecter::op_post_split_op_complete, the Objecter::rwlock read-lock (rl) is acquired inside the completion lambda and then held all the way across the complete_op_reply call — including across the onfinish user callback that fires at the end of that function. This directly contradicts the pattern used in the non-split code path (handle_osd_op_reply), where the equivalent shared lock (sul) is explicitly released before complete_op_reply is called.
Lock ordering problem¶
Two edges are recorded in lockdep during normal librbd use on an EC pool:
image_lock → Objecter::rwlock — librbd acquires image_lock and then issues a RADOS operation (e.g. inside ObjectReadRequest::read_object), which internally acquires Objecter::rwlock.
Objecter::rwlock → image_lock — the EC split-op completion lambda fires with rl (read-lock on Objecter::rwlock) held, and the user callback (e.g. luks::LoadRequest::handle_read_header) acquires image_lock.
These two edges form a cycle. Lockdep detects it and calls ceph_abort().
Crash scenario¶
- Build and run a Debug build Ceph cluster (to enable lockdep instead of just deadlocking).
- Create a k=2, m=1 EC pool with overwrites enabled.
- Create a 32 MiB RBD image using the EC pool as the data pool.
- Format the image with LUKS2.
- Open the image and call rbd_encryption_load.
Root cause¶
In op_post_split_op_complete (src/osdc/Objecter.cc), the posted lambda:
Acquires rl (shared lock on Objecter::rwlock).
Acquires sl (unique lock on op->session->lock).
Calls complete_op_reply(op, ec, op->session, sl, rc) — with rl still held.
complete_op_reply releases sl internally and then fires the onfinish callback. At no point does it touch or release rwlock, so rl remains held for the duration of the callback.
The session pointer guard evaluated at step 1 (op->session != splitop_session) only needs rl to be held until sl is acquired. Once sl is held the session pointer is stable and rl serves no further purpose on the non-EAGAIN path. On the EAGAIN path rl must remain held because it is passed by reference to _op_submit.
Non-split path comparison¶
In handle_osd_op_reply the analogous lock sul (shared lock on rwlock) is released at line ~3941 with an explicit sul.unlock() before complete_op_reply is called at line ~3992. The split-op path was missing that unlock.
Fix¶
A one-line rl.unlock() call after acquiring sl and before calling complete_op_reply on the rc != -EAGAIN branch, matching the established pattern in handle_osd_op_reply.
Affected component¶
src/osdc/Objecter.cc — op_post_split_op_complete
MW Updated by Matty Williams 3 months ago
- Description updated (diff)
MW Updated by Matty Williams 3 months ago
- % Done changed from 70 to 90
- Pull request ID set to 71520
LF Updated by Laura Flores 3 months ago
PR sent to QA.
LF Updated by Laura Flores 3 months ago
PR has been added to a QA batch.
MW Updated by Matty Williams 3 months ago
- Status changed from In Progress to Fix Under Review
- % Done changed from 90 to 100
UB Updated by Upkeep Bot 2 months ago
- Copied to Backport #80753: umbrella: osdc: EC split-op completion holds rwlock across user callback, causing lockdep cycle with image_lock added
UB Updated by Upkeep Bot 2 months ago
- Status changed from Fix Under Review to Backporting
- Merge Commit set to 44aad5bf723108c8c87e5f9b500f673552f9dc31
- Fixed In set to v21.3.0-3527-g44aad5bf72
- Upkeep Timestamp set to 2026-09-22T15:53:11+00:00
UB Updated by Upkeep Bot 23 days ago
- Status changed from Backporting to Resolved
- Upkeep Timestamp changed from 2026-09-22T15:53:11+00:00 to 2026-11-10T00:55:26+00:00