From 32e259c56c1ece5ca561dbd4d078f7e34c42bf30 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 4 Feb 2015 02:50:57 -0500 Subject: [PATCH] librbd: skip invalidating an invalid object map If the object map is already flagged as invalid, avoid attempting to set the invalid object map flag again. Signed-off-by: Jason Dillaman --- src/librbd/ObjectMap.cc | 14 +++++++++++--- src/librbd/ObjectMap.h | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/librbd/ObjectMap.cc b/src/librbd/ObjectMap.cc index 6b2be6389cc49..a3eec40a9959d 100644 --- a/src/librbd/ObjectMap.cc +++ b/src/librbd/ObjectMap.cc @@ -210,6 +210,10 @@ bool ObjectMap::aio_update(uint64_t start_object_no, uint64_t end_object_no, } void ObjectMap::invalidate() { + if ((m_image_ctx.flags & RBD_FLAG_OBJECT_MAP_INVALID) != 0) { + return; + } + CephContext *cct = m_image_ctx.cct; lderr(cct) << &m_image_ctx << " invalidating object map" << dendl; m_image_ctx.flags |= RBD_FLAG_OBJECT_MAP_INVALID; @@ -237,8 +241,7 @@ bool ObjectMap::Request::should_complete(int r) { } else if (r < 0) { lderr(cct) << "failed to update object map: " << cpp_strerror(r) << dendl; - invalidate(); - return false; + return invalidate(); } { @@ -267,7 +270,11 @@ bool ObjectMap::Request::should_complete(int r) { return false; } -void ObjectMap::Request::invalidate() { +bool ObjectMap::Request::invalidate() { + if ((m_image_ctx.flags & RBD_FLAG_OBJECT_MAP_INVALID) != 0) { + return true; + } + CephContext *cct = m_image_ctx.cct; RWLock::WLocker l(m_image_ctx.md_lock); @@ -283,6 +290,7 @@ void ObjectMap::Request::invalidate() { rados_completion, &op); assert(r == 0); rados_completion->release(); + return false; } void ObjectMap::ResizeRequest::send() { diff --git a/src/librbd/ObjectMap.h b/src/librbd/ObjectMap.h index 29eac9730af9b..0c476448d3c33 100644 --- a/src/librbd/ObjectMap.h +++ b/src/librbd/ObjectMap.h @@ -68,7 +68,7 @@ private: State m_state; - void invalidate(); + bool invalidate(); }; class ResizeRequest : public Request { -- 2.39.5