]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/cyanstore: handle OP_ZERO
authorKefu Chai <kchai@redhat.com>
Fri, 21 Aug 2020 05:28:15 +0000 (13:28 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 24 Aug 2020 09:51:32 +0000 (17:51 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/os/cyanstore/cyan_store.cc
src/crimson/os/cyanstore/cyan_store.h

index 3d362dd675a8407358c8d6ee71c9919a87e5a50d..ec1bc5ce4bf319a01d9e6cc00d7ed45a44b52b2b 100644 (file)
@@ -350,6 +350,15 @@ seastar::future<> CyanStore::do_transaction(CollectionRef ch,
         r = _write(cid, oid, off, len, bl, fadvise_flags);
       }
       break;
+      case Transaction::OP_ZERO:
+      {
+        coll_t cid = i.get_cid(op->cid);
+        ghobject_t oid = i.get_oid(op->oid);
+        uint64_t off = op->off;
+        uint64_t len = op->len;
+        r = _zero(cid, oid, off, len);
+      }
+      break;
       case Transaction::OP_TRUNCATE:
       {
         coll_t cid = i.get_cid(op->cid);
@@ -512,6 +521,17 @@ int CyanStore::_write(const coll_t& cid, const ghobject_t& oid,
   return 0;
 }
 
+int CyanStore::_zero(const coll_t& cid, const ghobject_t& oid,
+                     uint64_t offset, size_t len)
+{
+  logger().debug("{} {} {} {} ~ {}",
+                __func__, cid, oid, offset, len);
+
+  ceph::buffer::list bl;
+  bl.append_zero(len);
+  return _write(cid, oid, offset, len, bl, 0);
+}
+
 int CyanStore::_omap_clear(
   const coll_t& cid,
   const ghobject_t& oid)
index 71569d8154e11c27269fcfdad8338b1b56ae85e3..86678042f305fdbded609d546e3c3b606612c164 100644 (file)
@@ -151,6 +151,8 @@ 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 _zero(const coll_t& cid, const ghobject_t& oid,
+           uint64_t offset, size_t len);
   int _omap_clear(
     const coll_t& cid,
     const ghobject_t& oid);