Skip to content

Commit

Permalink
librbd: don't attempt to invalidate an object map in R/O mode
Browse files Browse the repository at this point in the history
The ImageWatcher is not initialized when in R/O mode, which
resulted in a NULL pointer dereference.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 64d740f)
  • Loading branch information
Jason Dillaman committed Jul 19, 2015
1 parent 0aea70f commit 4a77be0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/librbd/ObjectMap.cc
Expand Up @@ -274,6 +274,7 @@ void ObjectMap::aio_resize(uint64_t new_size, uint8_t default_object_state,
Context *on_finish) {
assert(m_image_ctx.test_features(RBD_FEATURE_OBJECT_MAP));
assert(m_image_ctx.owner_lock.is_locked());
assert(m_image_ctx.image_watcher != NULL);
assert(m_image_ctx.image_watcher->is_lock_owner());

ResizeRequest *req = new ResizeRequest(
Expand All @@ -296,7 +297,9 @@ bool ObjectMap::aio_update(uint64_t start_object_no, uint64_t end_object_no,
{
assert(m_image_ctx.test_features(RBD_FEATURE_OBJECT_MAP));
assert(m_image_ctx.owner_lock.is_locked());
assert(m_image_ctx.image_watcher != NULL);
assert(m_image_ctx.image_watcher->is_lock_owner());
assert(start_object_no < end_object_no);

RWLock::WLocker l(m_image_ctx.object_map_lock);
assert(start_object_no < end_object_no);
Expand Down Expand Up @@ -339,8 +342,9 @@ void ObjectMap::invalidate() {
true);

// do not update on-disk flags if not image owner
if (m_image_ctx.image_watcher->is_lock_supported(m_image_ctx.snap_lock) &&
!m_image_ctx.image_watcher->is_lock_owner()) {
if (m_image_ctx.image_watcher == NULL ||
(m_image_ctx.image_watcher->is_lock_supported(m_image_ctx.snap_lock) &&
!m_image_ctx.image_watcher->is_lock_owner())) {
return;
}

Expand Down

0 comments on commit 4a77be0

Please sign in to comment.