]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
librbd: remove previous incomplete primary snapshot after successfully creating a...
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Mon, 6 Mar 2023 09:58:03 +0000 (15:28 +0530)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 16 May 2023 20:15:43 +0000 (22:15 +0200)
commitef2b3be27e55e130907defa34971ecfbc36b51e1
tree7466da0387eadae0dc97ab0e891d79546d8a637c
parent3300e369469eed428f5b158d092667eb53b683b2
librbd: remove previous incomplete primary snapshot after successfully creating a new one

Problem:
-------
At a high level, creating a primary snapshot consists of three steps:

1. actually creating a snapshot in the mirror namespace
2. generating a set of image state objects with additional metadata for
   the snapshot
3. marking the snapshot as complete after the image state objects are
   written out

Depending on the circumstances, a request to create a primary snapshot
can be forwarded to rbd-mirror daemon.  If that happens and rbd-mirror
daemon gets axed for some practical reason after completing steps (1)
and/or (2) but before completing step (3), we are left with a
permanently incomplete primary snapshot because upon retrying that
primary snapshot creation request, librbd notices that such snapshot
already exists.  It does not check whether this "pre-existing" snapshot
is complete.

Solution:
--------
As part of the next mirror snapshot create (say triggered by the
scheduler) the unlink_peer() is called, it checks if there exists any
incomplete snapshot and delete them accordingly.

Fixes: https://tracker.ceph.com/issues/58887
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
(cherry picked from commit 165c9a4e163c5edfa77c900f61c680cc944b2b5d)
src/librbd/mirror/snapshot/CreatePrimaryRequest.cc
src/test/librbd/mirror/snapshot/test_mock_CreatePrimaryRequest.cc