]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: modify C_gather to erase CLSGatherOp from cls_gather_ops
authorKen Iizawa <iizawa.ken@fujitsu.com>
Fri, 12 Feb 2021 10:15:14 +0000 (19:15 +0900)
committerKen Iizawa <iizawa.ken@fujitsu.com>
Fri, 12 Feb 2021 10:34:06 +0000 (19:34 +0900)
Fixes: https://tracker.ceph.com/issues/48182
Signed-off-by: Ken Iizawa <iizawa.ken@fujitsu.com>
src/osd/PrimaryLogPG.cc
src/osd/PrimaryLogPG.h
src/osd/objclass.cc

index 7ee9c73f0e2905b3b475346917fafb63f02171a0..d88f2a178e08e92616bdc71c7f7c4637c783f323 100644 (file)
@@ -10083,8 +10083,9 @@ struct C_gather : public Context {
   hobject_t oid;
   PrimaryLogPG::OpContext *ctx;
   epoch_t last_peering_reset;
-  C_gather(PrimaryLogPG *pg_, hobject_t oid_, PrimaryLogPG::OpContext *ctx_, epoch_t lpr_) :
-    pg(pg_), oid(oid_), ctx(ctx_), last_peering_reset(lpr_) {}
+  OSDOp *osd_op;
+  C_gather(PrimaryLogPG *pg_, hobject_t oid_, PrimaryLogPG::OpContext *ctx_, epoch_t lpr_, OSDOp *osd_op_) :
+    pg(pg_), oid(oid_), ctx(ctx_), last_peering_reset(lpr_), osd_op(osd_op_) {}
   void finish(int r) override {
     if (r == -ECANCELED)
       return;
@@ -10097,7 +10098,8 @@ struct C_gather : public Context {
     if (last_peering_reset != pg->get_last_peering_reset()) {
       return;
     }
-    pg->cls_gather_set_result(p, r);
+    osd_op->rval = r;
+    pg->cls_gather_ops.erase(p);
     pg->execute_ctx(ctx);
   }
 };
@@ -10132,8 +10134,8 @@ int PrimaryLogPG::start_cls_gather(OpContext *ctx, std::map<std::string, bufferl
     cgop.objecter_tids.push_back(tid);
     dout(10) << __func__ << " src=" << oid << ", tgt=" << soid << dendl;
   }
-  
-  C_gather *fin = new C_gather(this, soid, ctx, get_last_peering_reset());
+
+  C_gather *fin = new C_gather(this, soid, ctx, get_last_peering_reset(), &(*ctx->ops)[ctx->current_osd_subop_num]);
   gather.set_finisher(new C_OnFinisher(fin,
                                       osd->get_objecter_finisher(get_pg_shard())));
   gather.activate();
@@ -10141,18 +10143,6 @@ int PrimaryLogPG::start_cls_gather(OpContext *ctx, std::map<std::string, bufferl
   return -EINPROGRESS;
 }
 
-int PrimaryLogPG::finish_cls_gather(OpContext *ctx)
-{
-  ObjectState& obs = ctx->new_obs;
-  object_info_t& oi = obs.oi;
-  const hobject_t& soid = oi.soid;
-  map<hobject_t,PrimaryLogPG::CLSGatherOp>::iterator p = cls_gather_ops.find(soid);
-  ceph_assert(p != cls_gather_ops.end());
-  int r = p->second.rval;
-  cls_gather_ops.erase(p);
-  return r;
-}
-
 // ========================================================================
 // flush
 //
@@ -10948,12 +10938,6 @@ bool PrimaryLogPG::is_present_clone(hobject_t coid)
 // cls gather
 //
 
-void PrimaryLogPG::cls_gather_set_result(map<hobject_t,PrimaryLogPG::CLSGatherOp>::iterator p, int r)
-{
-  ceph_assert(p != cls_gather_ops.end());
-  p->second.rval = r;
-}
-
 void PrimaryLogPG::cancel_cls_gather(map<hobject_t,CLSGatherOp>::iterator iter, bool requeue,
                                     vector<ceph_tid_t> *tids)
 {
index 45f090636482848b61805f373e932e0c90c723c8..b0a63b1262e41cf6ee67325ae5820363fbf0bf05 100644 (file)
@@ -1405,7 +1405,6 @@ protected:
 
   // -- cls_gather --
   std::map<hobject_t, CLSGatherOp> cls_gather_ops;
-  void cls_gather_set_result(map<hobject_t,PrimaryLogPG::CLSGatherOp>::iterator p, int r);
   void cancel_cls_gather(map<hobject_t,CLSGatherOp>::iterator iter, bool requeue, std::vector<ceph_tid_t> *tids);
   void cancel_cls_gather_ops(bool requeue, std::vector<ceph_tid_t> *tids);
 
@@ -1554,7 +1553,6 @@ public:
   void do_osd_op_effects(OpContext *ctx, const ConnectionRef& conn);
   int start_cls_gather(OpContext *ctx, std::map<std::string, bufferlist> *src_objs, const std::string& pool,
                       const char *cls, const char *method, bufferlist& inbl);
-  int finish_cls_gather(OpContext *ctx);
 
 private:
   int do_scrub_ls(const MOSDOp *op, OSDOp *osd_op);
index 6cb91477cc3081fe0727df607084e3bf06e9b1e4..5aad8acec4658b952950c060ea734a87f3455930 100644 (file)
@@ -703,6 +703,8 @@ uint64_t cls_get_pool_stripe_width(cls_method_context_t hctx)
 
 struct GatherFinisher : public PrimaryLogPG::OpFinisher {
   std::map<std::string, bufferlist> src_obj_buffs;
+  OSDOp *osd_op;
+  GatherFinisher(OSDOp *osd_op_) : osd_op(osd_op_) {}
   int execute() override {
     return 0;
   }
@@ -712,7 +714,9 @@ int cls_cxx_gather(cls_method_context_t hctx, const std::set<std::string> &src_o
                   const char *cls, const char *method, bufferlist& inbl)
 {
   PrimaryLogPG::OpContext **pctx = (PrimaryLogPG::OpContext**)hctx;
-  auto [iter, inserted] = (*pctx)->op_finishers.emplace(std::make_pair((*pctx)->current_osd_subop_num, std::make_unique<GatherFinisher>()));
+  int subop_num = (*pctx)->current_osd_subop_num;
+  OSDOp *osd_op = &(*(*pctx)->ops)[subop_num];
+  auto [iter, inserted] = (*pctx)->op_finishers.emplace(std::make_pair(subop_num, std::make_unique<GatherFinisher>(osd_op)));
   assert(inserted);
   auto &gather = *static_cast<GatherFinisher*>(iter->second.get());
   for (const auto &obj : src_objs) {
@@ -737,7 +741,7 @@ int cls_cxx_get_gathered_data(cls_method_context_t hctx, std::map<std::string, b
   } else {
     GatherFinisher *gf = (GatherFinisher*)op_finisher;
     *results = gf->src_obj_buffs;
-    r = (*pctx)->pg->finish_cls_gather(*pctx);
+    r = gf->osd_op->rval;
   }
   return r;
 }