]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: use new MOSDRepScrubMap message for ScrubMap instead of MOSDSubOp
authorSage Weil <sage@redhat.com>
Fri, 10 Feb 2017 19:05:26 +0000 (14:05 -0500)
committerSage Weil <sage@redhat.com>
Fri, 31 Mar 2017 18:42:11 +0000 (14:42 -0400)
This is one of the last remaining users of MOSDSubOp!

Signed-off-by: Sage Weil <sage@redhat.com>
src/messages/MOSDRepScrubMap.h [new file with mode: 0644]
src/msg/Message.cc
src/msg/Message.h
src/osd/OSD.h
src/osd/PG.cc
src/osd/PG.h
src/osd/PrimaryLogPG.cc

diff --git a/src/messages/MOSDRepScrubMap.h b/src/messages/MOSDRepScrubMap.h
new file mode 100644 (file)
index 0000000..f17bb0c
--- /dev/null
@@ -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 <sage@redhat.com>
+ *
+ * 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
index fa284a4cc3226fca33c2c1a5d4bc9f9e5607b21a..39b0575ff655cd8beca31ea96e893010bf0275cf 100644 (file)
@@ -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;
index bffd8ebc50be27375266f5ce68e6c0e47f8948f2..f5e5acc686631198b8ca13428db8d6df6f7403dc 100644 (file)
 #define MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY  115
 
 #define MSG_OSD_PG_CREATED      116
+#define MSG_OSD_REP_SCRUBMAP    117
 
 // *** MDS ***
 
index c4dbfe35d137c627ce4c2dee58af5e7829012d2d..2f14e049f6d8f49c0ed69a279b9688ecae8398d7 100644 (file)
@@ -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;
index cf686874f17499509e4c6af5ed2fb1022520e92d..477e00e9c372fce40f6db7e630756efab5458ede 100644 (file)
@@ -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<const MOSDRepScrubMap*>(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<bufferlist&>(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<const MOSDSubOp *>(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<OSDOp> 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<OSDOp> 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<MOSDECSubOpReadReply, MSG_OSD_EC_READ_REPLY>(op);
   case MSG_OSD_REP_SCRUB:
     return can_discard_replica_op<MOSDRepScrub, MSG_OSD_REP_SCRUB>(op);
+  case MSG_OSD_REP_SCRUBMAP:
+    return can_discard_replica_op<MOSDRepScrubMap, MSG_OSD_REP_SCRUBMAP>(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<const MOSDRepScrub*>(op->get_req())->map_epoch);
 
+  case MSG_OSD_REP_SCRUBMAP:
+    return !have_same_or_newer_map(
+      cur_epoch,
+      static_cast<const MOSDRepScrubMap*>(op->get_req())->map_epoch);
+
   case MSG_OSD_PG_UPDATE_LOG_MISSING:
     return !have_same_or_newer_map(
       cur_epoch,
index e739d70405a100512e58d403b71a60e9f44aad4a..3aa4776785ae554577bee0e9c0c232f99e8a6836 100644 (file)
@@ -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);
index b026d969c1b22ce6b0296b7d457d0d71f510a40a..1481b4104bb2ce7e282372b7fbe309f308059608 100644 (file)
@@ -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;