summaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
authorSamuel Just <sam.just@inktank.com>2012-05-25 15:06:55 -0700
committerSamuel Just <sam.just@inktank.com>2012-06-05 16:09:49 -0700
commit761140a0fa5408668f72740fb240e0f9d2a3c5a6 (patch)
tree000427e27e5e3d30c554edace0fac865a64f09da /src/os
parent9ceed879c86e28888819d8f114988f5031fe43f2 (diff)
downloadceph-761140a0fa5408668f72740fb240e0f9d2a3c5a6.tar.gz
FileStore,DBObjectMap: remove ObjectMap link method
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>
Diffstat (limited to 'src/os')
-rw-r--r--src/os/DBObjectMap.cc27
-rw-r--r--src/os/DBObjectMap.h7
-rw-r--r--src/os/FileStore.cc19
-rw-r--r--src/os/ObjectMap.h8
4 files changed, 11 insertions, 50 deletions
diff --git a/src/os/DBObjectMap.cc b/src/os/DBObjectMap.cc
index ecd9d0133e6..b116e6bcd9f 100644
--- a/src/os/DBObjectMap.cc
+++ b/src/os/DBObjectMap.cc
@@ -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);
diff --git a/src/os/DBObjectMap.h b/src/os/DBObjectMap.h
index 6e48bb0e384..018785afdc8 100644
--- a/src/os/DBObjectMap.h
+++ b/src/os/DBObjectMap.h
@@ -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);
diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc
index 91978e4af90..17ae06d3b4c 100644
--- a/src/os/FileStore.cc
+++ b/src/os/FileStore.cc
@@ -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);
}
diff --git a/src/os/ObjectMap.h b/src/os/ObjectMap.h
index 0f3088e641e..ea6c78ec9ea 100644
--- a/src/os/ObjectMap.h
+++ b/src/os/ObjectMap.h
@@ -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; }