Skip to content

mds: take waiting flock on unlock if owner itself is waiting - #71369

Merged
vshankar merged 1 commit into
ceph:mainfrom
MaxKellermann:mds__unlock_drop_waiting
Sep 8, 2026
Merged

vshankar merged 1 commit into
ceph:mainfrom
MaxKellermann:mds__unlock_drop_waiting

Conversation

@MaxKellermann

@MaxKellermann MaxKellermann commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

handle_client_file_setlock() treated "owner has a request on the waiting list" and "owner holds a lock" as mutually exclusive: if is_waiting() matched, it cancelled the pending request and returned without ever calling remove_lock().

Yet an owner that is upgrading a shared lock to exclusive is both at the same time. Another unlock in that state (e.g. on another thread) therefore left the lock behind in held_locks without anybody actuall holding a lock. All following attempts to take an exclusive lock on that file will block forever in "failed to add lock, waiting", retrying whenever some unrelated unlock woke WAIT_FLOCK and getting nowhere.

Recovery is only possible by restarting the MDS process; anything else, including client eviction, will not remove bogus held_locks entries.

Solution: cancel the waiting entry if there is one, and, unless this is an interrupt (which cancels the pending request only), also remove the held lock.

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

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)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@github-actions github-actions Bot added cephfs Ceph File System tests labels Aug 26, 2026
@MaxKellermann
MaxKellermann force-pushed the mds__unlock_drop_waiting branch from ecd6a04 to eabaa01 Compare August 26, 2026 20:37
@xiubli

xiubli commented Aug 27, 2026

Copy link
Copy Markdown
Member

jenkins test make check

@xiubli xiubli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good Catch.

Commit message: "actuall" -> "actually", "unlock woke WAIT_FLOCK" -> "unlock wakes WAIT_FLOCK".

Overall LGTM.

@MaxKellermann

Copy link
Copy Markdown
Member Author

jenkins test make check arm64

handle_client_file_setlock() treated "owner has a request on the
waiting list" and "owner holds a lock" as mutually exclusive: if
is_waiting() matched, it cancelled the pending request and returned
without ever calling remove_lock().

Yet an owner that is upgrading a shared lock to exclusive is both at
the same time.  Another unlock in that state (e.g. on another thread)
therefore left the lock behind in `held_locks` without anybody
actually holding a lock.  All following attempts to take an exclusive
lock on that file will block forever in "failed to add lock, waiting",
retrying whenever some unrelated unlock wakes WAIT_FLOCK and getting
nowhere.

Recovery is only possible by restarting the MDS process; anything
else, including client eviction, will not remove bogus `held_locks`
entries.

Solution: cancel the waiting entry if there is one, and, unless this
is an interrupt (which cancels the pending request only), also remove
the held lock.

Fixes: https://tracker.ceph.com/issues/79952
Signed-off-by: Max Kellermann <[email protected]>
@MaxKellermann
MaxKellermann force-pushed the mds__unlock_drop_waiting branch from eabaa01 to d5c0bff Compare August 27, 2026 07:50
@MaxKellermann

Copy link
Copy Markdown
Member Author

Thanks @xiubli, I have pushed fixes for the commit message typos.

@MaxKellermann

Copy link
Copy Markdown
Member Author

jenkins test make check

@rishabh-d-dave rishabh-d-dave 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.

The tests looks fine, will do another pass for MDS code in some time.

Comment on lines +50 to +51
f1 = open(FILENAME, 'w')
f2 = open(FILENAME, 'w')

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.

nit: s/f1/fd1 and s/f2/fd2 just for the sake of clearer naming?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

How is that any clearer? These are file objects, not file descriptors. It's open(), not os.open().

@dparmar18

Copy link
Copy Markdown
Contributor

So basically if there are multiple owners say O1 and O2 having shared locks on the same range and O2 wants an exclusive then the get_overlapping_locks() splits them by owners (via split_by_owner()) and so now the O2 is having a waiting_locks entry with also keeping it in the held_locks list and if/when CEPH_LOCK_UNLOCK is requested from a different thread of the same process, ceph_lock_state_t::is_waiting yells true; MDS removes the EXCL request and also assumes the owner doesn't hold anything in the held_locks list. This will effectively block an owner acquire exclusive.

@vshankar
vshankar requested a review from a team September 2, 2026 12:39

@vshankar vshankar 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.

Good catch 👍

@vshankar

vshankar commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by vshankar started 2026-09-02-13:52.

@vshankar vshankar 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.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants