Skip to content

cls/lock: don't clean an expired ephemeral lock from a read-only method - #72310

Merged
idryomov merged 1 commit into
ceph:mainfrom
jhoblitt:wip-rgw-r21-clslock
Nov 11, 2026
Merged

idryomov merged 1 commit into
ceph:mainfrom
jhoblitt:wip-rgw-r21-clslock

Conversation

@jhoblitt

@jhoblitt jhoblitt commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

get_info and assert_locked are registered read-only (CLS_METHOD_RD;
RdTag / RdPromoteTag on main). When they read an ephemeral lock whose
holders have all expired, read_lock() removes the now-empty object with
cls_cxx_remove(). The OSD rejects that write from a non-WR method and
fails the whole class call with EIO (PrimaryLogPG: "tried to update
object but is not marked WR"), so both methods answer EIO instead of the
lock's state and the cleanup is lost. Present since ephemeral locks landed in
a289f2d8654 (v14.1.0); verified at v19.2.6, v20.2.4 and main.

This gates the removal on a may_write flag the callers pass: the
write-capable methods (lock, unlock, break_lock, set_cookie) still
clean the drained object; the read-only methods skip the removal and report
the lock as empty. The next lock replaces the drained lock, and that holder's
unlock removes the object.

#56575 logged this same failure in
2022 but was closed by a test-only change
(ceph/ceph#47148) that lengthened
the test's lock durations so the lock never expired; the class behaviour was
never corrected.

Fixes: https://tracker.ceph.com/issues/80993

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)

@jhoblitt jhoblitt self-assigned this Oct 1, 2026
@github-actions github-actions Bot added the rbd label Oct 1, 2026
@jhoblitt
jhoblitt marked this pull request as ready for review October 12, 2026 22:03
@jhoblitt
jhoblitt requested review from a team as code owners October 12, 2026 22:03

@idryomov idryomov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest adding a test case to src/test/cls_lock/test_cls_lock.cc that would e.g. set duration to 3 seconds, sleep for 4 seconds, run lock_info() asserting success, run ioctx.stat() asserting that the object is still there, run some write-capable method and finally run ioctx.stat() again asserting that the object is now gone.

@rzarzynski
rzarzynski requested a review from cbodley October 15, 2026 19:36
@rzarzynski

Copy link
Copy Markdown
Contributor

RGW also uses cls_lock, so @cbodley might be interested as well.

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath11-testing-20261027.070430-main.

read_lock() removes the backing object when an ephemeral lock has drained
of unexpired holders, via cls_cxx_remove(). get_info and assert_locked are
registered read-only (CLS_METHOD_RD, RdTag / RdPromoteTag), so when they
reach that path the OSD rejects the write issued by a non-WR method and
fails the whole class call with EIO (PrimaryLogPG: "tried to update object
but is not marked WR"). Both methods then answer EIO instead of the lock's
state, and the cleanup is lost with them.

Gate the removal on a may_write flag that read_lock's callers pass: the
write-capable methods (lock, unlock, break_lock, set_cookie) still clean the
drained object, while the read-only methods skip the removal and report the
lock as empty. The next lock replaces the drained lock and that holder's
unlock removes the object; the removal was already lost before this
change, so nothing new is left behind.

https://tracker.ceph.com/issues/56575 logged this same failure in 2022
but was closed by a test-only change (PR ceph#47148) that
lengthened the test's lock durations so the lock never expired during
the run; the class behaviour was never corrected.

Assisted-by: Claude-v2.1.286:claude-opus-4-8
Assisted-by: Claude-v2.1.318:claude-opus-5-5
Fixes: https://tracker.ceph.com/issues/80993
Signed-off-by: Joshua Hoblitt <[email protected]>
@jhoblitt
jhoblitt force-pushed the wip-rgw-r21-clslock branch from 6756ea7 to 8291d0c Compare November 5, 2026 18:29
@github-actions github-actions Bot added the tests label Nov 5, 2026
@jhoblitt

jhoblitt commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

This is @jhoblitt's AI agent.

@SrinivasaBharath #72310 changed after the QA run in https://tracker.ceph.com/issues/82147. The only change is a new test, TestExclusiveEphemeralExpiredReadOnly in src/test/cls_lock/test_cls_lock.cc, which idryomov asked for; src/cls/lock/cls_lock.cc is identical to what was tested. The new test itself has not run in teuthology yet.

@connorfawcett

Copy link
Copy Markdown
Contributor

@idryomov
idryomov merged commit 74a992e into ceph:main Nov 11, 2026
17 checks passed
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/42996871055

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants