From ef453630200ab72373f08357ca6b5ac5c5bbb397 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Fri, 17 Jul 2015 12:43:46 -0400 Subject: [PATCH] librbd: new ImageWatcher::is_lock_supported method The new version does not attempt to acquire the snap_lock, to avoid cases where a recursive lock would result. Signed-off-by: Jason Dillaman --- src/librbd/ImageWatcher.cc | 7 ++++++- src/librbd/ImageWatcher.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index 860f7090eb19a..9962f48dfd7c3 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -56,8 +56,13 @@ ImageWatcher::~ImageWatcher() } bool ImageWatcher::is_lock_supported() const { - assert(m_image_ctx.owner_lock.is_locked()); RWLock::RLocker l(m_image_ctx.snap_lock); + return is_lock_supported(m_image_ctx.snap_lock); +} + +bool ImageWatcher::is_lock_supported(const RWLock &) const { + assert(m_image_ctx.owner_lock.is_locked()); + assert(m_image_ctx.snap_lock.is_locked()); uint64_t snap_features; m_image_ctx.get_features(m_image_ctx.snap_id, &snap_features); return ((snap_features & RBD_FEATURE_EXCLUSIVE_LOCK) != 0 && diff --git a/src/librbd/ImageWatcher.h b/src/librbd/ImageWatcher.h index 45a97ba939f69..19155ae9dd882 100644 --- a/src/librbd/ImageWatcher.h +++ b/src/librbd/ImageWatcher.h @@ -31,6 +31,7 @@ namespace librbd { ~ImageWatcher(); bool is_lock_supported() const; + bool is_lock_supported(const RWLock &snap_lock) const; bool is_lock_owner() const; int register_watch(); -- 2.39.5