Skip to content

os/bluestore: unpin an onode in the shard that holds it - #73664

Merged
Jayaprakash-ibm merged 2 commits into
ceph:mainfrom
ming1:wip-82605-unpin-shard
Nov 24, 2026
Merged

Jayaprakash-ibm merged 2 commits into
ceph:mainfrom
ming1:wip-82605-unpin-shard

Conversation

@ming1

@ming1 ming1 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

maybe_unpin() takes the lock of the shard a split_cache() may have moved the onode to while the caller waited, but then works on this shard's lru, age_bins and num. An onode unpinned while its PG is split is thus linked and counted in the wrong shard, under the other shard's lock. In the tree since a3057f4 (v18.1.0).

Move the work to _maybe_unpin_do() and call it on the shard whose lock is held. The unit test promotes an onode in one shard, calls maybe_unpin() on another, and checks the onode stays with the holding shard.

Split out of #73273 at ifed01's suggestion.

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

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)

@ming1

ming1 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@ming1

ming1 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@aclamk

aclamk commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

The explanation for the bug is too detailed I think.
The problem is that initial part of maybe_unpin() acquires the lock, and is aware that OnodeCacheShard* ocs can change while waiting for the lock.

What is missing the proper handling of the fact of changing ocs. Some accesses, specifically age_bins are accessed via this while we would like to have it accessed via ocs->age_bins.

I think the better solution would be to create function _maybe_unpin_do() that will consist of core part of the function:
https://github.com/ceph/ceph/pull/73664/changes#diff-a3d2a3267a1abacfec9417604d2d1fe40ec68a601060e61e44b8f6e6da43cccfR292-R321

That way we would get:

void maybe_unpin(bluestore::Onode* o) override
  {
    bluestore::OnodeCacheShard* ocs = this;
    ocs->lock.lock();
    // It is possible that during waiting split_cache moved us to different OnodeCacheShard.
    while (ocs != o->c->get_onode_cache()) {
      ocs->lock.unlock();
      ocs = o->c->get_onode_cache();
      ocs->lock.lock();
    }
    ocs->_maybe_unpin_do(o);
    ocs->lock_unlock();
  }

That way, we have 0 (zero) risk of messing up something between this and ocs.

@ming1
ming1 force-pushed the wip-82605-unpin-shard branch from 7e64833 to 44acf3e Compare November 17, 2026 14:18
@ming1

ming1 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

The explanation for the bug is too detailed I think.

Shortened, in both the commit message and the PR description.

I think the better solution would be to create function _maybe_unpin_do() that will consist of core part of the function

Agreed, that is cleaner. Moved the body to _maybe_unpin_do() (virtual in OnodeCacheShard, called under the shard's lock like _add/_rm), and maybe_unpin() now calls it on ocs.

@ming1
ming1 requested a review from aclamk November 17, 2026 14:20
Comment thread src/os/bluestore/BlueStore_components.h Resolved
@aclamk aclamk added the bluestore-needs-qa The PR is ready for teuthology testing. Bluestore team will do it. label Nov 18, 2026
maybe_unpin() takes the lock of the shard a split_cache() may have moved
the onode to while the caller waited, but then works on this shard's lru,
age_bins and num. An onode unpinned while its PG is split is thus linked
and counted in the wrong shard, under the other shard's lock.

Move the work to _maybe_unpin_do() and call it on the shard whose lock
is held.

In the tree since a3057f4 ("os/bluestore: fix onode ref counting").

Fixes: https://tracker.ceph.com/issues/82605
Signed-off-by: Ming Lei <[email protected]>
…oved out of

Promote an onode in one shard, then call maybe_unpin() on another shard,
as a caller does that read the collection's shard before a PG split moved
the onode. The onode must stay with the shard that holds it: its age bin
stamp stays there, the other shard's bins stay empty, and the holding
shard can still evict it.

Signed-off-by: Ming Lei <[email protected]>
@ming1
ming1 force-pushed the wip-82605-unpin-shard branch from 44acf3e to 23e3194 Compare November 18, 2026 11:57
@Jayaprakash-ibm

Copy link
Copy Markdown
Contributor

This PR has been added to wip-jaya-bs-testing2-18-11-2026.

@Jayaprakash-ibm

Copy link
Copy Markdown
Contributor

@Jayaprakash-ibm
Jayaprakash-ibm merged commit 8b4bf02 into ceph:main Nov 24, 2026
16 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/45411278838

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

Labels

bluestore bluestore-needs-qa The PR is ready for teuthology testing. Bluestore team will do it. core tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants