]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: fix ImageWatcher::is_lock_supported() locking
authorJosh Durgin <jdurgin@redhat.com>
Tue, 24 Feb 2015 02:49:34 +0000 (18:49 -0800)
committerJosh Durgin <jdurgin@redhat.com>
Wed, 25 Feb 2015 23:41:54 +0000 (15:41 -0800)
Take snap_lock while reading ImageCtx->snap_id, and
look up the features by snap_id as well.

Signed-off-by: Josh Durgin <jdurgin@redhat.com>
src/librbd/ImageWatcher.cc

index a1afa1eb8ef048ae6217cee470305fe03a1ab5fe..25fbeab9e7c2ebe04dfa6e30035f43bcbe6f55fd 100644 (file)
@@ -67,7 +67,10 @@ ImageWatcher::~ImageWatcher()
 
 bool ImageWatcher::is_lock_supported() const {
   assert(m_image_ctx.owner_lock.is_locked());
-  return ((m_image_ctx.features & RBD_FEATURE_EXCLUSIVE_LOCK) != 0 &&
+  RWLock::RLocker l(m_image_ctx.snap_lock);
+  uint64_t snap_features;
+  m_image_ctx.get_features(m_image_ctx.snap_id, &snap_features);
+  return ((snap_features & RBD_FEATURE_EXCLUSIVE_LOCK) != 0 &&
          !m_image_ctx.read_only && m_image_ctx.snap_id == CEPH_NOSNAP);
 }