From: Sage Weil Date: Fri, 10 Feb 2017 19:05:26 +0000 (-0500) Subject: osd: use new MOSDRepScrubMap message for ScrubMap instead of MOSDSubOp X-Git-Tag: v12.0.2~219^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=42be51d2ab98a7a2b5aad38745947ef42f4bd342;p=ceph.git osd: use new MOSDRepScrubMap message for ScrubMap instead of MOSDSubOp This is one of the last remaining users of MOSDSubOp! Signed-off-by: Sage Weil --- diff --git a/src/messages/MOSDRepScrubMap.h b/src/messages/MOSDRepScrubMap.h new file mode 100644 index 00000000000..f17bb0c2cf3 --- /dev/null +++ b/src/messages/MOSDRepScrubMap.h @@ -0,0 +1,74 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2017 Sage Weil + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#ifndef CEPH_MOSDREPSCRUBMAP_H +#define CEPH_MOSDREPSCRUBMAP_H + +#include "MOSDFastDispatchOp.h" + +/* + * pass a ScrubMap from a shard back to the primary + */ + +struct MOSDRepScrubMap : public MOSDFastDispatchOp { + + static const int HEAD_VERSION = 1; + static const int COMPAT_VERSION = 1; + + spg_t pgid; // primary spg_t + epoch_t map_epoch = 0; + pg_shard_t from; // whose scrubmap this is + bufferlist scrub_map_bl; + + epoch_t get_map_epoch() const override { + return map_epoch; + } + spg_t get_spg() const override { + return pgid; + } + + MOSDRepScrubMap() + : MOSDFastDispatchOp(MSG_OSD_REP_SCRUBMAP, HEAD_VERSION, COMPAT_VERSION) {} + + MOSDRepScrubMap(spg_t pgid, epoch_t map_epoch, pg_shard_t from) + : MOSDFastDispatchOp(MSG_OSD_REP_SCRUBMAP, HEAD_VERSION, COMPAT_VERSION), + pgid(pgid), + map_epoch(map_epoch), + from(from) {} + +private: + ~MOSDRepScrubMap() {} + +public: + const char *get_type_name() const { return "rep_scrubmap"; } + void print(ostream& out) const { + out << "rep_scrubmap(" << pgid << " e" << map_epoch + << " from shard " << from << ")"; + } + + void encode_payload(uint64_t features) { + ::encode(pgid, payload); + ::encode(map_epoch, payload); + ::encode(from, payload); + } + void decode_payload() { + bufferlist::iterator p = payload.begin(); + ::decode(pgid, p); + ::decode(map_epoch, p); + ::decode(from, p); + } +}; + + +#endif diff --git a/src/msg/Message.cc b/src/msg/Message.cc index fa284a4cc32..39b0575ff65 100644 --- a/src/msg/Message.cc +++ b/src/msg/Message.cc @@ -82,6 +82,7 @@ using namespace std; #include "messages/MOSDPGTrim.h" #include "messages/MOSDScrub.h" #include "messages/MOSDRepScrub.h" +#include "messages/MOSDRepScrubMap.h" #include "messages/MOSDPGScan.h" #include "messages/MOSDPGBackfill.h" #include "messages/MOSDBackoff.h" @@ -516,6 +517,9 @@ Message *decode_message(CephContext *cct, int crcflags, case MSG_OSD_REP_SCRUB: m = new MOSDRepScrub; break; + case MSG_OSD_REP_SCRUBMAP: + m = new MOSDRepScrubMap; + break; case MSG_OSD_PG_SCAN: m = new MOSDPGScan; break; diff --git a/src/msg/Message.h b/src/msg/Message.h index bffd8ebc50b..f5e5acc6866 100644 --- a/src/msg/Message.h +++ b/src/msg/Message.h @@ -116,6 +116,7 @@ #define MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY 115 #define MSG_OSD_PG_CREATED 116 +#define MSG_OSD_REP_SCRUBMAP 117 // *** MDS *** diff --git a/src/osd/OSD.h b/src/osd/OSD.h index c4dbfe35d13..2f14e049f6d 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -2337,6 +2337,7 @@ protected: case MSG_OSD_EC_READ: case MSG_OSD_EC_READ_REPLY: case MSG_OSD_REP_SCRUB: + case MSG_OSD_REP_SCRUBMAP: case MSG_OSD_PG_UPDATE_LOG_MISSING: case MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY: return true; diff --git a/src/osd/PG.cc b/src/osd/PG.cc index cf686874f17..477e00e9c37 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -54,6 +54,8 @@ #include "messages/MOSDRepOp.h" #include "messages/MOSDSubOpReply.h" #include "messages/MOSDRepOpReply.h" +#include "messages/MOSDRepScrubMap.h" + #include "common/BackTrace.h" #include "common/EventTrace.h" @@ -3637,8 +3639,39 @@ void PG::unreg_next_scrub() } } +void PG::do_replica_scrub_map(OpRequestRef op) +{ + const MOSDRepScrubMap *m = static_cast(op->get_req()); + dout(7) << __func__ << " " << *m << dendl; + if (m->map_epoch < info.history.same_interval_since) { + dout(10) << __func__ << " discarding old from " + << m->map_epoch << " < " << info.history.same_interval_since + << dendl; + return; + } + if (!scrubber.is_chunky_scrub_active()) { + dout(10) << __func__ << " scrub isn't active" << dendl; + return; + } + + op->mark_started(); + + bufferlist::iterator p = const_cast(m->get_data()).begin(); + scrubber.received_maps[m->from].decode(p, info.pgid.pool()); + dout(10) << "map version is " + << scrubber.received_maps[m->from].valid_through + << dendl; + + --scrubber.waiting_on; + scrubber.waiting_on_whom.erase(m->from); + if (scrubber.waiting_on == 0) { + requeue_scrub(); + } +} + void PG::sub_op_scrub_map(OpRequestRef op) { + // for legacy jewel compatibility only const MOSDSubOp *m = static_cast(op->get_req()); assert(m->get_type() == MSG_OSD_SUBOP); dout(7) << "sub_op_scrub_map" << dendl; @@ -4076,24 +4109,33 @@ void PG::replica_scrub( map, start, end, msg->deep, msg->seed, handle); - vector scrub(1); - scrub[0].op.op = CEPH_OSD_OP_SCRUB_MAP; - hobject_t poid; - eversion_t v; - osd_reqid_t reqid; - MOSDSubOp *subop = new MOSDSubOp( - reqid, - pg_whoami, - spg_t(info.pgid.pgid, get_primary().shard), - poid, - 0, - msg->map_epoch, - osd->get_tid(), - v); - ::encode(map, subop->get_data()); - subop->ops = scrub; - - osd->send_message_osd_cluster(subop, msg->get_connection()); + if (HAVE_FEATURE(acting_features, SERVER_LUMINOUS)) { + MOSDRepScrubMap *reply = new MOSDRepScrubMap( + spg_t(info.pgid.pgid, get_primary().shard), + msg->map_epoch, + pg_whoami); + ::encode(map, reply->get_data()); + osd->send_message_osd_cluster(reply, msg->get_connection()); + } else { + // for jewel compatibility + vector scrub(1); + scrub[0].op.op = CEPH_OSD_OP_SCRUB_MAP; + hobject_t poid; + eversion_t v; + osd_reqid_t reqid; + MOSDSubOp *subop = new MOSDSubOp( + reqid, + pg_whoami, + spg_t(info.pgid.pgid, get_primary().shard), + poid, + 0, + msg->map_epoch, + osd->get_tid(), + v); + ::encode(map, subop->get_data()); + subop->ops = scrub; + osd->send_message_osd_cluster(subop, msg->get_connection()); + } } /* Scrub: @@ -5503,6 +5545,8 @@ bool PG::can_discard_request(OpRequestRef& op) return can_discard_replica_op(op); case MSG_OSD_REP_SCRUB: return can_discard_replica_op(op); + case MSG_OSD_REP_SCRUBMAP: + return can_discard_replica_op(op); case MSG_OSD_PG_UPDATE_LOG_MISSING: return can_discard_replica_op< MOSDPGUpdateLogMissing, MSG_OSD_PG_UPDATE_LOG_MISSING>(op); @@ -5607,6 +5651,11 @@ bool PG::op_must_wait_for_map(epoch_t cur_epoch, OpRequestRef& op) cur_epoch, static_cast(op->get_req())->map_epoch); + case MSG_OSD_REP_SCRUBMAP: + return !have_same_or_newer_map( + cur_epoch, + static_cast(op->get_req())->map_epoch); + case MSG_OSD_PG_UPDATE_LOG_MISSING: return !have_same_or_newer_map( cur_epoch, diff --git a/src/osd/PG.h b/src/osd/PG.h index e739d70405a..3aa4776785a 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1332,6 +1332,7 @@ public: void replica_scrub( OpRequestRef op, ThreadPool::TPHandle &handle); + void do_replica_scrub_map(OpRequestRef op); void sub_op_scrub_map(OpRequestRef op); void sub_op_scrub_reserve(OpRequestRef op); void sub_op_scrub_reserve_reply(OpRequestRef op); diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index b026d969c1b..1481b4104bb 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -1689,6 +1689,10 @@ void PrimaryLogPG::do_request( replica_scrub(op, handle); break; + case MSG_OSD_REP_SCRUBMAP: + do_replica_scrub_map(op); + break; + case MSG_OSD_PG_UPDATE_LOG_MISSING: do_update_log_missing(op); break;