From b90b483084b650d4c5c0cdbbe94eb38d791248b3 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 19 Jul 2014 12:04:19 -0700 Subject: [PATCH] remove collection_rename No more users! Complicated semantics! Signed-off-by: Sage Weil --- src/os/FileStore.cc | 54 +----------------------------------- src/os/FileStore.h | 2 -- src/os/KeyValueStore.cc | 57 +------------------------------------- src/os/KeyValueStore.h | 2 -- src/os/MemStore.cc | 15 +--------- src/os/MemStore.h | 1 - src/os/ObjectStore.h | 8 ------ src/os/Transaction.cc | 1 - src/tracing/objectstore.tp | 16 ----------- 9 files changed, 3 insertions(+), 153 deletions(-) diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index d1b4d8c3f5413..4833c3aeb4d0d 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -2560,9 +2560,7 @@ unsigned FileStore::_do_transaction( { coll_t cid(i.decode_cid()); coll_t ncid(i.decode_cid()); - tracepoint(objectstore, coll_rename_enter, osr_name); - r = _collection_rename(cid, ncid, spos); - tracepoint(objectstore, coll_rename_exit, r); + r = -EOPNOTSUPP; } break; @@ -4322,56 +4320,6 @@ int FileStore::_collection_remove_recursive(const coll_t &cid, return _destroy_collection(cid); } -int FileStore::_collection_rename(const coll_t &cid, const coll_t &ncid, - const SequencerPosition& spos) -{ - char new_coll[PATH_MAX], old_coll[PATH_MAX]; - get_cdir(cid, old_coll, sizeof(old_coll)); - get_cdir(ncid, new_coll, sizeof(new_coll)); - - if (_check_replay_guard(cid, spos) < 0) { - return 0; - } - - if (_check_replay_guard(ncid, spos) < 0) { - return _collection_remove_recursive(cid, spos); - } - - if (!collection_exists(cid)) { - if (replaying) { - // already happened - return 0; - } else { - return -ENOENT; - } - } - _set_global_replay_guard(cid, spos); - - int ret = 0; - if (::rename(old_coll, new_coll)) { - if (replaying && !backend->can_checkpoint() && - (errno == EEXIST || errno == ENOTEMPTY)) - ret = _collection_remove_recursive(cid, spos); - else - ret = -errno; - - dout(10) << "collection_rename '" << cid << "' to '" << ncid << "'" - << ": ret = " << ret << dendl; - return ret; - } - - if (ret >= 0) { - int fd = ::open(new_coll, O_RDONLY); - assert(fd >= 0); - _set_replay_guard(fd, spos); - VOID_TEMP_FAILURE_RETRY(::close(fd)); - } - - dout(10) << "collection_rename '" << cid << "' to '" << ncid << "'" - << ": ret = " << ret << dendl; - return ret; -} - // -------------------------- // collections diff --git a/src/os/FileStore.h b/src/os/FileStore.h index 139c83965c331..ab9f47f60f49c 100644 --- a/src/os/FileStore.h +++ b/src/os/FileStore.h @@ -595,8 +595,6 @@ public: int _collection_setattrs(coll_t cid, map &aset); int _collection_remove_recursive(const coll_t &cid, const SequencerPosition &spos); - int _collection_rename(const coll_t &cid, const coll_t &ncid, - const SequencerPosition& spos); // collections int list_collections(vector& ls); diff --git a/src/os/KeyValueStore.cc b/src/os/KeyValueStore.cc index 71b61d3efc71b..7e1bf046d4b58 100644 --- a/src/os/KeyValueStore.cc +++ b/src/os/KeyValueStore.cc @@ -1433,7 +1433,7 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction, { coll_t cid(i.decode_cid()); coll_t ncid(i.decode_cid()); - r = _collection_rename(cid, ncid, t); + r = -EOPNOTSUPP; } break; @@ -2562,61 +2562,6 @@ int KeyValueStore::_collection_remove_recursive(const coll_t &cid, return 0; } -int KeyValueStore::_collection_rename(const coll_t &cid, const coll_t &ncid, - BufferTransaction &t) -{ - dout(10) << __func__ << " origin cid " << cid << " new cid " << ncid - << dendl; - - StripObjectMap::StripObjectHeaderRef header; - - int r = t.lookup_cached_header(get_coll_for_coll(), - make_ghobject_for_coll(ncid), - &header, false); - if (r == 0) { - dout(2) << __func__ << ": " << ncid << " DNE" << dendl; - return -EEXIST; - } - - r = t.lookup_cached_header(get_coll_for_coll(), make_ghobject_for_coll(cid), - &header, false); - if (r < 0) { - dout(2) << __func__ << ": " << cid << " DNE" << dendl; - return 0; - } - - vector objects; - ghobject_t next, current; - int move_size = 0; - while (1) { - collection_list_partial(cid, current, get_ideal_list_min(), - get_ideal_list_max(), 0, &objects, &next); - - dout(20) << __func__ << cid << "objects size: " << objects.size() - << dendl; - - if (objects.empty()) - break; - - for (vector::iterator i = objects.begin(); - i != objects.end(); ++i) { - if (_collection_move_rename(cid, *i, ncid, *i, t) < 0) { - return -1; - } - move_size++; - } - - objects.clear(); - current = next; - } - - t.rename_buffer(header, get_coll_for_coll(), make_ghobject_for_coll(ncid)); - - dout(10) << __func__ << " origin cid " << cid << " new cid " << ncid - << dendl; - return 0; -} - int KeyValueStore::list_collections(vector& ls) { dout(10) << __func__ << " " << dendl; diff --git a/src/os/KeyValueStore.h b/src/os/KeyValueStore.h index 86cd7aec69d24..0f13df649324f 100644 --- a/src/os/KeyValueStore.h +++ b/src/os/KeyValueStore.h @@ -610,8 +610,6 @@ class KeyValueStore : public ObjectStore, BufferTransaction &t); int _collection_remove_recursive(const coll_t &cid, BufferTransaction &t); - int _collection_rename(const coll_t &cid, const coll_t &ncid, - BufferTransaction &t); int list_collections(vector& ls); bool collection_exists(coll_t c); bool collection_empty(coll_t c); diff --git a/src/os/MemStore.cc b/src/os/MemStore.cc index f3c4c3021059d..b6ca64b5f3d79 100644 --- a/src/os/MemStore.cc +++ b/src/os/MemStore.cc @@ -911,7 +911,7 @@ void MemStore::_do_transaction(Transaction& t) { coll_t cid(i.decode_cid()); coll_t ncid(i.decode_cid()); - r = _collection_rename(cid, ncid); + r = -EOPNOTSUPP; } break; @@ -1485,19 +1485,6 @@ int MemStore::_collection_rmattr(coll_t cid, const char *name) return 0; } -int MemStore::_collection_rename(const coll_t &cid, const coll_t &ncid) -{ - dout(10) << __func__ << " " << cid << " -> " << ncid << dendl; - RWLock::WLocker l(coll_lock); - if (coll_map.count(cid) == 0) - return -ENOENT; - if (coll_map.count(ncid)) - return -EEXIST; - coll_map[ncid] = coll_map[cid]; - coll_map.erase(cid); - return 0; -} - int MemStore::_split_collection(coll_t cid, uint32_t bits, uint32_t match, coll_t dest) { diff --git a/src/os/MemStore.h b/src/os/MemStore.h index 3feeb24e1c18d..078959781eed5 100644 --- a/src/os/MemStore.h +++ b/src/os/MemStore.h @@ -218,7 +218,6 @@ private: size_t size); int _collection_setattrs(coll_t cid, map &aset); int _collection_rmattr(coll_t cid, const char *name); - int _collection_rename(const coll_t &cid, const coll_t &ncid); int _split_collection(coll_t cid, uint32_t bits, uint32_t rem, coll_t dest); int _save(); diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 255e5cb5c9547..d11fcdcadbff4 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -941,14 +941,6 @@ public: ::encode(aset, tbl); ops++; } - /// Change the name of a collection - void collection_rename(coll_t cid, coll_t ncid) { - __u32 op = OP_COLL_RENAME; - ::encode(op, tbl); - ::encode(cid, tbl); - ::encode(ncid, tbl); - ops++; - } /// Remove omap from oid void omap_clear( diff --git a/src/os/Transaction.cc b/src/os/Transaction.cc index b7360de761440..674eef43cd0ee 100644 --- a/src/os/Transaction.cc +++ b/src/os/Transaction.cc @@ -485,6 +485,5 @@ void ObjectStore::Transaction::generate_test_instances(listcollection_setattr(c, "this", bl); t->collection_rmattr(c, "foo"); t->collection_setattrs(c, m); - t->collection_rename(c, c2); o.push_back(t); } diff --git a/src/tracing/objectstore.tp b/src/tracing/objectstore.tp index 9c3c45f9f13f7..506a03b9c15ee 100644 --- a/src/tracing/objectstore.tp +++ b/src/tracing/objectstore.tp @@ -447,22 +447,6 @@ TRACEPOINT_EVENT(objectstore, omap_clear_exit, ) ) -TRACEPOINT_EVENT(objectstore, coll_rename_enter, - TP_ARGS( - const char *, osr_name), - TP_FIELDS( - ctf_string(osr_name, osr_name) - ) -) - -TRACEPOINT_EVENT(objectstore, coll_rename_exit, - TP_ARGS( - int, retval), - TP_FIELDS( - ctf_integer(int, retval, retval) - ) -) - TRACEPOINT_EVENT(objectstore, startsync_enter, TP_ARGS( const char *, osr_name), -- 2.39.5