From 024a12042ee61986d615a36748de25e866bd951f Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Thu, 20 Feb 2014 12:20:21 +0800 Subject: [PATCH] Use rename operation to make colection_move atomic Signed-off-by: Haomai Wang --- src/os/GenericObjectMap.cc | 1 + src/os/KeyValueStore.cc | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/os/GenericObjectMap.cc b/src/os/GenericObjectMap.cc index 3be9b76983755..94c6b3bb8c003 100644 --- a/src/os/GenericObjectMap.cc +++ b/src/os/GenericObjectMap.cc @@ -1043,6 +1043,7 @@ void GenericObjectMap::set_header(const coll_t &cid, const ghobject_t &oid, int GenericObjectMap::list_objects(const coll_t &cid, ghobject_t start, int max, vector *out, ghobject_t *next) { + // FIXME Mutex::Locker l(header_lock); if (start.is_max()) diff --git a/src/os/KeyValueStore.cc b/src/os/KeyValueStore.cc index a12606c875a2d..89c8263e999cd 100644 --- a/src/os/KeyValueStore.cc +++ b/src/os/KeyValueStore.cc @@ -1383,9 +1383,7 @@ unsigned KeyValueStore::_do_transaction(Transaction& transaction, coll_t ocid = i.get_cid(); coll_t ncid = i.get_cid(); ghobject_t oid = i.get_oid(); - r = _collection_add(ocid, ncid, oid, t); - if (r == 0) - r = _remove(ocid, oid, t); + r = _collection_move_rename(ocid, oid, ncid, oid, t); } break; @@ -2977,10 +2975,9 @@ int KeyValueStore::_split_collection(coll_t cid, uint32_t bits, uint32_t rem, for (vector::iterator i = objects.begin(); i != objects.end(); ++i) { if (i->match(bits, rem)) { - if (_collection_add(dest, cid, *i, t) < 0) { + if (_collection_move_rename(cid, *i, dest, *i, t) < 0) { return -1; } - _remove(cid, *i, t); move_size++; } } -- 2.39.5