]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: do not invalidate oversized object map
authorJason Dillaman <dillaman@redhat.com>
Tue, 10 Mar 2015 05:11:38 +0000 (01:11 -0400)
committerJosh Durgin <jdurgin@redhat.com>
Tue, 10 Mar 2015 22:41:46 +0000 (15:41 -0700)
If the object map is too large for the current image, it implies
that a resize operation was interrupted.  It should only be
considered invalid if the object map is smaller than the image,
which shouldn't be possible.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/ObjectMap.cc

index 27d1db7a23d518ad5c18183045d7de9046a8577f..e13f62fc993b5e32c1a947ffae13d7af2e5af805 100644 (file)
@@ -166,7 +166,7 @@ void ObjectMap::refresh(uint64_t snap_id)
   std::string oid(object_map_name(m_image_ctx.id, snap_id));
   int r = cls_client::object_map_load(&m_image_ctx.md_ctx, oid,
                                       &m_object_map);
-  if (r < 0) { 
+  if (r < 0) {
     lderr(cct) << "error refreshing object map: " << cpp_strerror(r)
                << dendl;
     invalidate();
@@ -179,11 +179,14 @@ void ObjectMap::refresh(uint64_t snap_id)
 
   uint64_t num_objs = Striper::get_num_objects(
     m_image_ctx.layout, m_image_ctx.get_image_size(snap_id));
-  if (m_object_map.size() != num_objs) {
-    // resize op might have been interrupted
-    lderr(cct) << "incorrect object map size: " << m_object_map.size()
-               << " != " << num_objs << dendl;
+  if (m_object_map.size() < num_objs) {
+    lderr(cct) << "object map smaller than current object count: "
+               << m_object_map.size() << " != " << num_objs << dendl;
     invalidate();
+  } else if (m_object_map.size() > num_objs) {
+    // resize op might have been interrupted
+    ldout(cct, 1) << "object map larger than current object count: "
+                  << m_object_map.size() << " != " << num_objs << dendl;
   }
 }