]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: add merge_delete
authorManali Kulkarni <Manali.Kulkarni@sandisk.com>
Tue, 27 Sep 2016 14:24:10 +0000 (10:24 -0400)
committerSage Weil <sage@redhat.com>
Tue, 27 Sep 2016 15:56:44 +0000 (11:56 -0400)
Signed-off-by: Manali Kulkarni <Manali.Kulkarni@sandisk.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 627ee25fdc8dc978fde2866dd6819e43bb381d8d..d4231468b71d0ae4d57ac7897b0c5ff82800b7d3 100644 (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,
index 362e0316cf9f10a9d4e4ec03f50d94a6a647e211..5361cfade811dfcec85c0fd1b6d6a135fbf06438 100644 (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,