From 284feb6a32795c64b1c5ec3b3bf0d959e72dd940 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 7 Nov 2017 13:42:19 -0500 Subject: [PATCH] librbd: reduce lock scope when assembling read results Signed-off-by: Jason Dillaman --- src/librbd/io/ReadResult.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/librbd/io/ReadResult.cc b/src/librbd/io/ReadResult.cc index 1b8cdb0e6ac..448de54200a 100644 --- a/src/librbd/io/ReadResult.cc +++ b/src/librbd/io/ReadResult.cc @@ -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); } -- 2.39.5