]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
message, osd: add request/response messages for deletes during recovery
authorJosh Durgin <jdurgin@redhat.com>
Sat, 24 Jun 2017 02:28:24 +0000 (22:28 -0400)
committerJosh Durgin <jdurgin@redhat.com>
Mon, 17 Jul 2017 06:00:35 +0000 (02:00 -0400)
The existing BackfillRemove message has no reply, and PushOps have too
much logic that would need changing to accomodate deletions.

Signed-off-by: Josh Durgin <jdurgin@redhat.com>
src/messages/MOSDPGRecoveryDelete.h [new file with mode: 0644]
src/messages/MOSDPGRecoveryDeleteReply.h [new file with mode: 0644]
src/msg/Message.cc
src/msg/Message.h
src/osd/ECBackend.cc
src/osd/OSD.h
src/osd/PG.cc
src/osd/ReplicatedBackend.cc
src/test/encoding/types.h

diff --git a/src/messages/MOSDPGRecoveryDelete.h b/src/messages/MOSDPGRecoveryDelete.h
new file mode 100644 (file)
index 0000000..ae768fd
--- /dev/null
@@ -0,0 +1,81 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_MOSDPGRECOVERYDELETE_H
+#define CEPH_MOSDPGRECOVERYDELETE_H
+
+#include "MOSDFastDispatchOp.h"
+
+/*
+ * instruct non-primary to remove some objects during recovery
+ */
+
+struct MOSDPGRecoveryDelete : public MOSDFastDispatchOp {
+
+  static const int HEAD_VERSION = 1;
+  static const int COMPAT_VERSION = 1;
+
+  pg_shard_t from;
+  spg_t pgid;            ///< target spg_t
+  epoch_t map_epoch;
+  list<pair<hobject_t, eversion_t> > objects;    ///< objects to remove
+
+private:
+  uint64_t cost;
+
+public:
+  int get_cost() const override {
+    return cost;
+  }
+
+  epoch_t get_map_epoch() const override {
+    return map_epoch;
+  }
+  spg_t get_spg() const override {
+    return pgid;
+  }
+
+  void set_cost(uint64_t c) {
+    cost = c;
+  }
+
+  MOSDPGRecoveryDelete()
+    : MOSDFastDispatchOp(MSG_OSD_PG_RECOVERY_DELETE, HEAD_VERSION,
+                       COMPAT_VERSION) {}
+
+  MOSDPGRecoveryDelete(pg_shard_t from, spg_t pgid, epoch_t map_epoch)
+    : MOSDFastDispatchOp(MSG_OSD_PG_RECOVERY_DELETE, HEAD_VERSION,
+                        COMPAT_VERSION),
+      from(from),
+      pgid(pgid),
+      map_epoch(map_epoch) {}
+
+private:
+  ~MOSDPGRecoveryDelete() {}
+
+public:
+  const char *get_type_name() const { return "recovery_delete"; }
+  void print(ostream& out) const {
+    out << "MOSDPGRecoveryDelete(" << pgid << " e" << map_epoch << " " << objects << ")";
+  }
+
+  void encode_payload(uint64_t features) {
+    ::encode(from, payload);
+    ::encode(pgid, payload);
+    ::encode(map_epoch, payload);
+    ::encode(cost, payload);
+    ::encode(objects, payload);
+  }
+  void decode_payload() {
+    bufferlist::iterator p = payload.begin();
+    ::decode(from, p);
+    ::decode(pgid, p);
+    ::decode(map_epoch, p);
+    ::decode(cost, p);
+    ::decode(objects, p);
+  }
+};
+
+
+
+#endif
diff --git a/src/messages/MOSDPGRecoveryDeleteReply.h b/src/messages/MOSDPGRecoveryDeleteReply.h
new file mode 100644 (file)
index 0000000..4732c8f
--- /dev/null
@@ -0,0 +1,54 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef MOSDRECOVERYDELETEREPLY_H
+#define MOSDRECOVERYDELETEREPLY_H
+
+#include "MOSDFastDispatchOp.h"
+
+struct MOSDPGRecoveryDeleteReply : public MOSDFastDispatchOp {
+  static const int HEAD_VERSION = 1;
+  static const int COMPAT_VERSION = 1;
+
+  pg_shard_t from;
+  spg_t pgid;
+  epoch_t map_epoch;
+  list<pair<hobject_t, eversion_t> > objects;
+
+  epoch_t get_map_epoch() const override {
+    return map_epoch;
+  }
+  spg_t get_spg() const override {
+    return pgid;
+  }
+
+  MOSDPGRecoveryDeleteReply()
+    : MOSDFastDispatchOp(MSG_OSD_PG_RECOVERY_DELETE_REPLY, HEAD_VERSION, COMPAT_VERSION)
+    {}
+
+  void decode_payload() override {
+    bufferlist::iterator p = payload.begin();
+    ::decode(pgid.pgid, p);
+    ::decode(map_epoch, p);
+    ::decode(objects, p);
+    ::decode(pgid.shard, p);
+    ::decode(from, p);
+  }
+
+  void encode_payload(uint64_t features) override {
+    ::encode(pgid.pgid, payload);
+    ::encode(map_epoch, payload);
+    ::encode(objects, payload);
+    ::encode(pgid.shard, payload);
+    ::encode(from, payload);
+  }
+
+  void print(ostream& out) const override {
+    out << "MOSDPGRecoveryDeleteReply(" << pgid
+        << " e" << map_epoch << " " << objects << ")";
+  }
+
+  const char *get_type_name() const override { return "recovery_delete_reply"; }
+};
+
+#endif
index 9d1953d75b195de2cba073061fa21be408294198..478ed46f8b6e029dfcb522f34eeab95af2aaec51 100644 (file)
@@ -88,6 +88,8 @@ using namespace std;
 #include "messages/MOSDPGBackfill.h"
 #include "messages/MOSDBackoff.h"
 #include "messages/MOSDPGBackfillRemove.h"
