From: Jason Dillaman Date: Thu, 30 Apr 2015 17:51:03 +0000 (-0400) Subject: librbd: give locks unique names to prevent false lockdep failures X-Git-Tag: v0.94.4~77^2~20 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6fdd3f1ce69fa2e00c6f1bedd5f72352953e1e44;p=ceph.git librbd: give locks unique names to prevent false lockdep failures Signed-off-by: Jason Dillaman (cherry picked from commit c474ee42b87975c04eeb2b40b976deb5a5e2d518) --- diff --git a/src/librbd/AioCompletion.h b/src/librbd/AioCompletion.h index 991c22517d08..362f0e6be596 100644 --- a/src/librbd/AioCompletion.h +++ b/src/librbd/AioCompletion.h @@ -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), diff --git a/src/librbd/AsyncObjectThrottle.cc b/src/librbd/AsyncObjectThrottle.cc index 4290eb8636c0..85cfec8e0db1 100644 --- a/src/librbd/AsyncObjectThrottle.cc +++ b/src/librbd/AsyncObjectThrottle.cc @@ -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) diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 3d76c75478e2..6092963e9f13 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -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), diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index 9962f48dfd7c..a80e632469dd 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -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(*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)) { } diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 2a82aa648b72..066f26ee7ce9 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -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) { diff --git a/src/librbd/internal.h b/src/librbd/internal.h index 419f929c48a3..4e56dc873173 100644 --- a/src/librbd/internal.h +++ b/src/librbd/internal.h @@ -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);