os/bluestore: add merge_delete

Signed-off-by: Manali Kulkarni <Manali.Kulkarni@sandisk.com>
This commit is contained in:
Manali Kulkarni 2016-09-27 10:24:10 -04:00 committed by Sage Weil
parent fdb8345e82
commit 8105ded227
2 changed files with 53 additions and 0 deletions

View File

@ -6720,6 +6720,19 @@ void BlueStore::_txc_add_transaction(TransContext *txc, Transaction *t)
}
break;
case Transaction::OP_MERGE_DELETE:
{
const ghobject_t& noid = i.get_oid(op->dest_oid);
OnodeRef& no = ovec[op->dest_oid];
if (!no) {
no = c->get_onode(noid, true);
}
vector<boost::tuple<uint64_t, uint64_t, uint64_t>> move_info;
i.decode_move_info(move_info);
r = _move_ranges_destroy_src(txc, c, o, no, move_info);
}
break;
case Transaction::OP_COLL_ADD:
assert(0 == "not implemented");
break;
@ -8183,6 +8196,41 @@ int BlueStore::_clone_range(TransContext *txc,
return r;
}
/* Move contents of src object according to move_info to base object.
* Once the move_info is traversed completely, delete the src object.
*/
int BlueStore::_move_ranges_destroy_src(TransContext *txc,
CollectionRef& c,
OnodeRef& srco,
OnodeRef& baseo,
const vector<boost::tuple<uint64_t, uint64_t, uint64_t>> move_info)
{
dout(15) << __func__ << " " << c->cid << " " << srco->oid << " -> " << baseo->oid << dendl;
int r = 0;
//Traverse move_info completely, move contents from src object to base object.
for (unsigned i = 0; i < move_info.size(); ++i) {
uint64_t srcoff = move_info[i].get<0>();
uint64_t dstoff = move_info[i].get<1>();
uint64_t len = move_info[i].get<2>();
dout(15) << __func__ << " " << c->cid << " " << srco->oid << " -> "
<< baseo->oid << " from 0x" << std::hex << srcoff << "~" << len
<< " to offset 0x" << dstoff << std::dec << dendl;
r = _clone_range(txc, c, srco, baseo, srcoff, len, dstoff);
if (r < 0)
goto out;
}
// delete the src object
r = _do_remove(txc, c, srco);
out:
return r;
}
int BlueStore::_rename(TransContext *txc,
CollectionRef& c,
OnodeRef& oldo,

View File

@ -1872,6 +1872,11 @@ private:
OnodeRef& oldo,
OnodeRef& newo,
uint64_t srcoff, uint64_t length, uint64_t dstoff);
int _move_ranges_destroy_src(TransContext *txc,
CollectionRef& c,
OnodeRef& oldo,
OnodeRef& newo,
const vector<boost::tuple<uint64_t, uint64_t, uint64_t>> move_info);
int _rename(TransContext *txc,
CollectionRef& c,
OnodeRef& oldo,