]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
librbd: avoid losing sparseness in read_parent()
authorIlya Dryomov <idryomov@gmail.com>
Thu, 15 Jan 2026 12:56:13 +0000 (13:56 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 16 Apr 2026 08:15:09 +0000 (10:15 +0200)
commitbd2204f7283a30d699778834280eed908440fd62
tree2384f69d44ef61877f02705d5451b5fcc56d3a42
parent12ccd61c348acd4b7db614bc8898a2feb7b1955f
librbd: avoid losing sparseness in read_parent()

When read_parent() constructs a read for image_ctx->parent, it employs
a thick bufferlist (either re-using the bufferlist on the object extent
or creating a temporary one inside of C_ObjectReadMergedExtents).  This
forgoes any sparseness: even if the result obtained by ObjectRequest is
sparse, it's thickened by ReadResult's handler for Bufferlist type.

This behavior is very old and hasn't been a problem for regular clones
because the public API returns a thick bufferlist in the case of C++ or
equivalent char* buf/struct iovec iov[] buffers in the case of C anyway.
ObjectCacher isn't sparse-aware but it's also not used for caching reads
by default and reading from parent for the purposes of a copyup is done
in CopyupRequest in a way that preserves sparseness.  However, when it
comes to migration, source image reads go through read_parent() and the
destination image gets thickened as an inadvertent side effect.

Fix this by introducing a new ChildObject type for ReadResult whose
handler would plant the result obtained by parent's ObjectRequest into
child's ObjectRequest, as if read_parent() wasn't even called.

Fixes: https://tracker.ceph.com/issues/73831
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/librbd/io/ReadResult.cc
src/librbd/io/ReadResult.h
src/librbd/io/Utils.cc
src/test/librbd/test_internal.cc