]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
messages/MOSDBackoff: add spg_t to message
authorSage Weil <sage@redhat.com>
Mon, 13 Feb 2017 03:47:31 +0000 (22:47 -0500)
committerSage Weil <sage@redhat.com>
Tue, 14 Feb 2017 04:03:52 +0000 (23:03 -0500)
and make it an MOSDFastDispatchOp.

Signed-off-by: Sage Weil <sage@redhat.com>
src/messages/MOSDBackoff.h
src/osd/OSD.cc
src/osd/PG.cc
src/osdc/Objecter.cc

index e501269b7ef76bb071bb03e12f8eb6268c1edf1f..181aaf181b900ce9a0db8b84b5762b5efff03c86 100644 (file)
 #ifndef CEPH_MOSDBACKOFF_H
 #define CEPH_MOSDBACKOFF_H
 
-#include "msg/Message.h"
+#include "MOSDFastDispatchOp.h"
 #include "osd/osd_types.h"
 
-class MOSDBackoff : public Message {
+class MOSDBackoff : public MOSDFastDispatchOp {
 public:
+  const int HEAD_VERSION = 1;
+  const int COMPAT_VERSION = 1;
+
+  spg_t pgid;
+  epoch_t map_epoch = 0;
   uint8_t op = 0;           ///< CEPH_OSD_BACKOFF_OP_*
   uint64_t id = 0;          ///< unique id within this session
   hobject_t begin, end;     ///< [) range to block, unless ==, block single obj
-  epoch_t osd_epoch = 0;
 
-  MOSDBackoff() : Message(CEPH_MSG_OSD_BACKOFF) {}
-  MOSDBackoff(uint8_t op_, uint64_t id_,
-             hobject_t begin_, hobject_t end_, epoch_t ep)
-    : Message(CEPH_MSG_OSD_BACKOFF),
+  spg_t get_spg() const override {
+    return pgid;
+  }
+  epoch_t get_map_epoch() const override {
+    return map_epoch;
+  }
+
+  MOSDBackoff()
+    : MOSDFastDispatchOp(CEPH_MSG_OSD_BACKOFF, HEAD_VERSION, COMPAT_VERSION) {}
+  MOSDBackoff(spg_t pgid_, epoch_t ep, uint8_t op_, uint64_t id_,
+             hobject_t begin_, hobject_t end_)
+    : MOSDFastDispatchOp(CEPH_MSG_OSD_BACKOFF, HEAD_VERSION, COMPAT_VERSION),
+      pgid(pgid_),
+      map_epoch(ep),
       op(op_),
       id(id_),
       begin(begin_),
-      end(end_),
-      osd_epoch(ep) { }
+      end(end_) { }
 
   void encode_payload(uint64_t features) override {
+    ::encode(pgid, payload);
+    ::encode(map_epoch, payload);
     ::encode(op, payload);
     ::encode(id, payload);
     ::encode(begin, payload);
     ::encode(end, payload);
-    ::encode(osd_epoch, payload);
   }
 
   void decode_payload() override {
     auto p = payload.begin();
+    ::decode(pgid, p);
+    ::decode(map_epoch, p);
     ::decode(op, p);
     ::decode(id, p);
     ::decode(begin, p);
     ::decode(end, p);
-    ::decode(osd_epoch, p);
   }
 
   const char *get_type_name() const override { return "osd_backoff"; }
 
   void print(ostream& out) const override {
-    out << "osd_backoff(" << ceph_osd_backoff_op_name(op)
+    out << "osd_backoff(" << pgid << " " << ceph_osd_backoff_op_name(op)
        << " id " << id
        << " [" << begin << "," << end << ")"
-       << " epoch " << osd_epoch << ")";
+       << " e" << map_epoch << ")";
   }
 };
 
index 92db3419e8cd467713f3700587b26b8421f43a83..fad41ca28688b7210328b2a022ad91f66468b7e1 100644 (file)
@@ -6308,7 +6308,7 @@ epoch_t op_required_epoch(OpRequestRef op)
   }
   case CEPH_MSG_OSD_BACKOFF: {
     MOSDBackoff *m = static_cast<MOSDBackoff*>(op->get_req());
-    return m->osd_epoch;
+    return m->map_epoch;
   }
   case MSG_OSD_SUBOP:
     return replica_op_required_epoch<MOSDSubOp, MSG_OSD_SUBOP>(op);
index 1f5e5a74a3a8761c4f15b508e3d2b38def2bc7e9..8cab55fb7b4aab9f1b3de564f223831535d65bcf 100644 (file)
@@ -2325,11 +2325,12 @@ void PG::add_backoff(SessionRef s, const hobject_t& begin, const hobject_t& end)
   }
   con->send_message(
     new MOSDBackoff(
+      info.pgid,
+      get_osdmap()->get_epoch(),
       CEPH_OSD_BACKOFF_OP_BLOCK,
       b->id,
       begin,
-      end,
-      get_osdmap()->get_epoch()));
+      end));
 }
 
 void PG::release_backoffs(const hobject_t& begin, const hobject_t& end)
@@ -2376,11 +2377,12 @@ void PG::release_backoffs(const hobject_t& begin, const hobject_t& end)
       if (con) {   // OSD::ms_handle_reset clears s->con without a lock
        con->send_message(
          new MOSDBackoff(
+           info.pgid,
+           get_osdmap()->get_epoch(),
            CEPH_OSD_BACKOFF_OP_UNBLOCK,
            b->id,
            b->begin,
-           b->end,
-           get_osdmap()->get_epoch()));
+           b->end));
       }
       if (b->is_new()) {
        b->state = Backoff::STATE_DELETING;
index 10b4c15129332fde9e37ea877181681d0f55760c..a23c783467f58c45cd7db639b8020739cb6ee6ef 100644 (file)
@@ -3429,10 +3429,12 @@ void Objecter::handle_osd_backoff(MOSDBackoff *m)
       b.begin = m->begin;
       b.end = m->end;
 
-      // ack
-      Message *r = new MOSDBackoff(CEPH_OSD_BACKOFF_OP_ACK_BLOCK,
-                                  m->id, m->begin, m->end,
-                                  osdmap->get_epoch());
+      // ack with original backoff's epoch so that the osd can discard this if
+      // there was a pg split.
+      Message *r = new MOSDBackoff(m->pgid,
+                                  m->map_epoch,
+                                  CEPH_OSD_BACKOFF_OP_ACK_BLOCK,
+                                  m->id, m->begin, m->end);
       // this priority must match the MOSDOps from _prepare_osd_op
       r->set_priority(cct->_conf->osd_client_op_priority);
       con->send_message(r);