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 <jdurgin@redhat.com>
This commit is contained in:
Josh Durgin 2015-02-23 18:49:34 -08:00
parent a94ceb6088
commit 4bcbdbfd0f

View 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);
}