]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: make has_parent() prone to callers from copyup
authorVenky Shankar <vshankar@redhat.com>
Mon, 5 Dec 2016 09:20:06 +0000 (14:50 +0530)
committerVenky Shankar <vshankar@redhat.com>
Sat, 21 Jan 2017 10:59:27 +0000 (16:29 +0530)
This is required when CopyupRequest would need to invoke
pre_object_map_update() as part of upcoming changes to
create fewer child image objects whenever possible.

CopyupRequest constructor accepts image extents as an
rvalue forcing the caller to transfer ownership to it
and leaving the original variable in an unspecified
stated making has_parent() return incorrect state when
invoked from CopyupRequest. Therefore, introduce a
private tracking state that can be used in place of
checking emptiness of parent image extents.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
src/librbd/AioObjectRequest.cc
src/librbd/AioObjectRequest.h

index 1b466efe52c4d8ac8f9512b51fec2dc2f05197e1..222abd1edb570d4006397761d96dd0cf391e9721 100644 (file)
@@ -112,6 +112,7 @@ bool AioObjectRequest<I>::compute_parent_extents() {
     lderr(m_ictx->cct) << this << " compute_parent_extents: failed to "
                        << "retrieve parent overlap: " << cpp_strerror(r)
                        << dendl;
+    m_has_parent = false;
     m_parent_extents.clear();
     return false;
   }
@@ -122,6 +123,7 @@ bool AioObjectRequest<I>::compute_parent_extents() {
     ldout(m_ictx->cct, 20) << this << " compute_parent_extents: "
                            << "overlap " << parent_overlap << " "
                            << "extents " << m_parent_extents << dendl;
+    m_has_parent = !m_parent_extents.empty();
     return true;
   }
   return false;
index 9ae2a84327c0dacc921a520f6b9e7bab37ce0692..8d6d98a19018f8af6ce24b7aa37a518c2052ce89 100644 (file)
@@ -80,7 +80,7 @@ public:
   virtual void send() = 0;
 
   bool has_parent() const {
-    return !m_parent_extents.empty();
+    return m_has_parent;
   }
 
 protected:
@@ -93,6 +93,9 @@ protected:
   Context *m_completion;
   Extents m_parent_extents;
   bool m_hide_enoent;
+
+private:
+  bool m_has_parent = false;
 };
 
 template <typename ImageCtxT = ImageCtx>