]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
FileStore,DBObjectMap: remove ObjectMap link method
authorSamuel Just <sam.just@inktank.com>
Fri, 25 May 2012 22:06:55 +0000 (15:06 -0700)
committerSamuel Just <sam.just@inktank.com>
Tue, 5 Jun 2012 23:09:49 +0000 (16:09 -0700)
hobject_t's are now globally unique in filestore.  Essentially, there is
a 1-to-1 mapping from inodes to hobject_t's.  The entry in the
DBObjectMap is now tied to the inode/hobject_t.  Thus, links needn't be
tracked.  Rather, we delete the ObjectMap entry when nlink == 0.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/os/DBObjectMap.cc
src/os/DBObjectMap.h
src/os/FileStore.cc
src/os/ObjectMap.h
src/test/ObjectMap/test_object_map.cc

index ecd9d0133e6f3f68edd39566c4d36207abe5b3ba..b116e6bcd9f0a8c00b1ed56be339d52feaa6c82f 100644 (file)
@@ -939,33 +939,6 @@ int DBObjectMap::clone(const hobject_t &hoid,
   return db->submit_transaction(t);
 }
 
-int DBObjectMap::link(const hobject_t &hoid,
-                     Index index,
-                     const hobject_t &target,
-                     Index target_index)
-{
-  assert(index->coll() != target_index->coll() ||
-        hoid != target);
-  KeyValueDB::Transaction t = db->get_transaction();
-  {
-    Header destination = lookup_map_header(target_index->coll(), target);
-    if (destination) {
-      remove_map_header(target_index->coll(), target, destination, t);
-      destination->num_children--;
-      _clear(destination, t);
-    }
-  }
-  Header header = lookup_create_map_header(index->coll(), hoid, t);
-
-  assert(header->num_children > 0);
-  header->num_children++;
-  set_header(header, t);
-  _Header ldestination;
-  ldestination.parent = header->seq;
-  set_map_header(target_index->coll(), target, ldestination, t);
-  return db->submit_transaction(t);
-}
-
 int DBObjectMap::upgrade()
 {
   assert(0);
index 6e48bb0e38471e3f0429d1bab930e66b21515db9..018785afdc82b5c3251a7052fded40f9f8368447 100644 (file)
@@ -168,13 +168,6 @@ public:
     Index target_index
     );
 
-  int link(
-    const hobject_t &hoid,
-    Index index,
-    const hobject_t &target,
-    Index target_index
-    );
-
   /// Read initial state from backing store
   int init(bool upgrade = false);
 
index 91978e4af90e1bd86cec69091506ba233c840dbb..17ae06d3b4c67588e2cdd57b4142deb9702d2a78 100644 (file)
@@ -360,11 +360,6 @@ int FileStore::lfn_link(coll_t c, coll_t cid, const hobject_t& o)
   if (r < 0)
     return -errno;
 
-  r = object_map->link(o, path_old->get_index(),
-                      o, path_new->get_index());
-  if (r < 0 && r != -ENOENT)
-    return r;
-
   r = index_new->created(o, path_new->path());
   if (r < 0)
     return r;
@@ -383,9 +378,17 @@ int FileStore::lfn_unlink(coll_t cid, const hobject_t& o)
     r = index->lookup(o, &path, &exist);
     if (r < 0)
       return r;
-    object_map->clear(o, path->get_index());
-    if (r < 0 && r != -ENOENT)
-      return r;
+
+    struct stat st;
+    r = ::stat(path->path(), &st);
+    if (r < 0) {
+      return -errno;
+    }
+    if (st.st_nlink == 1) {
+      r = object_map->clear(o, path->get_index());
+      if (r < 0 && r != -ENOENT)
+       return r;
+    }
   }
   return index->unlink(o);
 }
index 0f3088e641ed5ec06d8f1b3ff97ee18bb6436a2e..ea6c78ec9ea61d58cf27b1c3a96381ce73def673 100644 (file)
@@ -131,14 +131,6 @@ public:
     Index target_index                 ///< [in] path to target
     ) { return 0; }
 
-  /// Efficiently tie <target, target_path> to same key space as <hoid, path>
-  virtual int link(
-    const hobject_t &hoid,             ///< [in] object containing map
-    Index index,                       ///< [in] Path to hoid
-    const hobject_t &target,           ///< [in] target of link
-    Index target_index                 ///< [in] path to target
-    ) { return 0; }
-
   /// Ensure all previous writes are durable
   virtual int sync() { return 0; }
 
index a00a742e93694aca2cfd14b5c4ad0ab95fec3451..c8ac76942c407c8d4da66e34722cec3fb4339489 100644 (file)
@@ -656,18 +656,16 @@ TEST_F(ObjectMapTest, CloneOneObject) {
 TEST_F(ObjectMapTest, OddEvenClone) {
   hobject_t hoid(sobject_t("foo", CEPH_NOSNAP));
   hobject_t hoid2(sobject_t("foo2", CEPH_NOSNAP));
-  hobject_t hoid_link(sobject_t("foo_link", CEPH_NOSNAP));
   Index path = Index(new HashIndex(coll_t("foo_coll"),
                                   string("/bar").c_str(),
                                   2,
                                   2,
-                                  CollectionIndex::HASH_INDEX_TAG_2));
+                                  CollectionIndex::HOBJECT_WITH_POOL));
 
   for (unsigned i = 0; i < 1000; ++i) {
     set_key(hoid, path, "foo" + num_str(i), "bar" + num_str(i));
   }
 
-  db->link(hoid, path, hoid_link, path);
   db->clone(hoid, path, hoid2, path);
 
   int r = 0;
@@ -680,9 +678,6 @@ TEST_F(ObjectMapTest, OddEvenClone) {
     ASSERT_EQ(1, r);
     ASSERT_EQ("bar" + num_str(i), result);
 
-    r = get_key(hoid2, path, "foo" + num_str(i), &result);
-    ASSERT_EQ(1, r);
-    ASSERT_EQ("bar" + num_str(i), result);
     if (i % 2) {
       remove_key(hoid, path, "foo" + num_str(i));
     } else {
@@ -693,26 +688,19 @@ TEST_F(ObjectMapTest, OddEvenClone) {
   for (unsigned i = 0; i < 1000; ++i) {
     string result;
     string result2;
-    string result3;
     r = get_key(hoid, path, "foo" + num_str(i), &result);
-    int r3 = get_key(hoid_link, path, "foo" + num_str(i), &result3);
     int r2 = get_key(hoid2, path, "foo" + num_str(i), &result2);
     if (i % 2) {
       ASSERT_EQ(0, r);
-      ASSERT_EQ(0, r3);
       ASSERT_EQ(1, r2);
       ASSERT_EQ("bar" + num_str(i), result2);
     } else {
       ASSERT_EQ(0, r2);
       ASSERT_EQ(1, r);
-      ASSERT_EQ(1, r3);
       ASSERT_EQ("bar" + num_str(i), result);
-      ASSERT_EQ("bar" + num_str(i), result3);
     }
   }
 
-  db->clear(hoid_link, path);
-
   {
     ObjectMap::ObjectMapIterator iter = db->get_iterator(hoid, path);
     iter->seek_to_first();