+#include "messages/MOSDPGRecoveryDelete.h"
+#include "messages/MOSDPGRecoveryDeleteReply.h"
 
 #include "messages/MRemoveSnaps.h"
 
@@ -545,6 +547,12 @@ Message *decode_message(CephContext *cct, int crcflags,
   case MSG_OSD_PG_PUSH_REPLY:
     m = new MOSDPGPushReply;
     break;
+  case MSG_OSD_PG_RECOVERY_DELETE:
+    m = new MOSDPGRecoveryDelete;
+    break;
+  case MSG_OSD_PG_RECOVERY_DELETE_REPLY:
+    m = new MOSDPGRecoveryDeleteReply;
+    break;
   case MSG_OSD_EC_WRITE:
     m = new MOSDECSubOpWrite;
     break;
index d1b63ac1f21994edaab9e0c99f2c4c0a47724242..94b626b89570760f457948fe2d65017856d90b19 100644 (file)
 
 #define MSG_OSD_PG_CREATED      116
 #define MSG_OSD_REP_SCRUBMAP    117
+#define MSG_OSD_PG_RECOVERY_DELETE 118
+#define MSG_OSD_PG_RECOVERY_DELETE_REPLY 119
 
 // *** MDS ***
 
index 166edc65996f96749c497ff7e68ee5f1cec527ea..38da163fef3cf8e642ad31a7599b4efc494b0600 100644 (file)
@@ -734,9 +734,16 @@ int ECBackend::recover_object(
 }
 
 bool ECBackend::can_handle_while_inactive(
-  OpRequestRef _op)
+  OpRequestRef op)
 {
-  return false;
+  dout(10) << __func__ << ": " << op << dendl;
+  switch (op->get_req()->get_type()) {
+  case MSG_OSD_PG_RECOVERY_DELETE:
+  case MSG_OSD_PG_RECOVERY_DELETE_REPLY:
+    return true;
+  default:
+    return false;
+  }
 }
 
 bool ECBackend::handle_message(
index c34e247e44402822a9f523386acda84fc9014cd4..0dd8a563705795c731ad8c2ac2a542ec408e32eb 100644 (file)
@@ -2300,6 +2300,8 @@ private:
     case MSG_OSD_REP_SCRUBMAP:
     case MSG_OSD_PG_UPDATE_LOG_MISSING:
     case MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY:
+    case MSG_OSD_PG_RECOVERY_DELETE:
+    case MSG_OSD_PG_RECOVERY_DELETE_REPLY:
       return true;
     default:
       return false;
index 05ad63c69c121e55205399aeb2a9a65721dd5af9..ce3f52e9cab35bede4fdd6e6aaf8b0804c683d01 100644 (file)
@@ -55,6 +55,8 @@
 #include "messages/MOSDSubOpReply.h"
 #include "messages/MOSDRepOpReply.h"
 #include "messages/MOSDRepScrubMap.h"
+#include "messages/MOSDPGRecoveryDelete.h"
+#include "messages/MOSDPGRecoveryDeleteReply.h"
 
 #include "common/BackTrace.h"
 #include "common/EventTrace.h"
@@ -5689,6 +5691,11 @@ bool PG::can_discard_request(OpRequestRef& op)
     return can_discard_replica_op<MOSDSubOpReply, MSG_OSD_SUBOPREPLY>(op);
   case MSG_OSD_REPOPREPLY:
     return can_discard_replica_op<MOSDRepOpReply, MSG_OSD_REPOPREPLY>(op);
+  case MSG_OSD_PG_RECOVERY_DELETE:
+    return can_discard_replica_op<MOSDPGRecoveryDelete, MSG_OSD_PG_RECOVERY_DELETE>(op);
+
+  case MSG_OSD_PG_RECOVERY_DELETE_REPLY:
+    return can_discard_replica_op<MOSDPGRecoveryDeleteReply, MSG_OSD_PG_RECOVERY_DELETE_REPLY>(op);
 
   case MSG_OSD_EC_WRITE:
     return can_discard_replica_op<MOSDECSubOpWrite, MSG_OSD_EC_WRITE>(op);
index 7739602aeefe74d552c0087015d00528f2f0a522..092d0eeb6ed78b9252f744ab733b10037414075b 100644 (file)
@@ -185,6 +185,8 @@ bool ReplicatedBackend::can_handle_while_inactive(OpRequestRef op)
   dout(10) << __func__ << ": " << op << dendl;
   switch (op->get_req()->get_type()) {
   case MSG_OSD_PG_PULL:
+  case MSG_OSD_PG_RECOVERY_DELETE:
+  case MSG_OSD_PG_RECOVERY_DELETE_REPLY:
     return true;
   default:
     return false;
index d8822b487a7a5bede4f8f454e342fb6d0a3e288d..96fcd1747a8e5b6813beef24bae5d0d802152087 100644 (file)
@@ -593,6 +593,10 @@ MESSAGE(MOSDPGNotify)
 MESSAGE(MOSDPGQuery)
 #include "messages/MOSDPGRemove.h"
 MESSAGE(MOSDPGRemove)
+#include "messages/MOSDPGRecoveryDelete.h"
+MESSAGE(MOSDPGRecoveryDelete)
+#include "messages/MOSDPGRecoveryDeleteReply.h"
+MESSAGE(MOSDPGRecoveryDeleteReply)
 #include "messages/MOSDPGScan.h"
 MESSAGE(MOSDPGScan)
 #include "messages/MOSDPGTemp.h"