From: Haomai Wang Date: Thu, 20 Feb 2014 04:20:21 +0000 (+0800) Subject: Use rename operation to make colection_move atomic X-Git-Tag: v0.78~130^2~16 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=024a12042ee61986d615a36748de25e866bd951f;p=ceph.git Use rename operation to make colection_move atomic Signed-off-by: Haomai Wang --- diff --git a/src/os/GenericObjectMap.cc b/src/os/GenericObjectMap.cc index 3be9b7698375..94c6b3bb8c00 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 a12606c875a2..89c8263e999c 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++; } }