]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: give locks unique names to prevent false lockdep failures
authorJason Dillaman <dillaman@redhat.com>
Thu, 30 Apr 2015 17:51:03 +0000 (13:51 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 28 Jul 2015 20:35:20 +0000 (16:35 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit c474ee42b87975c04eeb2b40b976deb5a5e2d518)

src/librbd/AioCompletion.h
src/librbd/AsyncObjectThrottle.cc
src/librbd/ImageCtx.cc
src/librbd/ImageWatcher.cc
src/librbd/internal.cc
src/librbd/internal.h

index 991c22517d081d6ef7a9d4bb6cb57d6f66990e0b..362f0e6be59675803b6a8f7b7b055658620de58b 100644 (file)
@@ -64,7 +64,7 @@ namespace librbd {
 
     AsyncOperation async_op;
 
-    AioCompletion() : lock("AioCompletion::lock", true),
+    AioCompletion() : lock(unique_lock_name("AioCompletion::lock", this), true),
                      done(false), rval(0), complete_cb(NULL),
                      complete_arg(NULL), rbd_comp(NULL),
                      pending_count(0), blockers(1),
index 4290eb8636c03178d7e4be86821063dfc6e5c26f..85cfec8e0db1252ace0deb3d43321d553cc74326 100644 (file)
@@ -3,6 +3,7 @@
 #include "librbd/AsyncObjectThrottle.h"
 #include "include/rbd/librbd.hpp"
 #include "librbd/AsyncRequest.h"
+#include "librbd/internal.h"
 
 namespace librbd
 {
@@ -12,7 +13,7 @@ AsyncObjectThrottle::AsyncObjectThrottle(const AsyncRequest& async_request,
                                         Context *ctx, ProgressContext &prog_ctx,
                                         uint64_t object_no,
                                         uint64_t end_object_no)
-  : m_lock("librbd::AsyncThrottle::m_lock"),
+  : m_lock(unique_lock_name("librbd::AsyncThrottle::m_lock", this)),
     m_async_request(async_request), m_context_factory(context_factory),
     m_ctx(ctx), m_prog_ctx(prog_ctx), m_object_no(object_no),
     m_end_object_no(end_object_no), m_current_ops(0), m_ret(0)
index 3d76c75478e2d400a6fa126d830e1679740f89a9..6092963e9f13be7ddf61799680ef2fbe17c09641 100644 (file)
@@ -63,15 +63,15 @@ public:
       image_watcher(NULL),
       refresh_seq(0),
       last_refresh(0),
-      owner_lock("librbd::ImageCtx::owner_lock"),
-      md_lock("librbd::ImageCtx::md_lock"),
-      cache_lock("librbd::ImageCtx::cache_lock"),
-      snap_lock("librbd::ImageCtx::snap_lock"),
-      parent_lock("librbd::ImageCtx::parent_lock"),
-      refresh_lock("librbd::ImageCtx::refresh_lock"),
-      object_map_lock("librbd::ImageCtx::object_map_lock"),
-      async_ops_lock("librbd::ImageCtx::async_ops_lock"),
-      copyup_list_lock("librbd::ImageCtx::copyup_list_lock"),
+      owner_lock(unique_lock_name("librbd::ImageCtx::owner_lock", this)),
+      md_lock(unique_lock_name("librbd::ImageCtx::md_lock", this)),
+      cache_lock(unique_lock_name("librbd::ImageCtx::cache_lock", this)),
+      snap_lock(unique_lock_name("librbd::ImageCtx::snap_lock", this)),
+      parent_lock(unique_lock_name("librbd::ImageCtx::parent_lock", this)),
+      refresh_lock(unique_lock_name("librbd::ImageCtx::refresh_lock", this)),
+      object_map_lock(unique_lock_name("librbd::ImageCtx::object_map_lock", this)),
+      async_ops_lock(unique_lock_name("librbd::ImageCtx::async_ops_lock", this)),
+      copyup_list_lock(unique_lock_name("librbd::ImageCtx::copyup_list_lock", this)),
       extra_read_flags(0),
       old_format(true),
       order(0), size(0), features(0),
index 9962f48dfd7c373648fbc502d92d817da5b04e62..a80e632469ddba22e34d399b545ff38cdbcb4643 100644 (file)
@@ -31,14 +31,14 @@ static const double RETRY_DELAY_SECONDS = 1.0;
 
 ImageWatcher::ImageWatcher(ImageCtx &image_ctx)
   : m_image_ctx(image_ctx),
-    m_watch_lock("librbd::ImageWatcher::m_watch_lock"),
+    m_watch_lock(unique_lock_name("librbd::ImageWatcher::m_watch_lock", this)),
     m_watch_ctx(*this), m_watch_handle(0),
     m_watch_state(WATCH_STATE_UNREGISTERED),
     m_lock_owner_state(LOCK_OWNER_STATE_NOT_LOCKED),
     m_task_finisher(new TaskFinisher<Task>(*m_image_ctx.cct)),
-    m_async_request_lock("librbd::ImageWatcher::m_async_request_lock"),
-    m_aio_request_lock("librbd::ImageWatcher::m_aio_request_lock"),
-    m_owner_client_id_lock("librbd::ImageWatcher::m_owner_client_id_lock")
+    m_async_request_lock(unique_lock_name("librbd::ImageWatcher::m_async_request_lock", this)),
+    m_aio_request_lock(unique_lock_name("librbd::ImageWatcher::m_aio_request_lock", this)),
+    m_owner_client_id_lock(unique_lock_name("librbd::ImageWatcher::m_owner_client_id_lock", this))
 {
 }
 
index 2a82aa648b7279779720f03ef4ace734546ca39b..066f26ee7ce9c531fac911520cbc14f3ce349ff8 100644 (file)
@@ -152,6 +152,10 @@ int invoke_async_request(ImageCtx *ictx, const std::string& request_type,
     return image_name + RBD_SUFFIX;
   }
 
+  std::string unique_lock_name(const std::string &name, void *address) {
+    return name + " (" + stringify(address) + ")";
+  }
+
   int detect_format(IoCtx &io_ctx, const string &name,
                    bool *old_format, uint64_t *size)
   {
index 419f929c48a3d2b0756cd089e6fa5e0ac7cec2f0..4e56dc8731737c9de07f9444bf9a25fdafd6b0ee 100644 (file)
@@ -76,6 +76,7 @@ namespace librbd {
   const std::string id_obj_name(const std::string &name);
   const std::string header_name(const std::string &image_id);
   const std::string old_header_name(const std::string &image_name);
+  std::string unique_lock_name(const std::string &name, void *address);
 
   int detect_format(librados::IoCtx &io_ctx, const std::string &name,
                    bool *old_format, uint64_t *size);