Project

General

Profile

Actions

Bug #80241

closed
MW MW

osdc: EC split-op completion holds rwlock across user callback, causing lockdep cycle with image_lock

Bug #80241: osdc: EC split-op completion holds rwlock across user callback, causing lockdep cycle with image_lock

Added by Matty Williams 3 months ago. Updated 23 days ago.

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

100%

Source:
Backport:
umbrella
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Component(RADOS):
Pull request ID:
Tags (freeform):
Fixed In:
v21.3.0-3527-g44aad5bf72
Released In:
Upkeep Timestamp:
2026-11-10T00:55:26+00:00

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

  1. Build and run a Debug build Ceph cluster (to enable lockdep instead of just deadlocking).
  2. Create a k=2, m=1 EC pool with overwrites enabled.
  3. Create a 32 MiB RBD image using the EC pool as the data pool.
  4. Format the image with LUKS2.
  5. 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


Related issues 1 (0 open — 1 closed)

Copied to RADOS - Backport #80753: umbrella: osdc: EC split-op completion holds rwlock across user callback, causing lockdep cycle with image_lockResolvedMatty Williams

Actions

MW Updated by Matty Williams 3 months ago Actions #1

  • Description updated (diff)

MW Updated by Matty Williams 3 months ago Actions #2

  • % Done changed from 70 to 90
  • Pull request ID set to 71520

LF Updated by Laura Flores 3 months ago Actions #3

PR sent to QA.

LF Updated by Laura Flores 3 months ago Actions #4

PR has been added to a QA batch.

MW Updated by Matty Williams 3 months ago Actions #5

  • Status changed from In Progress to Fix Under Review
  • % Done changed from 90 to 100

UB Updated by Upkeep Bot 2 months ago Actions #6

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

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

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

Also available in: PDF Atom