]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: avoid repeatedly invoking is_zero() in CopyupRequest
authorIlya Dryomov <idryomov@gmail.com>
Mon, 22 Apr 2019 10:12:33 +0000 (12:12 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 24 Apr 2019 15:45:53 +0000 (17:45 +0200)
Invoke is_zero() just once, either in handle_read_from_parent() or
handle_deep_copy().

Initialize m_copyup_is_zero to true to preserve existing behavior:
on an empty bufferlist is_zero() returns true.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/librbd/io/CopyupRequest.cc
src/librbd/io/CopyupRequest.h

index 2299d3bf341961bac7ac2f6344d0d7414d0776d7..1cf686f15bd7023fd7828397cbf000ea14973d24 100644 (file)
@@ -180,6 +180,7 @@ void CopyupRequest<I>::handle_read_from_parent(int r) {
   ldout(cct, 20) << "oid=" << m_oid << ", r=" << r << dendl;
 
   m_lock.Lock();
+  m_copyup_is_zero = m_copyup_data.is_zero();
   m_copyup_required = is_copyup_required();
   disable_append_requests();
 
@@ -369,8 +370,8 @@ void CopyupRequest<I>::copyup() {
   ldout(cct, 20) << "oid=" << m_oid << dendl;
 
   bool copy_on_read = m_pending_requests.empty();
-  bool deep_copyup = !snapc.snaps.empty() && !m_copyup_data.is_zero();
-  if (m_copyup_data.is_zero()) {
+  bool deep_copyup = !snapc.snaps.empty() && !m_copyup_is_zero;
+  if (m_copyup_is_zero) {
     m_copyup_data.clear();
   }
 
@@ -522,7 +523,7 @@ bool CopyupRequest<I>::is_copyup_required() {
     return true;
   }
 
-  if (!m_copyup_data.is_zero()) {
+  if (!m_copyup_is_zero) {
     return true;
   }
 
index c30d5d409cb311f8f6da31326ed92efe7311e8c3..55eb5948bcbd6a5617761ecccc567fafa5c09e24 100644 (file)
@@ -87,6 +87,7 @@ private:
   bool m_deep_copy = false;
   bool m_flatten = false;
   bool m_copyup_required = true;
+  bool m_copyup_is_zero = true;
 
   ceph::bufferlist m_copyup_data;