]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: new ImageWatcher::is_lock_supported method
authorJason Dillaman <dillaman@redhat.com>
Fri, 17 Jul 2015 16:43:46 +0000 (12:43 -0400)
committerJason Dillaman <dillaman@redhat.com>
Sun, 19 Jul 2015 17:44:16 +0000 (13:44 -0400)
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 <dillaman@redhat.com>
src/librbd/ImageWatcher.cc
src/librbd/ImageWatcher.h

index 860f7090eb19ac56f7ae2b0f67e5cd068f6bdf92..9962f48dfd7c373648fbc502d92d817da5b04e62 100644 (file)
@@ -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 &&
index 45a97ba939f691f68b8795267f72594168c21777..19155ae9dd88220bd13ebdaf3363c3b2b3d27a7b 100644 (file)
@@ -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();