]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-objectstore-tool: do not populate snapmapper with missing clones
authorSage Weil <sage@redhat.com>
Tue, 20 Jun 2017 18:25:28 +0000 (14:25 -0400)
committerSage Weil <sage@redhat.com>
Tue, 20 Jun 2017 18:25:28 +0000 (14:25 -0400)
Cache pools may have clones represented in SnapSet that are not stored
locally.  This is fine as long as ceph-objectstore-tool doesn't go and
add them when it shouldn't.

Fixes: http://tracker.ceph.com/issues/19943
Signed-off-by: Sage Weil <sage@redhat.com>
src/tools/ceph_objectstore_tool.cc

index 23e06ecf04e670228e969020cdd697f19b32b3e0..9fcbbdf3e145c0c92ff44525fe4e83f1f166bbfe 100644 (file)
@@ -861,14 +861,24 @@ int get_attrs(
          cout << "snapset " << snapset << std::endl;
          if (!snapset.is_legacy()) {
            for (auto& p : snapset.clone_snaps) {
-             hobject_t clone = hoid.hobj;
-             clone.snap = p.first;
+             ghobject_t clone = hoid;
+             clone.hobj.snap = p.first;
              set<snapid_t> snaps(p.second.begin(), p.second.end());
+             if (!store->exists(coll, clone)) {
+               // no clone, skip.  this is probably a cache pool.  this works
+               // because we use a separate transaction per object and clones
+               // come before head in the archive.
+               if (debug)
+                 cerr << "\tskipping missing " << clone << " (snaps "
+                      << snaps << ")" << std::endl;
+               continue;
+             }
              if (debug)
-               cerr << "\tsetting " << clone << " snaps " << snaps << std::endl;
+               cerr << "\tsetting " << clone.hobj << " snaps " << snaps
+                    << std::endl;
              OSDriver::OSTransaction _t(driver.get_transaction(t));
              assert(!snaps.empty());
-             snap_mapper.add_oid(clone, snaps, &_t);
+             snap_mapper.add_oid(clone.hobj, snaps, &_t);
            }
          }
        } else {