]> 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>
Wed, 21 Jun 2023 12:56:29 +0000 (14:56 +0200)
commitba6aa697c7831b04d03bb8031de5b247600ae03e
treede4289d68ce6643dde5f8e65e8665b241f34506b
parent4be78cea2b4ae54a27b1049cffa1208df48bffae
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)
src/librbd/io/ImageDispatch.cc
src/librbd/io/ImageRequest.cc
src/librbd/io/ImageRequest.h
src/librbd/journal/Replay.cc