]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
rbd-mirror: generally skip replay/resync if remote image is not primary
authorIlya Dryomov <idryomov@gmail.com>
Mon, 20 Jun 2022 12:19:41 +0000 (14:19 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 22 Jun 2022 12:33:07 +0000 (14:33 +0200)
commitef3ebf55c1783ca6f29287697a886e26165eb9a0
treeb3b348656071b049a67e0219abc440528f0d65ff
parent4287d7e651307fe10a7bfaa2c81ca5ac81dbb64e
rbd-mirror: generally skip replay/resync if remote image is not primary

Replay and resync should generally be skipped if the remote image is
not primary.

If this is not done for replay, snapshot-based mirroring can run into
a livelock if the primary image is demoted while a mirror snapshot is
being synced.  On the demote site, rbd-mirror would pick up the just
demoted image, grab the exclusive lock on it and idle waiting for a new
mirror snapshot to be created.  On the (still) non-primary site,
rbd-mirror would eventually finish syncing that mirror snapshot and
attempt to unlink from it on the demote site.  These attempts would
fail with EROFS due to exclusive lock being held in the "refuse proxied
maintenance operations" mode, blocking forward progress (syncing of the
demotion snapshot so that the non-primary image can be orderly promoted
to primary, etc).

If this is not done for resync, data loss can ensue as the just demoted
image would be immediately trashed, underneath the non-primary site that
is still syncing.

Currently this is done in PrepareReplayRequest only for journal-based
mirroring.  Note that it is conditional: if the local image is linked
to the remote image, proceeding is desirable.

Generalize this check, consolidate it with a related check in
PrepareRemoteImageRequest and move the result to BootstrapRequest to
cover both "local image does not exist" and "local image is unlinked"
cases for both modes.

Fixes: https://tracker.ceph.com/issues/54448
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 79d28e63cb47e9bacbb2fd8a5ddc3a092377731b)
src/test/rbd_mirror/image_replayer/journal/test_mock_PrepareReplayRequest.cc
src/test/rbd_mirror/image_replayer/test_mock_BootstrapRequest.cc
src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc
src/tools/rbd_mirror/image_replayer/PrepareRemoteImageRequest.cc
src/tools/rbd_mirror/image_replayer/StateBuilder.cc
src/tools/rbd_mirror/image_replayer/StateBuilder.h
src/tools/rbd_mirror/image_replayer/journal/PrepareReplayRequest.cc