From: Mykola Golub Date: Wed, 5 Sep 2018 17:24:00 +0000 (+0300) Subject: librbd: flatten operation should use object map X-Git-Tag: v14.0.1~320^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=40af4f87b64f944de786f6fcb6cc18eddd3633ef;p=ceph.git librbd: flatten operation should use object map If the object is known to exist in the image, the copy-up operation can be skipped for that object. Fixes: http://tracker.ceph.com/issues/23445 Signed-off-by: Mykola Golub --- diff --git a/src/librbd/operation/FlattenRequest.cc b/src/librbd/operation/FlattenRequest.cc index 071cbe43d174..0b861ebe59d0 100644 --- a/src/librbd/operation/FlattenRequest.cc +++ b/src/librbd/operation/FlattenRequest.cc @@ -40,6 +40,15 @@ public: return -ERESTART; } + { + RWLock::RLocker snap_lock(image_ctx.snap_lock); + if (image_ctx.object_map != nullptr && + !image_ctx.object_map->object_may_not_exist(m_object_no)) { + // can skip because the object already exists + return 1; + } + } + bufferlist bl; string oid = image_ctx.get_object_name(m_object_no); auto req = new io::ObjectWriteRequest(&image_ctx, oid, m_object_no, 0,