]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
fix nspace assignment in LFNIndex::lfn_parse_object_name 176/head
authorLoic Dachary <loic@dachary.org>
Sat, 30 Mar 2013 17:15:12 +0000 (18:15 +0100)
committerLoic Dachary <loic@dachary.org>
Tue, 2 Apr 2013 11:07:24 +0000 (13:07 +0200)
The unused ns variable is assigned to the nspace data member of the
parsed hobject_t. It would be nicer to use a constructor accepting
the namespace in argument.

http://tracker.ceph.com/issues/4597 refs #4597

Signed-off-by: Loic Dachary <loic@dachary.org>
src/os/LFNIndex.cc
src/test/os/TestLFNIndex.cc

index 62b8f7085e16bc56c168cdac12713e80c6c4376b..12aabfd8fd1ad419acec41b0e97471a4c5ebdc70 100644 (file)
@@ -1073,6 +1073,7 @@ bool LFNIndex::lfn_parse_object_name(const string &long_name, hobject_t *out) {
     pool = strtoull(pstring.c_str(), NULL, 16);
 
   (*out) = hobject_t(name, key, snap, hash, (int64_t)pool);
+  out->nspace = ns;
   return true;
 }
 
index 3666de0ede153baf7fa86d954b75d6c8cc6eb3e7..eeacf1ab8fb644e2a34dd1b2d53f7a265e04c8a8 100644 (file)
@@ -131,6 +131,35 @@ TEST_F(TestHASH_INDEX_TAG_2, generate_and_parse_name) {
                          "\\dA_KEY_head_ABABABAB");
 }
 
+class TestHOBJECT_WITH_POOL : public TestWrapLFNIndex, public ::testing::Test {
+public:
+  TestHOBJECT_WITH_POOL() : TestWrapLFNIndex(coll_t("ABC"), "PATH", CollectionIndex::HOBJECT_WITH_POOL) {
+  }
+};
+
+TEST_F(TestHOBJECT_WITH_POOL, generate_and_parse_name) {
+  const vector<string> path;
+  std::string mangled_name;
+  const std::string key("KEY");
+  uint64_t hash = 0xABABABAB;
+  uint64_t pool = 0xCDCDCDCD;
+
+  {
+    std::string name(".XA/B_\\C.D");
+    name[1] = '\0';
+    hobject_t hoid(object_t(name), key, CEPH_NOSNAP, hash, pool);
+    hoid.nspace = "NSPACE";
+
+    test_generate_and_parse(hoid, "\\.\\nA\\sB\\u\\\\C.D_KEY_head_ABABABAB_NSPACE_cdcdcdcd");
+  }
+  {
+    hobject_t hoid(object_t("DIR_A"), key, CEPH_NOSNAP, hash, pool);
+    hoid.nspace = "NSPACE";
+
+    test_generate_and_parse(hoid, "\\dA_KEY_head_ABABABAB_NSPACE_cdcdcdcd");
+  }
+}
+
 class TestLFNIndex : public TestWrapLFNIndex, public ::testing::Test {
 public:
   TestLFNIndex() : TestWrapLFNIndex(coll_t("ABC"), "PATH", CollectionIndex::HASH_INDEX_TAG) {