Skip to content

client: add defensive checks for LRU pin counter drift - #69970

Merged
chrisphoffman merged 2 commits into
ceph:mainfrom
salieri11:igolikov-lru-cache-fix-77947
Aug 20, 2026
Merged

chrisphoffman merged 2 commits into
ceph:mainfrom
salieri11:igolikov-lru-cache-fix-77947

Conversation

@salieri11

Copy link
Copy Markdown
Contributor

Summary

  • Add Client::assert_lru_num_pinned_sane() — checks num_pinned <= lru_size, logs LRU breakdown (and dentry details when available), then ceph_asserts
  • Call it around dentry trim/eviction paths: trim_cache, trim_cache_for_reconnect, close_dir parent unpin, unlink before lru_remove
  • Add ceph_assert(dn->dir) in trim_dentry and unlink; log parent dentry unpin in close_dir

Context

recurrence of tracker client tick thread crashed in
LRU::adjust() via Client::unlink() → lru_remove(). Core dump showed
num_pinned=2, size=1 — counter drift, not dentry UAF.

This PR adds diagnostics only (no lru.h changes, no behavioral fixes)
until we can reproduce the drift reliably.

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

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.

sometimes we hit a SIGSEGV in LRU::adjust() after num_pinned grew
larger than the LRU size (num_pinned=2, size=1 in the core dump).
Add client-side diagnostics only — no LRU logic changes.
Introduce assert_lru_num_pinned_sane() and call it around trim_cache,
close_dir parent unpin, and unlink/lru_remove. On drift it logs LRU
list sizes (and dentry ref/pin state when known) via lderr, then
asserts instead of crashing deep inside LRU::adjust().
Also assert dn->dir is set in trim_dentry/unlink, and log when
close_dir drops the parent dentry pin (suspected trigger path).

Signed-off-by: Igor Golikov <[email protected]>
Fixes: https://tracker.ceph.com/issues/77947
@github-actions github-actions Bot added the cephfs Ceph File System label Jul 6, 2026
@chrisphoffman
chrisphoffman requested a review from a team July 13, 2026 13:49
@vshankar
vshankar requested a review from chrisphoffman July 21, 2026 10:26

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

A few minor things

Can you discuss testing you did for this? I'd expect it to pass, but with these asserts we need to be sure it does. It will be beneficial to catch any low hanging issues before a teuthology run to save time.

Comment thread src/client/Client.cc Resolved
Comment thread src/client/Client.h Resolved
Comment thread src/client/Client.cc Resolved
Comment thread src/client/Client.cc Resolved
@chrisphoffman

Copy link
Copy Markdown
Contributor

@chrisphoffman

Copy link
Copy Markdown
Contributor

jenkins test api

Replace internal IBMCEPH-14337 references with public tracker URLs
and drop the duplicate <sstream> include in Client.h.

Signed-off-by: Igor Golikov <[email protected]>
Fixes: https://tracker.ceph.com/issues/77947
@salieri11

Copy link
Copy Markdown
Contributor Author

@chrisphoffman , thanks for the review. I have pushed the fix addressing your comments. Can be merged when tests pass

@chrisphoffman

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by choffman started 2026-08-06-18:43.

@chrisphoffman

Copy link
Copy Markdown
Contributor

jenkins test api

@chrisphoffman

Copy link
Copy Markdown
Contributor

jenkins test windows

@chrisphoffman

Copy link
Copy Markdown
Contributor

jenkins test make check

@chrisphoffman

Copy link
Copy Markdown
Contributor

jenkins test make check arm64

@chrisphoffman

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by choffman started 2026-08-11-17:22.

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.

2 participants