diff --git a/src/librbd/operation/FlattenRequest.cc b/src/librbd/operation/FlattenRequest.cc index 071cbe43d17..0b861ebe59d 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,