From: Venky Shankar Date: Mon, 5 Dec 2016 09:20:06 +0000 (+0530) Subject: librbd: make has_parent() prone to callers from copyup X-Git-Tag: v12.0.0~114^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ad0dcff47f60a949b70fd75dd7813cdc5a621810;p=ceph.git librbd: make has_parent() prone to callers from copyup 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 --- diff --git a/src/librbd/AioObjectRequest.cc b/src/librbd/AioObjectRequest.cc index 1b466efe52c..222abd1edb5 100644 --- a/src/librbd/AioObjectRequest.cc +++ b/src/librbd/AioObjectRequest.cc @@ -112,6 +112,7 @@ bool AioObjectRequest::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::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; diff --git a/src/librbd/AioObjectRequest.h b/src/librbd/AioObjectRequest.h index 9ae2a84327c..8d6d98a1901 100644 --- a/src/librbd/AioObjectRequest.h +++ b/src/librbd/AioObjectRequest.h @@ -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