]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: promote_object() for redirect and chunked object
authormyoungwon oh <omwmw@sk.com>
Wed, 6 Dec 2017 08:37:08 +0000 (17:37 +0900)
committermyoungwon oh <omwmw@sk.com>
Fri, 12 Jan 2018 05:38:20 +0000 (14:38 +0900)
Signed-off-by: Myoungwon Oh <omwmw@sk.com>
src/osd/PrimaryLogPG.cc
src/osd/PrimaryLogPG.h

index cacc6999d2373d181b23daa37b3e32c06a6fabb2..b1ba3beb413c6ad575bb9b0c7fab3d93c049c159 100644 (file)
@@ -2369,7 +2369,8 @@ PrimaryLogPG::cache_result_t PrimaryLogPG::maybe_handle_manifest_detail(
     OSDOp& osd_op = *p;
     ceph_osd_op& op = osd_op.op;
     if (op.op == CEPH_OSD_OP_SET_REDIRECT ||
-       op.op == CEPH_OSD_OP_SET_CHUNK) {
+       op.op == CEPH_OSD_OP_SET_CHUNK || 
+       op.op == CEPH_OSD_OP_TIER_PROMOTE) {
       return cache_result_t::NOOP;
     }
   }
@@ -2379,6 +2380,10 @@ PrimaryLogPG::cache_result_t PrimaryLogPG::maybe_handle_manifest_detail(
     if (op->may_write() || write_ordered) {
       do_proxy_write(op, obc);
     } else {
+      // promoted object 
+      if (obc->obs.oi.size != 0) {
+       return cache_result_t::NOOP;
+      }
       do_proxy_read(op, obc);
     }
     return cache_result_t::HANDLED_PROXY;
@@ -3555,18 +3560,49 @@ class PromoteManifestCallback: public PrimaryLogPG::CopyCallback {
   ObjectContextRef obc;
   PrimaryLogPG *pg;
   utime_t start;
+  PrimaryLogPG::OpContext *ctx;
+  PrimaryLogPG::CopyCallbackResults promote_results;
 public:
-  PromoteManifestCallback(ObjectContextRef obc_, PrimaryLogPG *pg_)
+  PromoteManifestCallback(ObjectContextRef obc_, PrimaryLogPG *pg_, PrimaryLogPG::OpContext *ctx = NULL)
     : obc(obc_),
       pg(pg_),
-      start(ceph_clock_now()) {}
+      start(ceph_clock_now()), ctx(ctx) {}
 
   void finish(PrimaryLogPG::CopyCallbackResults results) override {
     PrimaryLogPG::CopyResults *results_data = results.get<1>();
     int r = results.get<0>();
-    pg->finish_promote_manifest(r, results_data, obc);
+    if (ctx) {
+      promote_results = results;
+      pg->execute_ctx(ctx);
+    } else {
+      pg->finish_promote_manifest(r, results_data, obc);
+    }
     pg->osd->logger->tinc(l_osd_tier_promote_lat, ceph_clock_now() - start);
   }
+  friend struct PromoteFinisher;
+};
+
+struct PromoteFinisher : public PrimaryLogPG::OpFinisher {
+  PromoteManifestCallback *promote_callback;
+
+  PromoteFinisher(PromoteManifestCallback *promote_callback)
+    : promote_callback(promote_callback) {
+  }
+
+  int execute() override {
+    if (promote_callback->ctx->obc->obs.oi.manifest.is_redirect()) {
+      promote_callback->ctx->pg->finish_promote(promote_callback->promote_results.get<0>(),
+                                               promote_callback->promote_results.get<1>(),
+                                               promote_callback->obc);
+    } else if (promote_callback->ctx->obc->obs.oi.manifest.is_chunked()) {
+      promote_callback->ctx->pg->finish_promote_manifest(promote_callback->promote_results.get<0>(),
+                                               promote_callback->promote_results.get<1>(),
+                                               promote_callback->obc);
+    } else {
+      assert(0 == "unrecognized manifest type");
+    }
+    return 0;
+  }
 };
 
 void PrimaryLogPG::promote_object(ObjectContextRef obc,
@@ -3609,15 +3645,24 @@ void PrimaryLogPG::promote_object(ObjectContextRef obc,
   }
 
   CopyCallback *cb;
-  object_locator_t my_oloc = oloc;
-  my_oloc.pool = pool.info.tier_of;
+  object_locator_t my_oloc;
+  hobject_t src_hoid;
   if (!obc->obs.oi.has_manifest()) {
+    my_oloc = oloc;
+    my_oloc.pool = pool.info.tier_of;
+    src_hoid = obc->obs.oi.soid;
     cb = new PromoteCallback(obc, this);
   } else {
     if (obc->obs.oi.manifest.is_chunked()) {
+      src_hoid = obc->obs.oi.soid;
       cb = new PromoteManifestCallback(obc, this);
+    } else if (obc->obs.oi.manifest.is_redirect()) {
+      object_locator_t src_oloc(obc->obs.oi.manifest.redirect_target);
+      my_oloc = src_oloc;
+      src_hoid = obc->obs.oi.manifest.redirect_target;
+      cb = new PromoteCallback(obc, this);
     } else {
-      assert(0);
+      assert(0 == "unrecognized manifest type");
     }
   }
 
@@ -3625,7 +3670,7 @@ void PrimaryLogPG::promote_object(ObjectContextRef obc,
                    CEPH_OSD_COPY_FROM_FLAG_IGNORE_CACHE |
                    CEPH_OSD_COPY_FROM_FLAG_MAP_SNAP_CLONE |
                    CEPH_OSD_COPY_FROM_FLAG_RWORDERED;
-  start_copy(cb, obc, obc->obs.oi.soid, my_oloc, 0, flags,
+  start_copy(cb, obc, src_hoid, my_oloc, 0, flags,
             obc->obs.oi.soid.snap == CEPH_NOSNAP,
             src_fadvise_flags, 0);
 
@@ -6702,11 +6747,40 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
          break;
        }
 
-       object_locator_t tgt_oloc(obs.oi.soid);
-       promote_object(ctx->obc, obs.oi.soid, tgt_oloc, ctx->op, NULL);
-
-       dout(10) << "tier-promote oid:" << oi.soid << " manifest: " << obs.oi.manifest << dendl;
-       result = -EAGAIN;
+       if (op_finisher == nullptr) {
+         PromoteManifestCallback *cb;
+         object_locator_t my_oloc;
+         hobject_t src_hoid;
+
+         if (obs.oi.manifest.is_chunked()) {
+           src_hoid = obs.oi.soid;
+           cb = new PromoteManifestCallback(ctx->obc, this, ctx);
+         } else if (obs.oi.manifest.is_redirect()) {
+           object_locator_t src_oloc(obs.oi.manifest.redirect_target);
+           my_oloc = src_oloc;
+           src_hoid = obs.oi.manifest.redirect_target;
+           cb = new PromoteManifestCallback(ctx->obc, this, ctx);
+         } else {
+           assert(0 == "unrecognized manifest type");
+         }
+          ctx->op_finishers[ctx->current_osd_subop_num].reset(
+            new PromoteFinisher(cb));
+         unsigned flags = CEPH_OSD_COPY_FROM_FLAG_IGNORE_OVERLAY |
+                          CEPH_OSD_COPY_FROM_FLAG_IGNORE_CACHE |
+                          CEPH_OSD_COPY_FROM_FLAG_MAP_SNAP_CLONE |
+                          CEPH_OSD_COPY_FROM_FLAG_RWORDERED;
+         unsigned src_fadvise_flags = LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL;
+         start_copy(cb, ctx->obc, src_hoid, my_oloc, 0, flags,
+                    obs.oi.soid.snap == CEPH_NOSNAP,
+                    src_fadvise_flags, 0);
+
+         dout(10) << "tier-promote oid:" << oi.soid << " manifest: " << obs.oi.manifest << dendl;
+         result = -EINPROGRESS;
+       } else {
+         result = op_finisher->execute();
+         assert(result == 0);
+         ctx->op_finishers.erase(ctx->current_osd_subop_num);
+       }
       }
 
       break;
@@ -8452,8 +8526,14 @@ void PrimaryLogPG::start_copy(CopyCallback *cb, ObjectContextRef obc,
   if (!obc->obs.oi.has_manifest()) {
     _copy_some(obc, cop);
   } else {
-    auto p = obc->obs.oi.manifest.chunk_map.begin();
-    _copy_some_manifest(obc, cop, p->first);
+    if (obc->obs.oi.manifest.is_redirect()) {
+      _copy_some(obc, cop);
+    } else if (obc->obs.oi.manifest.is_chunked()) {
+      auto p = obc->obs.oi.manifest.chunk_map.begin();
+      _copy_some_manifest(obc, cop, p->first);
+    } else {
+      assert(0 == "unrecognized manifest type");
+    }
   }
 }
 
index 9e97c42e86c8713b65e030cb9dc26c62139e578c..7e3ccdf7a021d1009a0381e516b8875b9c607f87 100644 (file)
@@ -190,6 +190,7 @@ public:
   friend class CopyFromCallback;
   friend class CopyFromFinisher;
   friend class PromoteCallback;
+  friend class PromoteFinisher;
 
   struct ProxyReadOp {
     OpRequestRef op;