mirror of
https://github.com/ceph/ceph
synced 2025-02-24 11:37:37 +00:00
osd: return error code of remote-reads via cls_cxx_get_gathered_data
Fixes: https://tracker.ceph.com/issues/48182 Signed-off-by: Ken Iizawa <iizawa.ken@fujitsu.com>
This commit is contained in:
parent
fa226f2a46
commit
a5b04552f8
@ -152,7 +152,7 @@ extern int cls_get_snapset_seq(cls_method_context_t hctx, uint64_t *snap_seq);
|
||||
extern int cls_cxx_gather(cls_method_context_t hctx, const std::set<std::string> &src_objs, const std::string& pool,
|
||||
const char *cls, const char *method, bufferlist& inbl);
|
||||
|
||||
extern std::shared_ptr<std::map<std::string, bufferlist> > cls_cxx_get_gathered_data(cls_method_context_t hctx);
|
||||
extern int cls_cxx_get_gathered_data(cls_method_context_t hctx, std::map<std::string, bufferlist> *results);
|
||||
|
||||
/* These are also defined in rados.h and librados.h. Keep them in sync! */
|
||||
#define CEPH_OSD_TMAP_HDR 'h'
|
||||
|
@ -10093,14 +10093,14 @@ struct C_gather : public Context {
|
||||
pg->unlock();
|
||||
return;
|
||||
}
|
||||
pg->cls_gather_ops.erase(oid);
|
||||
pg->cls_gather_set_result(oid, r);
|
||||
pg->execute_ctx(ctx);
|
||||
pg->unlock();
|
||||
}
|
||||
};
|
||||
|
||||
int PrimaryLogPG::cls_gather(OpContext *ctx, std::shared_ptr<std::map<std::string, bufferlist> > src_obj_buffs, const std::string& pool,
|
||||
const char *cls, const char *method, bufferlist& inbl)
|
||||
int PrimaryLogPG::start_cls_gather(OpContext *ctx, std::shared_ptr<std::map<std::string, bufferlist> > src_obj_buffs, const std::string& pool,
|
||||
const char *cls, const char *method, bufferlist& inbl)
|
||||
{
|
||||
OpRequestRef op = ctx->op;
|
||||
MOSDOp *m = static_cast<MOSDOp*>(op->get_nonconst_req());
|
||||
@ -10137,6 +10137,18 @@ int PrimaryLogPG::cls_gather(OpContext *ctx, std::shared_ptr<std::map<std::strin
|
||||
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(soid);
|
||||
return r;
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// flush
|
||||
//
|
||||
@ -10932,6 +10944,13 @@ bool PrimaryLogPG::is_present_clone(hobject_t coid)
|
||||
// cls gather
|
||||
//
|
||||
|
||||
void PrimaryLogPG::cls_gather_set_result(hobject_t oid, int r)
|
||||
{
|
||||
map<hobject_t,PrimaryLogPG::CLSGatherOp>::iterator p = cls_gather_ops.find(oid);
|
||||
ceph_assert(p != cls_gather_ops.end());
|
||||
p->second.rval = r;
|
||||
}
|
||||
|
||||
void PrimaryLogPG::cancel_cls_gather(CLSGatherOp cgop, bool requeue,
|
||||
vector<ceph_tid_t> *tids)
|
||||
{
|
||||
|
@ -1405,6 +1405,7 @@ protected:
|
||||
|
||||
// -- cls_gather --
|
||||
std::map<hobject_t, CLSGatherOp> cls_gather_ops;
|
||||
void cls_gather_set_result(hobject_t oid, int r);
|
||||
void cancel_cls_gather(CLSGatherOp cgop, bool requeue, std::vector<ceph_tid_t> *tids);
|
||||
void cancel_cls_gather_ops(bool requeue, std::vector<ceph_tid_t> *tids);
|
||||
|
||||
@ -1551,8 +1552,10 @@ public:
|
||||
int do_tmapup_slow(OpContext *ctx, ceph::buffer::list::const_iterator& bp, OSDOp& osd_op, ceph::buffer::list& bl);
|
||||
|
||||
void do_osd_op_effects(OpContext *ctx, const ConnectionRef& conn);
|
||||
int cls_gather(OpContext *ctx, std::shared_ptr<std::map<std::string, bufferlist> > src_objs, const std::string& pool,
|
||||
const char *cls, const char *method, bufferlist& inbl);
|
||||
int start_cls_gather(OpContext *ctx, std::shared_ptr<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);
|
||||
bool check_src_targ(const hobject_t& soid, const hobject_t& toid) const;
|
||||
|
@ -718,13 +718,14 @@ int cls_cxx_gather(cls_method_context_t hctx, const std::set<std::string> &src_o
|
||||
(*src_obj_buffs)[*it] = bufferlist();
|
||||
}
|
||||
(*pctx)->op_finishers[(*pctx)->current_osd_subop_num].reset(new GatherFinisher(src_obj_buffs));
|
||||
return (*pctx)->pg->cls_gather(*pctx, src_obj_buffs, pool, cls, method, inbl);
|
||||
return (*pctx)->pg->start_cls_gather(*pctx, src_obj_buffs, pool, cls, method, inbl);
|
||||
}
|
||||
|
||||
std::shared_ptr<std::map<std::string, bufferlist> > cls_cxx_get_gathered_data(cls_method_context_t hctx)
|
||||
int cls_cxx_get_gathered_data(cls_method_context_t hctx, std::map<std::string, bufferlist> *results)
|
||||
{
|
||||
PrimaryLogPG::OpContext **pctx = (PrimaryLogPG::OpContext**)hctx;
|
||||
PrimaryLogPG::OpFinisher* op_finisher = nullptr;
|
||||
int r = 0;
|
||||
{
|
||||
auto op_finisher_it = (*pctx)->op_finishers.find((*pctx)->current_osd_subop_num);
|
||||
if (op_finisher_it != (*pctx)->op_finishers.end()) {
|
||||
@ -732,9 +733,11 @@ std::shared_ptr<std::map<std::string, bufferlist> > cls_cxx_get_gathered_data(cl
|
||||
}
|
||||
}
|
||||
if (op_finisher == NULL) {
|
||||
return std::shared_ptr<std::map<std::string, bufferlist> >(new std::map<std::string, bufferlist>);
|
||||
results->clear();
|
||||
} else {
|
||||
GatherFinisher *gf = (GatherFinisher*)op_finisher;
|
||||
return std::move(gf->src_obj_buffs);
|
||||
*results = *gf->src_obj_buffs;
|
||||
r = (*pctx)->pg->finish_cls_gather(*pctx);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user