}
return 0;
}
+
+int DBObjectMap::list_object_headers(vector<_Header> *out)
+{
+ int error = 0;
+ KeyValueDB::Iterator iter = db->get_iterator(HOBJECT_TO_SEQ);
+ for (iter->seek_to_first(); iter->valid(); iter->next()) {
+ bufferlist bl = iter->value();
+ bufferlist::iterator bliter = bl.begin();
+ _Header header;
+ header.decode(bliter);
+ out->push_back(header);
+ while (header.parent) {
+ set<string> to_get;
+ map<string, bufferlist> got;
+ to_get.insert(HEADER_KEY);
+ db->get(sys_parent_prefix(header), to_get, &got);
+ if (got.empty()) {
+ dout(0) << "Missing: seq " << header.parent << dendl;
+ error = -ENOENT;
+ break;
+ } else {
+ bl = got.begin()->second;
+ bufferlist::iterator bliter = bl.begin();
+ header.decode(bliter);
+ out->push_back(header);
+ }
+ }
+ }
+ return error;
+}
+
+ostream& operator<<(ostream& out, const DBObjectMap::_Header& h)
+{
+ out << "seq=" << h.seq << " parent=" << h.parent
+ << " num_children=" << h.num_children
+ << " ghobject=" << h.oid;
+ return out;
+}
int list_objects(vector<ghobject_t> *objs ///< [out] objects
);
+ struct _Header;
+ // Util, get all object headers, there must be no other concurrent access
+ int list_object_headers(vector<_Header> *out ///< [out] headers
+ );
+
ObjectMapIterator get_iterator(const ghobject_t &oid);
static const string USER_PREFIX;
WRITE_CLASS_ENCODER(DBObjectMap::_Header)
WRITE_CLASS_ENCODER(DBObjectMap::State)
+ostream& operator<<(ostream& out, const DBObjectMap::_Header& h);
+
#endif
("paranoid", "use paranoid checking")
("oid", po::value<string>(&oid), "Restrict to this object id when dumping objects")
("command", po::value<string>(&cmd),
- "command arg is one of [dump-raw-keys, dump-raw-key-vals, dump-objects, dump-objects-with-keys, check], mandatory")
+ "command arg is one of [dump-raw-keys, dump-raw-key-vals, dump-objects, dump-objects-with-keys, check, dump-headers], mandatory")
;
po::positional_options_description p;
p.add("command", 1);
goto done;
}
std::cout << "check succeeded" << std::endl;
+ } else if (cmd == "dump-headers") {
+ vector<DBObjectMap::_Header> headers;
+ r = omap.list_object_headers(&headers);
+ if (r < 0) {
+ std::cerr << "list_object_headers got: " << cpp_strerror(r) << std::endl;
+ r = 1;
+ goto done;
+ }
+ for (auto i : headers)
+ std::cout << i << std::endl;
} else {
std::cerr << "Did not recognize command " << cmd << std::endl;
goto done;