]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/ObjectStore: add merge_collection operation to Transaction
authorSage Weil <sage@redhat.com>
Fri, 16 Feb 2018 04:43:18 +0000 (22:43 -0600)
committerSage Weil <sage@redhat.com>
Fri, 7 Sep 2018 17:07:56 +0000 (12:07 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/ObjectStore.h
src/os/Transaction.cc

index 2ef00640f24e01b517cee14a407b5a3229cb2ff0..129b366ea8b2956766e574194217d5b112fad653 100644 (file)
@@ -349,6 +349,8 @@ public:
       OP_TRY_RENAME = 41,   // oldcid, oldoid, newoid
 
       OP_COLL_SET_BITS = 42, // cid, bits
+
+      OP_MERGE_COLLECTION = 43, // cid, destination
     };
 
     // Transaction hint type
@@ -682,6 +684,13 @@ public:
         op->dest_cid = cm[op->dest_cid];
         break;
 
+      case OP_MERGE_COLLECTION:
+        ceph_assert(op->cid < cm.size());
+       ceph_assert(op->dest_cid < cm.size());
+        op->cid = cm[op->cid];
+        op->dest_cid = cm[op->dest_cid];
+        break;
+
       default:
         ceph_abort_msg("Unknown OP");
       }
@@ -1367,6 +1376,19 @@ public:
       data.ops++;
     }
 
+    /// Merge collection into another.
+    void merge_collection(
+      coll_t cid,
+      coll_t destination,
+      uint32_t bits) {
+      Op* _op = _get_next_op();
+      _op->op = OP_MERGE_COLLECTION;
+      _op->cid = _get_coll_id(cid);
+      _op->dest_cid = _get_coll_id(destination);
+      _op->split_bits = bits;
+      data.ops++;
+    }
+
     void collection_set_bits(
       const coll_t &cid,
       int bits) {
index 69f82cc2b1f5f3a9a55e95ec89eec5ad6d345d6c..ad390a1c3eeebab445dabab9285080f8d51c7978 100644 (file)
@@ -387,6 +387,18 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
       }
       break;
 
+    case Transaction::OP_MERGE_COLLECTION:
+      {
+        coll_t cid = i.get_cid(op->cid);
+        uint32_t bits = op->split_bits;
+        coll_t dest = i.get_cid(op->dest_cid);
+       f->dump_string("op_name", "op_merge_collection");
+       f->dump_stream("collection") << cid;
+       f->dump_stream("dest") << dest;
+       f->dump_stream("bits") << bits;
+      }
+      break;
+
     case Transaction::OP_OMAP_RMKEYRANGE:
       {
         coll_t cid = i.get_cid(op->cid);