}
break;
+ case Transaction::OP_MERGE_DELETE:
+ {
+ const ghobject_t& boid = i.get_oid(op->dest_oid);
+ OnodeRef bo = c->get_onode(boid, 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, cvec[op->dest_cid], bo, move_info);
+ }
+ break;
+
case Transaction::OP_COLL_ADD:
assert(0 == "not implemented");
break;
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 KStore::_move_ranges_destroy_src(TransContext *txc,
+ CollectionRef& c,
+ OnodeRef& srco,
+ CollectionRef& basec,
+ OnodeRef& baseo,
+ vector<boost::tuple<uint64_t, uint64_t, uint64_t>> move_info)
+{
+ int r = 0;
+ bufferlist bl;
+ baseo->exists = true;
+ _assign_nid(txc, baseo);
+
+// Traverse move_info completely, move contents from src to base object.
+ for (unsigned i = 0; i < move_info.size(); ++i) {
+ uint64_t srcoff;
+ uint64_t dstoff;
+ uint64_t len;
+
+ srcoff = move_info[i].get<0>();
+ dstoff = move_info[i].get<1>();
+ len = move_info[i].get<2>();
+
+ r = _do_read(srco, srcoff, len, bl, 0);
+ if (r < 0)
+ goto out;
+
+ r = _do_write(txc, baseo, dstoff, bl.length(), bl, 0);
+ txc->write_onode(baseo);
+ r = 0;
+ }
+
+// After for loop ends, remove src obj
+ r = _do_remove(txc, srco);
+
+ out:
+ return r;
+}
+
+
int KStore::_rename(TransContext *txc,
CollectionRef& c,
OnodeRef& oldo,
OnodeRef& oldo,
OnodeRef& newo,
uint64_t srcoff, uint64_t length, uint64_t dstoff);
+ int _move_ranges_destroy_src(TransContext *txc,
+ CollectionRef& c,
+ OnodeRef& oldo,
+ CollectionRef& bc,
+ OnodeRef& newo,
+ vector<boost::tuple<uint64_t, uint64_t, uint64_t>> move_info);
int _rename(TransContext *txc,
CollectionRef& c,
OnodeRef& oldo,