]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: don't attempt to invalidate an object map in R/O mode
authorJason Dillaman <dillaman@redhat.com>
Sun, 5 Jul 2015 15:09:09 +0000 (11:09 -0400)
committerJason Dillaman <dillaman@redhat.com>
Sun, 19 Jul 2015 17:44:16 +0000 (13:44 -0400)
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 64d740f8fa10ba872e324ec2580a4d8c3f99a9ce)

src/librbd/ObjectMap.cc

index 67ff1a20e30cfd0ee883e58baf4db7c0cc6c17e3..c2ca798b584ff9c45da0a55c574e60bb1f62e74d 100644 (file)
@@ -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(
@@ -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);
@@ -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;
   }