From: Yunchuan Wen Date: Tue, 20 Dec 2016 03:44:32 +0000 (+0800) Subject: filestore: avoid unnecessary copy with coll_t X-Git-Tag: v12.0.1~96^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a681c03cb44392e012bd2f106dfc6745ef6fb1f5;p=ceph.git filestore: avoid unnecessary copy with coll_t Signed-off-by: Yunchuan Wen --- diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index c2798a6f9a3..7f4c89c3bff 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -2530,9 +2530,10 @@ void FileStore::_do_transaction( break; case Transaction::OP_TOUCH: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); tracepoint(objectstore, touch_enter, osr_name); if (_check_replay_guard(cid, oid, spos) > 0) r = _touch(cid, oid); @@ -2542,9 +2543,10 @@ void FileStore::_do_transaction( case Transaction::OP_WRITE: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); uint64_t off = op->off; uint64_t len = op->len; uint32_t fadvise_flags = i.get_fadvise_flags(); @@ -2559,9 +2561,10 @@ void FileStore::_do_transaction( case Transaction::OP_ZERO: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); uint64_t off = op->off; uint64_t len = op->len; tracepoint(objectstore, zero_enter, osr_name, off, len); @@ -2579,9 +2582,10 @@ void FileStore::_do_transaction( case Transaction::OP_TRUNCATE: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); uint64_t off = op->off; tracepoint(objectstore, truncate_enter, osr_name, off); if (_check_replay_guard(cid, oid, spos) > 0) @@ -2592,9 +2596,10 @@ void FileStore::_do_transaction( case Transaction::OP_REMOVE: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); tracepoint(objectstore, remove_enter, osr_name); if (_check_replay_guard(cid, oid, spos) > 0) r = _remove(cid, oid, spos); @@ -2604,9 +2609,10 @@ void FileStore::_do_transaction( case Transaction::OP_SETATTR: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); string name = i.decode_string(); bufferlist bl; i.decode_bl(bl); @@ -2625,9 +2631,10 @@ void FileStore::_do_transaction( case Transaction::OP_SETATTRS: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); map aset; i.decode_attrset(aset); tracepoint(objectstore, setattrs_enter, osr_name); @@ -2641,9 +2648,10 @@ void FileStore::_do_transaction( case Transaction::OP_RMATTR: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); string name = i.decode_string(); tracepoint(objectstore, rmattr_enter, osr_name); if (_check_replay_guard(cid, oid, spos) > 0) @@ -2654,9 +2662,10 @@ void FileStore::_do_transaction( case Transaction::OP_RMATTRS: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); tracepoint(objectstore, rmattrs_enter, osr_name); if (_check_replay_guard(cid, oid, spos) > 0) r = _rmattrs(cid, oid, spos); @@ -2666,9 +2675,10 @@ void FileStore::_do_transaction( case Transaction::OP_CLONE: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); const ghobject_t &noid = i.get_oid(op->dest_oid); tracepoint(objectstore, clone_enter, osr_name); r = _clone(cid, oid, noid, spos); @@ -2678,12 +2688,13 @@ void FileStore::_do_transaction( case Transaction::OP_CLONERANGE: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - coll_t ncid = cid; const ghobject_t &noid = i.get_oid(op->dest_oid); - _kludge_temp_object_collection(cid, oid); - _kludge_temp_object_collection(ncid, noid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); + const coll_t &ncid = !_need_temp_object_collection(_cid, noid) ? + _cid : _cid.get_temp(); uint64_t off = op->off; uint64_t len = op->len; tracepoint(objectstore, clone_range_enter, osr_name, len); @@ -2694,12 +2705,13 @@ void FileStore::_do_transaction( case Transaction::OP_CLONERANGE2: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - coll_t ncid = cid; const ghobject_t &noid = i.get_oid(op->dest_oid); - _kludge_temp_object_collection(cid, oid); - _kludge_temp_object_collection(ncid, noid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); + const coll_t &ncid = !_need_temp_object_collection(_cid, noid) ? + _cid : _cid.get_temp(); uint64_t srcoff = op->off; uint64_t len = op->len; uint64_t dstoff = op->dest_off; @@ -2711,7 +2723,7 @@ void FileStore::_do_transaction( case Transaction::OP_MKCOLL: { - coll_t cid = i.get_cid(op->cid); + const coll_t &cid = i.get_cid(op->cid); tracepoint(objectstore, mkcoll_enter, osr_name); if (_check_replay_guard(cid, spos) > 0) r = _create_collection(cid, spos); @@ -2721,7 +2733,7 @@ void FileStore::_do_transaction( case Transaction::OP_COLL_HINT: { - coll_t cid = i.get_cid(op->cid); + const coll_t &cid = i.get_cid(op->cid); uint32_t type = op->hint_type; bufferlist hint; i.decode_bl(hint); @@ -2743,7 +2755,7 @@ void FileStore::_do_transaction( case Transaction::OP_RMCOLL: { - coll_t cid = i.get_cid(op->cid); + const coll_t &cid = i.get_cid(op->cid); tracepoint(objectstore, rmcoll_enter, osr_name); if (_check_replay_guard(cid, spos) > 0) r = _destroy_collection(cid); @@ -2753,15 +2765,15 @@ void FileStore::_do_transaction( case Transaction::OP_COLL_ADD: { - coll_t ocid = i.get_cid(op->cid); - coll_t ncid = i.get_cid(op->dest_cid); + const coll_t &ocid = i.get_cid(op->cid); + const coll_t &ncid = i.get_cid(op->dest_cid); const ghobject_t &oid = i.get_oid(op->oid); assert(oid.hobj.pool >= -1); // always followed by OP_COLL_REMOVE Transaction::Op *op2 = i.decode_op(); - coll_t ocid2 = i.get_cid(op2->cid); + const coll_t &ocid2 = i.get_cid(op2->cid); const ghobject_t &oid2 = i.get_oid(op2->oid); assert(op2->op == Transaction::OP_COLL_REMOVE); assert(ocid2 == ocid); @@ -2783,8 +2795,8 @@ void FileStore::_do_transaction( case Transaction::OP_COLL_MOVE: { // WARNING: this is deprecated and buggy; only here to replay old journals. - coll_t ocid = i.get_cid(op->cid); - coll_t ncid = i.get_cid(op->dest_cid); + const coll_t &ocid = i.get_cid(op->cid); + const coll_t &ncid = i.get_cid(op->dest_cid); const ghobject_t &oid = i.get_oid(op->oid); tracepoint(objectstore, coll_move_enter); r = _collection_add(ocid, ncid, oid, spos); @@ -2797,12 +2809,14 @@ void FileStore::_do_transaction( case Transaction::OP_COLL_MOVE_RENAME: { - coll_t oldcid = i.get_cid(op->cid); + const coll_t &_oldcid = i.get_cid(op->cid); const ghobject_t &oldoid = i.get_oid(op->oid); - coll_t newcid = i.get_cid(op->dest_cid); + const coll_t &_newcid = i.get_cid(op->dest_cid); const ghobject_t &newoid = i.get_oid(op->dest_oid); - _kludge_temp_object_collection(oldcid, oldoid); - _kludge_temp_object_collection(newcid, newoid); + const coll_t &oldcid = !_need_temp_object_collection(_oldcid, oldoid) ? + _oldcid : _oldcid.get_temp(); + const coll_t &newcid = !_need_temp_object_collection(_newcid, newoid) ? + _oldcid : _newcid.get_temp(); tracepoint(objectstore, coll_move_rename_enter); r = _collection_move_rename(oldcid, oldoid, newcid, newoid, spos); tracepoint(objectstore, coll_move_rename_exit, r); @@ -2811,12 +2825,13 @@ void FileStore::_do_transaction( case Transaction::OP_TRY_RENAME: { - coll_t oldcid = i.get_cid(op->cid); - coll_t newcid = oldcid; + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oldoid = i.get_oid(op->oid); const ghobject_t &newoid = i.get_oid(op->dest_oid); - _kludge_temp_object_collection(oldcid, oldoid); - _kludge_temp_object_collection(newcid, newoid); + const coll_t &oldcid = !_need_temp_object_collection(_cid, oldoid) ? + _cid : _cid.get_temp(); + const coll_t &newcid = !_need_temp_object_collection(_cid, newoid) ? + _cid : _cid.get_temp(); tracepoint(objectstore, coll_try_rename_enter); r = _collection_move_rename(oldcid, oldoid, newcid, newoid, spos, true); tracepoint(objectstore, coll_try_rename_exit, r); @@ -2842,9 +2857,10 @@ void FileStore::_do_transaction( case Transaction::OP_OMAP_CLEAR: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); tracepoint(objectstore, omap_clear_enter, osr_name); r = _omap_clear(cid, oid, spos); tracepoint(objectstore, omap_clear_exit, r); @@ -2852,9 +2868,10 @@ void FileStore::_do_transaction( break; case Transaction::OP_OMAP_SETKEYS: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); map aset; i.decode_attrset(aset); tracepoint(objectstore, omap_setkeys_enter, osr_name); @@ -2864,9 +2881,10 @@ void FileStore::_do_transaction( break; case Transaction::OP_OMAP_RMKEYS: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); set keys; i.decode_keyset(keys); tracepoint(objectstore, omap_rmkeys_enter, osr_name); @@ -2876,9 +2894,10 @@ void FileStore::_do_transaction( break; case Transaction::OP_OMAP_RMKEYRANGE: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); string first, last; first = i.decode_string(); last = i.decode_string(); @@ -2889,9 +2908,10 @@ void FileStore::_do_transaction( break; case Transaction::OP_OMAP_SETHEADER: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); bufferlist bl; i.decode_bl(bl); tracepoint(objectstore, omap_setheader_enter, osr_name); @@ -2918,9 +2938,10 @@ void FileStore::_do_transaction( case Transaction::OP_SETALLOCHINT: { - coll_t cid = i.get_cid(op->cid); + const coll_t &_cid = i.get_cid(op->cid); const ghobject_t &oid = i.get_oid(op->oid); - _kludge_temp_object_collection(cid, oid); + const coll_t &cid = !_need_temp_object_collection(_cid, oid) ? + _cid : _cid.get_temp(); uint64_t expected_object_size = op->expected_object_size; uint64_t expected_write_size = op->expected_write_size; tracepoint(objectstore, setallochint_enter, osr_name);