]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: hold AioCompletion lock while modifying global state
authorDan Mick <dan.mick@inktank.com>
Tue, 4 Dec 2012 04:59:17 +0000 (20:59 -0800)
committerDan Mick <dan.mick@inktank.com>
Thu, 6 Dec 2012 01:05:18 +0000 (17:05 -0800)
C_AioRead::finish needs to add in each chunk of a partial read
request to the 'partial' map in the AioCompletion's state
(in destriper, of type StripedReadResult).  That map is global
and must be protected from simultaneous access.  Use the
AioCompletion lock; could create a separate lock if contention is an
issue.

Fixes: #3567
Signed-off-by: Dan Mick <dan.mick@inktank.com>
src/librbd/AioCompletion.cc

index 082a08eb6517f26eb982e43bc8825472770c0e5b..86b5b504ebd3d96ac679c10f6e24c978a7da1756 100644 (file)
@@ -88,10 +88,11 @@ namespace librbd {
       if (m_req->m_ext_map.empty())
        m_req->m_ext_map[m_req->m_object_off] = m_req->data().length();
 
-      m_completion->destriper.add_partial_sparse_result(m_cct,
-                                                       m_req->data(),
-                                                       m_req->m_ext_map, m_req->m_object_off,
-                                                       m_req->m_buffer_extents);
+      m_completion->lock.Lock();
+      m_completion->destriper.add_partial_sparse_result(
+         m_cct, m_req->data(), m_req->m_ext_map, m_req->m_object_off,
+         m_req->m_buffer_extents);
+      m_completion->lock.Unlock();
       r = m_req->m_object_len;
     }
     m_completion->complete_request(m_cct, r);