]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rados: Fix bug in export of xattr which dropped first char of key on import
authorDavid Zafman <dzafman@redhat.com>
Wed, 15 Jul 2015 00:45:58 +0000 (17:45 -0700)
committerDavid Zafman <dzafman@redhat.com>
Wed, 15 Jul 2015 21:12:30 +0000 (14:12 -0700)
This was caused because the user xattrs exported in a pg includes a underscore
prepended to the xattr key.

Signed-off-by: David Zafman <dzafman@redhat.com>
src/tools/rados/PoolDump.cc

index 998bd54f4b2a8f7a4a3663fc198830efe591e5d2..69963ee264d788a920f068430b2e3fe6e36faf76 100644 (file)
@@ -94,13 +94,20 @@ int PoolDump::dump(IoCtx *io_ctx)
 
     // Compose TYPE_ATTRS chunk
     // ========================
+    std::map<std::string, bufferlist> raw_xattrs;
     std::map<std::string, bufferlist> xattrs;
-    r = io_ctx->getxattrs(oid, xattrs);
+    r = io_ctx->getxattrs(oid, raw_xattrs);
     if (r < 0) {
       cerr << "error getting xattr set " << oid << ": " << cpp_strerror(r)
            << std::endl;
       return r;
     }
+    // Prepend "_" to mimic how user keys are represented in a pg export
+    for (std::map<std::string, bufferlist>::iterator i = raw_xattrs.begin();
+         i != raw_xattrs.end(); ++i) {
+      std::pair< std::string, bufferlist> item(std::string("_") + std::string(i->first.c_str()), i->second);
+      xattrs.insert(item);
+    }
     r = write_section(TYPE_ATTRS, attr_section(xattrs), file_fd);
     if (r != 0) {
       return r;