From: Josh Durgin Date: Tue, 24 Feb 2015 02:49:34 +0000 (-0800) Subject: librbd: fix ImageWatcher::is_lock_supported() locking X-Git-Tag: v0.93~6^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4bcbdbfd0f69b00cbba53e4753459989b6117d3a;p=ceph.git librbd: fix ImageWatcher::is_lock_supported() locking Take snap_lock while reading ImageCtx->snap_id, and look up the features by snap_id as well. Signed-off-by: Josh Durgin --- diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index a1afa1eb8ef0..25fbeab9e7c2 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -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); }