From: Jason Dillaman Date: Fri, 17 Jul 2015 16:43:46 +0000 (-0400) Subject: librbd: new ImageWatcher::is_lock_supported method X-Git-Tag: v0.94.3~29^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ef453630200ab72373f08357ca6b5ac5c5bbb397;p=ceph.git 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 --- diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index 860f7090eb19..9962f48dfd7c 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 45a97ba939f6..19155ae9dd88 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();