librbd: give locks unique names to prevent false lockdep failures

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
Jason Dillaman 2015-04-30 13:51:03 -04:00
parent c1e1445177
commit c474ee42b8
6 changed files with 21 additions and 15 deletions

View 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),

View 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)

View 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),

View 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))
{
}

View 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)
{

View 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);