]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: bail from schedule_request_lock() if already lock owner 47116/head
authorChristopher Hoffman <choffman@redhat.com>
Thu, 14 Jul 2022 18:20:29 +0000 (12:20 -0600)
committerChristopher Hoffman <choffman@redhat.com>
Mon, 18 Jul 2022 13:25:04 +0000 (07:25 -0600)
Race condition may be hit if there are multiple pending locks for the
same image and pending callbacks. Abort exclusive lock process if
already exclusive lock owner.

Fixes: https://tracker.ceph.com/issues/56549
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
src/librbd/ImageWatcher.cc

index f8e47a8dfd3eb90f2980b36a263282dc13ad91ae..85049fac74f9aa34727262f6367df4c6405cdafb 100644 (file)
@@ -572,12 +572,11 @@ template <typename I>
 void ImageWatcher<I>::schedule_request_lock(bool use_timer, int timer_delay) {
   ceph_assert(ceph_mutex_is_locked(m_image_ctx.owner_lock));
 
-  if (m_image_ctx.exclusive_lock == nullptr) {
-    // exclusive lock dynamically disabled via image refresh
+  // see notify_request_lock()
+  if (m_image_ctx.exclusive_lock == nullptr ||
+      m_image_ctx.exclusive_lock->is_lock_owner()) {
     return;
   }
-  ceph_assert(m_image_ctx.exclusive_lock &&
-              !m_image_ctx.exclusive_lock->is_lock_owner());
 
   std::shared_lock watch_locker{this->m_watch_lock};
   if (this->is_registered(this->m_watch_lock)) {