]> 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>
Thu, 4 Jun 2015 20:49:51 +0000 (16:49 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
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 bd527b130d6f54605911e5b74b177680c408202d..ddf0a14761c5efa5730984d26863adf692cdff08 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 7c02e03920e48c7565241e9b3a02b69907dde1d1..9fd5d38a2a1cbbc054587213eaa8a11f316fb109 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 1393de60aeffda48a68d0c8d9f7685b8b16fe537..0e12de2756e16389182a5b0b3e846ac608c9521a 100644 (file)
@@ -66,15 +66,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 e7b7a1ba3dd93eb7d7e45926e8485f56a04010ed..a006768c957852be7e643644e97eb67b608d0311 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 e9df16f3613a86141a89fe48a604d92b7cd5eb7b..96e9a554ef77e4f20216a0d4bd6e5e497dcf5376 100644 (file)
@@ -314,6 +314,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 860654f2805f075d714fd4c1ad78372bd166c0bc..a8e70b9b01dded5d81f3659ef310d1ae7477eeeb 100644 (file)
@@ -67,6 +67,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);