]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: reduce lock scope when assembling read results
authorJason Dillaman <dillaman@redhat.com>
Tue, 7 Nov 2017 18:42:19 +0000 (13:42 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 1 Feb 2018 16:16:26 +0000 (11:16 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 284feb6a32795c64b1c5ec3b3bf0d959e72dd940)

src/librbd/io/ReadResult.cc

index 1b8cdb0e6acf21e765295686c96884cbc14975ab..448de54200a167a3b2277068e3cddc3b3c8bcc6b 100644 (file)
@@ -113,27 +113,26 @@ void ReadResult::C_SparseReadRequestBase::finish(ExtentMap &extent_map,
                                                  const Extents &buffer_extents,
                                                  uint64_t offset, size_t length,
                                                  bufferlist &bl, int r) {
-  aio_completion->lock.Lock();
   CephContext *cct = aio_completion->ictx->cct;
   ldout(cct, 10) << "C_SparseReadRequestBase: r = " << r
                  << dendl;
 
-  if (r >= 0 || r == -ENOENT) { // this was a sparse_read operation
+  if (r >= 0 || r == -ENOENT) {
     ldout(cct, 10) << " got " << extent_map
                    << " for " << buffer_extents
                    << " bl " << bl.length() << dendl;
-    // reads from the parent don't populate the m_ext_map and the overlap
-    // may not be the full buffer.  compensate here by filling in m_ext_map
-    // with the read extent when it is empty.
+    // handle the case where a sparse-read wasn't issued
     if (extent_map.empty()) {
       extent_map[offset] = bl.length();
     }
 
+    aio_completion->lock.Lock();
     aio_completion->read_result.m_destriper.add_partial_sparse_result(
       cct, bl, extent_map, offset, buffer_extents);
+    aio_completion->lock.Unlock();
+
     r = length;
   }
-  aio_completion->lock.Unlock();
 
   C_ReadRequest::finish(r);
 }