Skip to content

Commit

Permalink
crimson/osd: implement cls_get_request_origin().
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslaw Zarzynski <[email protected]>
  • Loading branch information
rzarzynski committed Sep 13, 2019
1 parent 3daddb8 commit fe9ce1f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/crimson/osd/objclass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ int cls_read(cls_method_context_t hctx,

int cls_get_request_origin(cls_method_context_t hctx, entity_inst_t *origin)
{
assert(origin)
*origin =
reinterpret_cast<ceph::osd::OpsExecuter*>(hctx)->get_orig_source_inst();
return 0;
}

Expand Down
14 changes: 12 additions & 2 deletions src/crimson/osd/ops_executer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "crimson/osd/pg_backend.h"
#include "crimson/osd/exceptions.h"

#include "messages/MOSDOp.h"

class PGLSFilter;
class OSDOp;

Expand All @@ -48,6 +50,7 @@ class OpsExecuter {
PGBackend::cached_os_t os;
PG& pg;
PGBackend& backend;
Ref<MOSDOp> msg;
ceph::os::Transaction txn;

size_t num_read = 0; ///< count read ops
Expand Down Expand Up @@ -94,14 +97,21 @@ class OpsExecuter {
}

public:
OpsExecuter(PGBackend::cached_os_t os, PG& pg)
: os(std::move(os)), pg(pg), backend(pg.get_backend()) {
OpsExecuter(PGBackend::cached_os_t os, PG& pg, Ref<MOSDOp> msg)
: os(std::move(os)),
pg(pg),
backend(pg.get_backend()),
msg(std::move(msg)) {
}

seastar::future<> do_osd_op(class OSDOp& osd_op);

template <typename Func>
seastar::future<> submit_changes(Func&& f) &&;

auto get_orig_source_inst() const {
return msg->get_orig_source_inst();
}
};

template <class Context, class MainFunc, class EffectFunc>
Expand Down
4 changes: 2 additions & 2 deletions src/crimson/osd/pg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ seastar::future<Ref<MOSDOpReply>> PG::do_osd_ops(Ref<MOSDOp> m)
const auto oid = m->get_snapid() == CEPH_SNAPDIR ? m->get_hobj().get_head()
: m->get_hobj();
return backend->get_object_state(oid).then([this, m](auto os) mutable {
return seastar::do_with(OpsExecuter{std::move(os), *this/* as const& */},
[this, m=std::move(m)] (auto& ox) {
return seastar::do_with(OpsExecuter{std::move(os), *this/* as const& */, m},
[this, m] (auto& ox) {
return seastar::do_for_each(m->ops, [this, &ox](OSDOp& osd_op) {
logger().debug("will be handling op {}", ceph_osd_op_name(osd_op.op.op));
return ox.do_osd_op(osd_op);
Expand Down

0 comments on commit fe9ce1f

Please sign in to comment.