From: David Zafman Date: Wed, 10 Dec 2014 02:09:04 +0000 (-0800) Subject: ceph_objectstore_tool: Fix import-rados skipping of snapshots X-Git-Tag: v0.80.10~69^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bbed3a728471292de625d922abeae8b39d290045;p=ceph.git ceph_objectstore_tool: Fix import-rados skipping of snapshots Signed-off-by: David Zafman (cherry picked from commit fe936026ed87c9f95f3b7ad235b24c22e8de5f55) --- diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index 74c0fcb242b1..0a3ab3fd9504 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -1123,6 +1123,40 @@ int get_omap(ObjectStore *store, coll_t coll, ghobject_t hoid, return 0; } +int skip_object(bufferlist &bl) +{ + bufferlist::iterator ebliter = bl.begin(); + bufferlist ebl; + bool done = false; + while(!done) { + sectiontype_t type; + int ret = read_section(file_fd, &type, &ebl); + if (ret) + return ret; + + ebliter = ebl.begin(); + if (type >= END_OF_TYPES) { + cout << "Skipping unknown object section type" << std::endl; + continue; + } + switch(type) { + case TYPE_DATA: + case TYPE_ATTRS: + case TYPE_OMAP_HDR: + case TYPE_OMAP: + if (debug) + cerr << "Skip type " << (int)type << std::endl; + break; + case TYPE_OBJECT_END: + done = true; + break; + default: + return EFAULT; + } + } + return 0; +} + int get_object_rados(librados::IoCtx &ioctx, bufferlist &bl) { bufferlist::iterator ebliter = bl.begin(); @@ -1138,6 +1172,8 @@ int get_object_rados(librados::IoCtx &ioctx, bufferlist &bl) if (!ob.hoid.hobj.is_head()) { cout << "Skipping non-head for " << ob.hoid << std::endl; + skip_object(bl); + return 0; } ioctx.set_namespace(ob.hoid.hobj.get_namespace());