]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
src/osd: add tier_flush operation
authormyoungwon oh <omwmw@sk.com>
Fri, 28 Jun 2019 09:47:56 +0000 (18:47 +0900)
committermyoungwon oh <omwmw@sk.com>
Fri, 12 Jul 2019 13:14:14 +0000 (22:14 +0900)
Current extensible tier flush a chunked object when all chunks mark as dirty.
So, to make the state of object consistent, tier-flush operation is needed.

Signed-off-by: Myoungwon Oh <omwmw@sk.com>
doc/dev/deduplication.rst
src/include/rados.h
src/include/rados/librados.hpp
src/librados/librados_cxx.cc
src/osd/PrimaryLogPG.cc
src/osdc/Objecter.h
src/tools/rados/rados.cc

index 62b487d3c6481ad73287d71f04f12e361740ad8c..4a4c611d48ae96b236e56e6951e8dd3bd197736c 100644 (file)
@@ -173,6 +173,11 @@ Interface
 
         rados -p base_pool unset-manifest <obj-name>
 
+* tier-flush
+
+  flush the object that has chunks to the chunk pool. ::
+
+        rados -p base_pool tier-flush <obj-name>
 
 Dedup tool
 ==========
index ca26a1941eeff5f6c98bd3ea44cc4b9219c6df7b..f9aa1d526c48710192a2d03072315397cb1870ad 100644 (file)
@@ -315,6 +315,7 @@ extern const char *ceph_osd_state_name(int s);
        f(SET_CHUNK,    __CEPH_OSD_OP(WR, DATA, 40),    "set-chunk")        \
        f(TIER_PROMOTE, __CEPH_OSD_OP(WR, DATA, 41),    "tier-promote")     \
        f(UNSET_MANIFEST, __CEPH_OSD_OP(WR, DATA, 42),  "unset-manifest")   \
+       f(TIER_FLUSH, __CEPH_OSD_OP(WR, DATA, 43),      "tier-flush")       \
                                                                            \
        /** attrs **/                                                       \
        /* read */                                                          \
index cbce2e0bd45a20debf5054026dc429f0cb312f74..ff31fe54e28e4e326541cb44d6808377c8fd03a6 100644 (file)
@@ -493,6 +493,7 @@ inline namespace v14_2_0 {
                    std::string tgt_oid, uint64_t tgt_offset, int flag = 0);
     void tier_promote();
     void unset_manifest();
+    void tier_flush();
 
 
     friend class IoCtx;
index 4dc75a8900bcf26775ad083de335bb7dbe87dbcb..c3e1b1b5700c378c1cacf70b54d1fb58f49f850b 100644 (file)
@@ -653,6 +653,13 @@ void librados::ObjectWriteOperation::unset_manifest()
   o->unset_manifest();
 }
 
+void librados::ObjectWriteOperation::tier_flush()
+{
+  ceph_assert(impl);
+  ::ObjectOperation *o = &impl->o;
+  o->tier_flush();
+}
+
 void librados::ObjectWriteOperation::tmap_update(const bufferlist& cmdbl)
 {
   ceph_assert(impl);
index 9f5491616c2e695fb565bc02fcb765c4134e19ac..ad6f9950b6d7c3fcb03bc84a86ee511236ff7c73 100644 (file)
@@ -2277,7 +2277,8 @@ PrimaryLogPG::cache_result_t PrimaryLogPG::maybe_handle_manifest_detail(
     if (op.op == CEPH_OSD_OP_SET_REDIRECT ||
        op.op == CEPH_OSD_OP_SET_CHUNK || 
        op.op == CEPH_OSD_OP_TIER_PROMOTE ||
-       op.op == CEPH_OSD_OP_UNSET_MANIFEST) {
+       op.op == CEPH_OSD_OP_UNSET_MANIFEST ||
+       op.op == CEPH_OSD_OP_TIER_FLUSH) {
       return cache_result_t::NOOP;
     }
   }
@@ -5612,6 +5613,7 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
     case CEPH_OSD_OP_CACHE_UNPIN:
     case CEPH_OSD_OP_SET_REDIRECT:
     case CEPH_OSD_OP_TIER_PROMOTE:
+    case CEPH_OSD_OP_TIER_FLUSH:
       break;
     default:
       if (op.op & CEPH_OSD_OP_MODE_WR)
@@ -6967,6 +6969,46 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
 
       break;
 
+    case CEPH_OSD_OP_TIER_FLUSH:
+      ++ctx->num_write;
+      {
+       if (pool.info.is_tier()) {
+         result = -EINVAL;
+         break;
+       }
+       if (!obs.exists) {
+         result = -ENOENT;
+         break;
+       }
+       if (get_osdmap()->require_osd_release < ceph_release_t::octopus) {
+         result = -EOPNOTSUPP;
+         break;
+       }
+       if (!obs.oi.has_manifest()) {
+         result = 0;
+         break;
+       }
+
+       hobject_t missing;
+       bool is_dirty = false;
+       for (auto& p : ctx->obc->obs.oi.manifest.chunk_map) {
+         if (p.second.is_dirty()) {
+           is_dirty = true;
+           break;
+         }
+       }
+
+       if (is_dirty) {
+         result = start_flush(ctx->op, ctx->obc, true, NULL, std::nullopt);
+         if (result == -EINPROGRESS)
+           result = -EAGAIN;
+       } else {
+         result = 0;
+       }
+      }
+
+      break;
+
     case CEPH_OSD_OP_UNSET_MANIFEST:
       ++ctx->num_write;
       {
index b428ecc52176c8ab5868bd4ba2761ef8706ef59a..90e1bd725cda71cba7e992b8c3efd76d574b8ed8 100644 (file)
@@ -1174,6 +1174,10 @@ struct ObjectOperation {
     add_op(CEPH_OSD_OP_UNSET_MANIFEST);
   }
 
+  void tier_flush() {
+    add_op(CEPH_OSD_OP_TIER_FLUSH);
+  }
+
   void set_alloc_hint(uint64_t expected_object_size,
                       uint64_t expected_write_size,
                      uint32_t flags) {
index 37c6d3352e0d69446630261942bb46d7b598fda0..79c390a5f4516ade56a71450a46f8cf67bb50137 100644 (file)
@@ -131,6 +131,7 @@ void usage(ostream& out)
 "                                    convert an object to chunked object\n"
 "   tier-promote <obj-name>         promote the object to the base tier\n"
 "   unset-manifest <obj-name>       unset redirect or chunked object\n"
+"   tier-flush <obj-name>           flush the chunked object\n"
 "\n"
 "IMPORT AND EXPORT\n"
 "   export [filename]\n"
@@ -3770,6 +3771,21 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
           << cpp_strerror(ret) << std::endl;
       return 1;
     }
+  } else if (strcmp(nargs[0], "tier-flush") == 0) {
+    if (!pool_name || nargs.size() < 2) {
+      usage(cerr);
+      return 1;
+    }
+    string oid(nargs[1]);
+
+    ObjectWriteOperation op;
+    op.tier_flush();
+    ret = io_ctx.operate(oid, &op);
+    if (ret < 0) {
+      cerr << "error tier-flush " << pool_name << "/" << oid << " : " 
+          << cpp_strerror(ret) << std::endl;
+      return 1;
+    }
   } else if (strcmp(nargs[0], "export") == 0) {
     // export [filename]
     if (!pool_name || nargs.size() > 2) {