]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
librbd: use an up-to-date snap context when owning the exclusive lock
authorIlya Dryomov <idryomov@gmail.com>
Mon, 12 Jun 2023 19:45:03 +0000 (21:45 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 2 Jul 2023 12:00:35 +0000 (14:00 +0200)
commita92c533e56e65906e34a3a61e2af0f66c23d2954
tree7120daf3be831f11b7a7f0a51f8236b4b3c95eec
parentb836b6bc5a20d18357b2f9e8ac006e18500b3211
librbd: use an up-to-date snap context when owning the exclusive lock

By effectively moving capturing of the snap context to the API layer,
commit 1d0a3b17f590 ("librbd: pass IOContext to image-extent IO
dispatch methods") introduced a nasty regression.  The snap context can
be captured only after exclusive lock is safely held for the duration
of dealing with the image request and even then must be refreshed if
a snapshot creation request is accepted from a peer.  This is needed to
ensure correctness of the object map in general and fast-diff states in
particular (OBJECT_EXISTS vs OBJECT_EXISTS_CLEAN) and object deltas
computed based off of them.  Otherwise the object map that is forked
for the snapshot isn't guaranteed to accurately reflect the contents of
the snapshot when the snapshot is taken under I/O (as in disabling the
object map may lead to different results being returned for reads).

The regression affects mainly differential backup and snapshot-based
mirroring use cases with object-map and/or fast-diff enabled: since
some object deltas may be incomplete, the destination image may get
corrupted.

This commit represents a reasonable minimal fix: IOContext passed
through to ImageDispatch is effected only for reads and just gets
ignored for writes.  The next commit cleans up further by undoing the
passing of IOContext through the image dispatch layers for writes.

Fixes: https://tracker.ceph.com/issues/61616
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit e4b1e0466354942c935e9eca2ab2858e75049415)

Conflicts:
src/librbd/io/ImageDispatch.cc [ ImageArea support not in
  pacific ]
src/librbd/io/ImageRequest.cc [ ditto ]
src/librbd/io/ImageRequest.h [ ditto ]
src/librbd/journal/Replay.cc [ ditto ]
src/librbd/io/ImageDispatch.cc
src/librbd/io/ImageRequest.cc
src/librbd/io/ImageRequest.h
src/librbd/journal/Replay.cc