From 4bcbdbfd0f69b00cbba53e4753459989b6117d3a Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Mon, 23 Feb 2015 18:49:34 -0800 Subject: [PATCH] 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 --- src/librbd/ImageWatcher.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index a1afa1eb8ef04..25fbeab9e7c2e 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); } -- 2.39.5