X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Flibrbd%2FExclusiveLock.cc;h=8436bad87695ea389c26bb3d07db3e6d5cbdb717;hb=224ce89bce8186937e77bdbda572a650953f8c23;hp=a3d69fce89fbed9b7b48a1f5f910f5d6bf4c5c31;hpb=31f18b776d001752a193a7cec8bb49033c1a904c;p=ceph.git diff --git a/ceph/src/librbd/ExclusiveLock.cc b/ceph/src/librbd/ExclusiveLock.cc index a3d69fce8..8436bad87 100644 --- a/ceph/src/librbd/ExclusiveLock.cc +++ b/ceph/src/librbd/ExclusiveLock.cc @@ -147,8 +147,14 @@ template void ExclusiveLock::handle_init_complete(uint64_t features) { ldout(m_image_ctx.cct, 10) << ": features=" << features << dendl; - if ((features & RBD_FEATURE_JOURNALING) != 0) { - m_image_ctx.io_work_queue->set_require_lock_on_read(); + { + RWLock::RLocker owner_locker(m_image_ctx.owner_lock); + if (m_image_ctx.clone_copy_on_read || + (features & RBD_FEATURE_JOURNALING) != 0) { + m_image_ctx.io_work_queue->set_require_lock(io::DIRECTION_BOTH, true); + } else { + m_image_ctx.io_work_queue->set_require_lock(io::DIRECTION_WRITE, true); + } } Mutex::Locker locker(ML::m_lock); @@ -161,7 +167,7 @@ void ExclusiveLock::shutdown_handler(int r, Context *on_finish) { { RWLock::WLocker owner_locker(m_image_ctx.owner_lock); - m_image_ctx.io_work_queue->clear_require_lock_on_read(); + m_image_ctx.io_work_queue->set_require_lock(io::DIRECTION_BOTH, false); m_image_ctx.exclusive_lock = nullptr; } @@ -269,7 +275,7 @@ void ExclusiveLock::handle_post_acquired_lock(int r) { if (r >= 0) { m_image_ctx.image_watcher->notify_acquired_lock(); - m_image_ctx.io_work_queue->clear_require_lock_on_read(); + m_image_ctx.io_work_queue->set_require_lock(io::DIRECTION_BOTH, false); m_image_ctx.io_work_queue->unblock_writes(); } @@ -302,16 +308,11 @@ void ExclusiveLock::post_release_lock_handler(bool shutting_down, int r, if (r >= 0) { m_image_ctx.image_watcher->notify_released_lock(); - if (m_image_ctx.io_work_queue->is_lock_request_needed()) { - // if we have blocked IO -- re-request the lock - RWLock::RLocker owner_locker(m_image_ctx.owner_lock); - ML::acquire_lock(nullptr); - } } } else { { RWLock::WLocker owner_locker(m_image_ctx.owner_lock); - m_image_ctx.io_work_queue->clear_require_lock_on_read(); + m_image_ctx.io_work_queue->set_require_lock(io::DIRECTION_BOTH, false); m_image_ctx.exclusive_lock = nullptr; }