Skip to content

librbd/mirror: detect trashed snapshots in UnlinkPeerRequest - #67482

Merged
idryomov merged 1 commit into
ceph:mainfrom
idryomov:wip-68279
Feb 26, 2026
Merged

idryomov merged 1 commit into
ceph:mainfrom
idryomov:wip-68279

Conversation

@idryomov

Copy link
Copy Markdown
Contributor

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.

If two instances of UnlinkPeerRequest race with each other (e.g. due
to rbd-mirror daemon unlinking from a previous mirror snapshot and the
user taking another mirror snapshot at same time), the snapshot that
UnlinkPeerRequest was created for may be in the process of being removed
(which may mean trashed by SnapshotRemoveRequest::trash_snap()) or fully
removed by the time unlink_peer() grabs the image lock.  Because trashed
snapshots weren't handled explicitly, UnlinkPeerRequest could spuriously
fail with EINVAL ("not mirror snapshot" case) instead of the expected
ENOENT ("missing snapshot" case).  This in turn could lead to spurious
ImageReplayer failures with it stopping prematurely.

Fixes: https://tracker.ceph.com/issues/68279
Signed-off-by: Ilya Dryomov <[email protected]>
@idryomov
idryomov requested a review from a team February 24, 2026 12:42
@idryomov

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@ajarr ajarr 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 commit and the fix makes sense to me.

I looked at the tracker ticket to see the tests that failed, e.g., TestImageReplayer/3.ImageRename. I was trying to figure out how that test caused UnlinkPeerRequests to race. So renaming of the remote image ends up initiating a UnlinkPeerRequest and that races with the replayer initiating its own UnlinkPeerRequest when it's replaying and trying to get rid of unwanted remote mirror snapshots?

@idryomov

Copy link
Copy Markdown
Contributor Author

So renaming of the remote image ends up initiating a UnlinkPeerRequest and that races with the replayer initiating its own UnlinkPeerRequest when it's replaying and trying to get rid of unwanted remote mirror snapshots?

Yes -- this->flush() takes a mirror snapshot to replay/sync the rename and from there CreatePrimaryRequest invokes UnlinkPeerRequest:

TYPED_TEST(TestImageReplayer, ImageRename) {
  this->create_replayer();
  this->start();

  librbd::ImageCtx* remote_image_ctx = nullptr;
  this->open_remote_image(&remote_image_ctx);
  auto image_name = this->get_temp_image_name();
  ASSERT_EQ(0, remote_image_ctx->operations->rename(image_name.c_str()));
  this->flush(remote_image_ctx);
  ...
  void flush(librbd::ImageCtx *ictx)
  {
    ...
    if (MIRROR_IMAGE_MODE == cls::rbd::MIRROR_IMAGE_MODE_JOURNAL) {
       ...
    } else {
      uint64_t snap_id = CEPH_NOSNAP;
      ASSERT_EQ(0, librbd::api::Mirror<>::image_snapshot_create(
                  ictx, 0, &snap_id));
    }

@idryomov

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@idryomov
idryomov merged commit 15a4428 into ceph:main Feb 26, 2026
7 checks passed
@idryomov
idryomov deleted the wip-68279 branch February 26, 2026 19:48
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.

2 participants