]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/cyanstore: handle OP_OMAP_CLEAR
authorKefu Chai <kchai@redhat.com>
Thu, 20 Aug 2020 13:06:24 +0000 (21:06 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 24 Aug 2020 09:49:41 +0000 (17:49 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/os/cyanstore/cyan_store.cc
src/crimson/os/cyanstore/cyan_store.h

index 57363b1d81abb1bfd76472b4c3487fae450d8149..3d362dd675a8407358c8d6ee71c9919a87e5a50d 100644 (file)
@@ -376,6 +376,13 @@ seastar::future<> CyanStore::do_transaction(CollectionRef ch,
         r = _create_collection(cid, op->split_bits);
       }
       break;
+      case Transaction::OP_OMAP_CLEAR:
+      {
+        coll_t cid = i.get_cid(op->cid);
+        ghobject_t oid = i.get_oid(op->oid);
+        r = _omap_clear(cid, oid);
+      }
+      break;
       case Transaction::OP_OMAP_SETKEYS:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -505,6 +512,25 @@ int CyanStore::_write(const coll_t& cid, const ghobject_t& oid,
   return 0;
 }
 
+int CyanStore::_omap_clear(
+  const coll_t& cid,
+  const ghobject_t& oid)
+{
+  logger().debug("{} {} {}", __func__, cid, oid);
+
+  auto c = _get_collection(cid);
+  if (!c) {
+    return -ENOENT;
+  }
+  ObjectRef o = c->get_object(oid);
+  if (!o) {
+    return -ENOENT;
+  }
+  o->omap.clear();
+  o->omap_header.clear();
+  return 0;
+}
+
 int CyanStore::_omap_set_values(
   const coll_t& cid,
   const ghobject_t& oid,
index 877400272b56cd7e6cd6d872f00482a08bb12080..71569d8154e11c27269fcfdad8338b1b56ae85e3 100644 (file)
@@ -151,6 +151,9 @@ private:
   int _write(const coll_t& cid, const ghobject_t& oid,
             uint64_t offset, size_t len, const ceph::bufferlist& bl,
             uint32_t fadvise_flags);
+  int _omap_clear(
+    const coll_t& cid,
+    const ghobject_t& oid);
   int _omap_set_values(
     const coll_t& cid,
     const ghobject_t& oid,