OSDPerfMetricSubKey *sub_key) {
ceph_assert(d.is_supported());
- auto m = static_cast<const MOSDOp*>(op.get_req());
+ auto m = op.get_req<MOSDOp>();
std::string match_string;
switch(d.type) {
case OSDPerfMetricSubKeyType::CLIENT_ID:
return true;
}
case MSG_OSD_EC_READ: {
- const MOSDECSubOpRead *op = static_cast<const MOSDECSubOpRead*>(_op->get_req());
+ auto op = _op->get_req<MOSDECSubOpRead>();
MOSDECSubOpReadReply *reply = new MOSDECSubOpReadReply;
reply->pgid = get_parent()->primary_spg_t();
reply->map_epoch = get_osdmap_epoch();
return true;
}
case MSG_OSD_PG_PUSH: {
- const MOSDPGPush *op = static_cast<const MOSDPGPush *>(_op->get_req());
+ auto op = _op->get_req<MOSDPGPush>();
RecoveryMessages rm;
for (vector<PushOp>::const_iterator i = op->pushes.begin();
i != op->pushes.end();
void OSDService::reply_op_error(OpRequestRef op, int err, eversion_t v,
version_t uv)
{
- const MOSDOp *m = static_cast<const MOSDOp*>(op->get_req());
+ auto m = op->get_req<MOSDOp>();
ceph_assert(m->get_type() == CEPH_MSG_OSD_OP);
int flags;
flags = m->get_flags() & (CEPH_OSD_FLAG_ACK|CEPH_OSD_FLAG_ONDISK);
return;
}
- const MOSDOp *m = static_cast<const MOSDOp*>(op->get_req());
+ auto m = op->get_req<MOSDOp>();
ceph_assert(m->get_type() == CEPH_MSG_OSD_OP);
ceph_assert(m->get_map_epoch() >= pg->get_history().same_primary_since);
while (i != session->waiting_on_map.end()) {
OpRequestRef op = &(*i);
ceph_assert(ms_can_fast_dispatch(op->get_req()));
- const MOSDFastDispatchOp *m = static_cast<const MOSDFastDispatchOp*>(
- op->get_req());
+ auto m = op->get_req<MOSDFastDispatchOp>();
if (m->get_min_epoch() > osdmap->get_epoch()) {
break;
}
// NOTE: this can be removed in P release (mimic is the last version to
// send MOSDPGCreate messages).
- const MOSDPGCreate *m = static_cast<const MOSDPGCreate*>(op->get_req());
+ auto m = op->get_req<MOSDPGCreate>();
ceph_assert(m->get_type() == MSG_OSD_PG_CREATE);
dout(10) << "handle_pg_create " << *m << dendl;
int OSD::init_op_flags(OpRequestRef& op)
{
- const MOSDOp *m = static_cast<const MOSDOp*>(op->get_req());
+ auto m = op->get_req<MOSDOp>();
vector<OSDOp>::const_iterator iter;
// client flags have no bearing on whether an op is a read, write, etc.
epoch_t min_epoch = 0; ///< min epoch needed to handle this msg
bool hitset_inserted;
+
+ template<class T>
+ const T* get_req() const { return static_cast<const T*>(request); }
+
const Message *get_req() const { return request; }
Message *get_nonconst_req() { return request; }
if (op->get_req()->get_type() != CEPH_MSG_OSD_OP)
return true;
- const MOSDOp *req = static_cast<const MOSDOp*>(op->get_req());
-
+ auto req = op->get_req<MOSDOp>();
auto priv = req->get_connection()->get_priv();
auto session = static_cast<Session*>(priv.get());
if (!session) {
void PG::do_replica_scrub_map(OpRequestRef op)
{
- const MOSDRepScrubMap *m = static_cast<const MOSDRepScrubMap*>(op->get_req());
+ auto m = op->get_req<MOSDRepScrubMap>();
dout(7) << __func__ << " " << *m << dendl;
if (m->map_epoch < info.history.same_interval_since) {
dout(10) << __func__ << " discarding old from "
dout(20) << __func__ << ": failed to reserve remotely" << dendl;
scrubber.reserved = false;
}
- const MOSDScrubReserve *m =
- static_cast<const MOSDScrubReserve*>(op->get_req());
+ auto m = op->get_req<MOSDScrubReserve>();
Message *reply = new MOSDScrubReserve(
spg_t(info.pgid.pgid, get_primary().shard),
m->map_epoch,
OpRequestRef op,
ThreadPool::TPHandle &handle)
{
- const MOSDRepScrub *msg = static_cast<const MOSDRepScrub *>(op->get_req());
+ auto msg = op->get_req<MOSDRepScrub>();
ceph_assert(!scrubber.active_rep_scrub);
dout(7) << "replica_scrub" << dendl;
bool PG::can_discard_op(OpRequestRef& op)
{
- const MOSDOp *m = static_cast<const MOSDOp*>(op->get_req());
+ auto m = op->get_req<MOSDOp>();
if (cct->_conf->osd_discard_disconnected_ops && OSD::op_is_discardable(m)) {
dout(20) << " discard " << *m << dendl;
return true;
template<typename T, int MSGTYPE>
bool PG::can_discard_replica_op(OpRequestRef& op)
{
- const T *m = static_cast<const T *>(op->get_req());
+ auto m = op->get_req<T>();
ceph_assert(m->get_type() == MSGTYPE);
int from = m->get_source().num();
bool PG::can_discard_scan(OpRequestRef op)
{
- const MOSDPGScan *m = static_cast<const MOSDPGScan *>(op->get_req());
+ auto m = op->get_req<MOSDPGScan>();
ceph_assert(m->get_type() == MSG_OSD_PG_SCAN);
if (old_peering_msg(m->map_epoch, m->query_epoch)) {
bool PG::can_discard_backfill(OpRequestRef op)
{
- const MOSDPGBackfill *m = static_cast<const MOSDPGBackfill *>(op->get_req());
+ auto m = op->get_req<MOSDPGBackfill>();
ceph_assert(m->get_type() == MSG_OSD_PG_BACKFILL);
if (old_peering_msg(m->map_epoch, m->query_epoch)) {
void PGBackend::handle_recovery_delete(OpRequestRef op)
{
- const MOSDPGRecoveryDelete *m = static_cast<const MOSDPGRecoveryDelete *>(op->get_req());
+ auto m = op->get_req<MOSDPGRecoveryDelete>();
ceph_assert(m->get_type() == MSG_OSD_PG_RECOVERY_DELETE);
dout(20) << __func__ << " " << op << dendl;
void PGBackend::handle_recovery_delete_reply(OpRequestRef op)
{
- const MOSDPGRecoveryDeleteReply *m = static_cast<const MOSDPGRecoveryDeleteReply *>(op->get_req());
+ auto m = op->get_req<MOSDPGRecoveryDeleteReply>();
ceph_assert(m->get_type() == MSG_OSD_PG_RECOVERY_DELETE_REPLY);
dout(20) << __func__ << " " << op << dendl;
void PrimaryLogPG::handle_backoff(OpRequestRef& op)
{
- const MOSDBackoff *m = static_cast<const MOSDBackoff*>(op->get_req());
+ auto m = op->get_req<MOSDBackoff>();
SessionRef session{static_cast<Session*>(m->get_connection()->get_priv().get())};
if (!session)
return; // drop it.
case MSG_OSD_SCRUB_RESERVE:
{
- const MOSDScrubReserve *m =
- static_cast<const MOSDScrubReserve*>(op->get_req());
+ auto m = op->get_req<MOSDScrubReserve>();
switch (m->type) {
case MOSDScrubReserve::REQUEST:
handle_scrub_reserve_request(op);
ObjectContextRef obc)
{
ceph_assert(obc);
- if (static_cast<const MOSDOp *>(op->get_req())->get_flags() &
- CEPH_OSD_FLAG_IGNORE_REDIRECT) {
+ if (op->get_req<MOSDOp>()->get_flags() & CEPH_OSD_FLAG_IGNORE_REDIRECT) {
dout(20) << __func__ << ": ignoring redirect due to flag" << dendl;
return cache_result_t::NOOP;
}
return cache_result_t::NOOP;
}
- vector<OSDOp> ops = static_cast<const MOSDOp*>(op->get_req())->ops;
+ vector<OSDOp> ops = op->get_req<MOSDOp>()->ops;
for (vector<OSDOp>::iterator p = ops.begin(); p != ops.end(); ++p) {
OSDOp& osd_op = *p;
ceph_osd_op& op = osd_op.op;
for (auto& p : obc->obs.oi.manifest.chunk_map) {
if (p.second.is_missing()) {
- const MOSDOp *m = static_cast<const MOSDOp*>(op->get_req());
+ auto m = op->get_req<MOSDOp>();
const object_locator_t oloc = m->get_object_locator();
promote_object(obc, obc->obs.oi.soid, oloc, op, NULL);
return cache_result_t::BLOCKED_PROMOTE;
{
dout(20) << __func__ << " r=" << r << dendl;
ceph_assert(op->may_write());
- const osd_reqid_t &reqid = static_cast<const MOSDOp*>(op->get_req())->get_reqid();
+ const osd_reqid_t &reqid = op->get_req<MOSDOp>()->get_reqid();
mempool::osd_pglog::list<pg_log_entry_t> entries;
entries.push_back(pg_log_entry_t(pg_log_entry_t::ERROR, soid,
get_next_version(), eversion_t(), 0,
{}
void operator()() {
ldpp_dout(pg, 20) << "finished " << __func__ << " r=" << r << dendl;
- const MOSDOp *m = static_cast<const MOSDOp*>(op->get_req());
+ auto m = op->get_req<MOSDOp>();
int flags = m->get_flags() & (CEPH_OSD_FLAG_ACK | CEPH_OSD_FLAG_ONDISK);
MOSDOpReply *reply = orig_reply.detach();
if (reply == nullptr) {
if (op &&
op->get_req() &&
op->get_req()->get_type() == CEPH_MSG_OSD_OP &&
- (static_cast<const MOSDOp *>(op->get_req())->get_flags() &
+ (op->get_req<MOSDOp>()->get_flags() &
CEPH_OSD_FLAG_IGNORE_CACHE)) {
dout(20) << __func__ << ": ignoring cache due to flag" << dendl;
return cache_result_t::NOOP;
missing_oid = obc->obs.oi.soid;
}
- const MOSDOp *m = static_cast<const MOSDOp*>(op->get_req());
+ auto m = op->get_req<MOSDOp>();
const object_locator_t oloc = m->get_object_locator();
if (op->need_skip_handle_cache()) {
void PrimaryLogPG::do_cache_redirect(OpRequestRef op)
{
- const MOSDOp *m = static_cast<const MOSDOp*>(op->get_req());
+ auto m = op->get_req<MOSDOp>();
int flags = m->get_flags() & (CEPH_OSD_FLAG_ACK|CEPH_OSD_FLAG_ONDISK);
MOSDOpReply *reply = new MOSDOpReply(m, -ENOENT, get_osdmap_epoch(),
flags, false);
osd->logger->inc(l_osd_tier_proxy_read);
- const MOSDOp *m = static_cast<const MOSDOp*>(op->get_req());
+ auto m = op->get_req<MOSDOp>();
OpContext *ctx = new OpContext(op, m->get_reqid(), &prdop->ops, this);
ctx->reply = new MOSDOpReply(m, 0, get_osdmap_epoch(), 0, false);
ctx->user_at_version = prdop->user_version;
osd->logger->inc(l_osd_tier_proxy_write);
- const MOSDOp *m = static_cast<const MOSDOp*>(pwop->op->get_req());
+ auto m = pwop->op->get_req<MOSDOp>();
ceph_assert(m != NULL);
if (!pwop->sent_reply) {
ctx->reset_obs(ctx->obc);
ctx->update_log_only = false; // reset in case finish_copyfrom() is re-running execute_ctx
OpRequestRef op = ctx->op;
- const MOSDOp *m = static_cast<const MOSDOp*>(op->get_req());
+ auto m = op->get_req<MOSDOp>();
ObjectContextRef obc = ctx->obc;
const hobject_t& soid = obc->obs.oi.soid;
const uint64_t inb,
const uint64_t outb)
{
- const MOSDOp* const m = static_cast<const MOSDOp*>(op.get_req());
+ auto m = op.get_req<MOSDOp>();
const utime_t now = ceph_clock_now();
const utime_t latency = now - m->get_recv_stamp();
OpRequestRef op,
ThreadPool::TPHandle &handle)
{
- const MOSDPGScan *m = static_cast<const MOSDPGScan*>(op->get_req());
+ auto m = op->get_req<MOSDPGScan>();
ceph_assert(m->get_type() == MSG_OSD_PG_SCAN);
dout(10) << "do_scan " << *m << dendl;
void PrimaryLogPG::do_backfill(OpRequestRef op)
{
- const MOSDPGBackfill *m = static_cast<const MOSDPGBackfill*>(op->get_req());
+ auto m = op->get_req<MOSDPGBackfill>();
ceph_assert(m->get_type() == MSG_OSD_PG_BACKFILL);
dout(10) << "do_backfill " << *m << dendl;
ctx->delta_stats.num_objects > 0) && // FIXME: keys?
(pool.info.has_flag(pg_pool_t::FLAG_FULL) ||
get_osdmap()->test_flag(CEPH_OSDMAP_FULL))) {
- const MOSDOp *m = static_cast<const MOSDOp*>(ctx->op->get_req());
+ auto m = ctx->op->get_req<MOSDOp>();
if (ctx->reqid.name.is_mds() || // FIXME: ignore MDS for now
m->has_flag(CEPH_OSD_FLAG_FULL_FORCE)) {
dout(20) << __func__ << " full, but proceeding due to FULL_FORCE or MDS"
void PrimaryLogPG::complete_read_ctx(int result, OpContext *ctx)
{
- const MOSDOp *m = static_cast<const MOSDOp*>(ctx->op->get_req());
+ auto m = ctx->op->get_req<MOSDOp>();
ceph_assert(ctx->async_reads_complete());
for (vector<OSDOp>::iterator p = ctx->ops->begin();
{
const MOSDOp *m = NULL;
if (repop->op)
- m = static_cast<const MOSDOp *>(repop->op->get_req());
+ m = repop->op->get_req<MOSDOp>();
if (m)
dout(10) << "eval_repop " << *repop << dendl;
void ReplicatedBackend::do_repop_reply(OpRequestRef op)
{
static_cast<MOSDRepOpReply*>(op->get_nonconst_req())->finish_decode();
- const MOSDRepOpReply *r = static_cast<const MOSDRepOpReply *>(op->get_req());
+ auto r = op->get_req<MOSDRepOpReply>();
ceph_assert(r->get_header().type == MSG_OSD_REPOPREPLY);
op->mark_started();
auto iter = in_progress_ops.find(rep_tid);
if (iter != in_progress_ops.end()) {
InProgressOp &ip_op = *iter->second;
- const MOSDOp *m = NULL;
+ const MOSDOp *m = nullptr;
if (ip_op.op)
- m = static_cast<const MOSDOp *>(ip_op.op->get_req());
+ m = ip_op.op->get_req<MOSDOp>();
if (m)
dout(7) << __func__ << ": tid " << ip_op.tid << " op " //<< *m
void ReplicatedBackend::_do_push(OpRequestRef op)
{
- const MOSDPGPush *m = static_cast<const MOSDPGPush *>(op->get_req());
+ auto m = op->get_req<MOSDPGPush>();
ceph_assert(m->get_type() == MSG_OSD_PG_PUSH);
pg_shard_t from = m->from;
void ReplicatedBackend::_do_pull_response(OpRequestRef op)
{
- const MOSDPGPush *m = static_cast<const MOSDPGPush *>(op->get_req());
+ auto m = op->get_req<MOSDPGPush>();
ceph_assert(m->get_type() == MSG_OSD_PG_PUSH);
pg_shard_t from = m->from;
void ReplicatedBackend::do_push_reply(OpRequestRef op)
{
- const MOSDPGPushReply *m = static_cast<const MOSDPGPushReply *>(op->get_req());
+ auto m = op->get_req<MOSDPGPushReply>();
ceph_assert(m->get_type() == MSG_OSD_PG_PUSH_REPLY);
pg_shard_t from = m->from;
void ReplicatedBackend::do_repop(OpRequestRef op)
{
static_cast<MOSDRepOp*>(op->get_nonconst_req())->finish_decode();
- const MOSDRepOp *m = static_cast<const MOSDRepOp *>(op->get_req());
+ auto m = op->get_req<MOSDRepOp>();
int msg_type = m->get_type();
ceph_assert(MSG_OSD_REPOP == msg_type);
rm->committed = true;
// send commit.
- const MOSDRepOp *m = static_cast<const MOSDRepOp*>(rm->op->get_req());
+ auto m = rm->op->get_req<MOSDRepOp>();
ceph_assert(m->get_type() == MSG_OSD_REPOP);
dout(10) << __func__ << " on op " << *m
<< ", sending commit to osd." << rm->ackerosd