]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: use new MOSDPGBackfillRemove instead of MOSDSubOp
authorSage Weil <sage@redhat.com>
Mon, 13 Feb 2017 18:53:59 +0000 (13:53 -0500)
committerSage Weil <sage@redhat.com>
Fri, 31 Mar 2017 18:41:42 +0000 (14:41 -0400)
One of the last remaining MOSDSubOp users!

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

diff --git a/src/messages/MOSDPGBackfillRemove.h b/src/messages/MOSDPGBackfillRemove.h
new file mode 100644 (file)
index 0000000..3f3c896
--- /dev/null
@@ -0,0 +1,75 @@
+// -*- 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_MOSDPGBACKFILLREMOVE_H
+#define CEPH_MOSDPGBACKFILLREMOVE_H
+
+#include "MOSDFastDispatchOp.h"
+
+/*
+ * instruct non-primary to remove some objects during backfill
+ */
+
+struct MOSDPGBackfillRemove : public MOSDFastDispatchOp {
+
+  static const int HEAD_VERSION = 1;
+  static const int COMPAT_VERSION = 1;
+
+  spg_t pgid;            ///< target spg_t
+  epoch_t map_epoch = 0;
+  list<pair<hobject_t,eversion_t>> ls;    ///< objects to remove
+
+  epoch_t get_map_epoch() const override {
+    return map_epoch;
+  }
+  spg_t get_spg() const override {
+    return pgid;
+  }
+
+  MOSDPGBackfillRemove()
+    : MOSDFastDispatchOp(MSG_OSD_PG_BACKFILL_REMOVE, HEAD_VERSION,
+                       COMPAT_VERSION) {}
+
+  MOSDPGBackfillRemove(spg_t pgid, epoch_t map_epoch)
+    : MOSDFastDispatchOp(MSG_OSD_PG_BACKFILL_REMOVE, HEAD_VERSION,
+                        COMPAT_VERSION),
+      pgid(pgid),
+      map_epoch(map_epoch) {}
+
+private:
+  ~MOSDPGBackfillRemove() {}
+
+public:
+  const char *get_type_name() const { return "backfill_remove"; }
+  void print(ostream& out) const {
+    out << "backfill_remove(" << pgid << " e" << map_epoch
+       << " " << ls << ")";
+  }
+
+  void encode_payload(uint64_t features) {
+    ::encode(pgid, payload);
+    ::encode(map_epoch, payload);
+    ::encode(ls, payload);
+  }
+  void decode_payload() {
+    bufferlist::iterator p = payload.begin();
+    ::decode(pgid, p);
+    ::decode(map_epoch, p);
+    ::decode(ls, p);
+  }
+};
+
+
+
+#endif
index c80ddf0fe00f3b5920ca8fb0a5e2fed28b6c635c..fa284a4cc3226fca33c2c1a5d4bc9f9e5607b21a 100644 (file)
@@ -85,6 +85,7 @@ using namespace std;
 #include "messages/MOSDPGScan.h"
 #include "messages/MOSDPGBackfill.h"
 #include "messages/MOSDBackoff.h"
+#include "messages/MOSDPGBackfillRemove.h"
 
 #include "messages/MRemoveSnaps.h"
 
@@ -521,6 +522,9 @@ Message *decode_message(CephContext *cct, int crcflags,
   case MSG_OSD_PG_BACKFILL:
     m = new MOSDPGBackfill;
     break;
+  case MSG_OSD_PG_BACKFILL_REMOVE:
+    m = new MOSDPGBackfillRemove;
+    break;
   case MSG_OSD_PG_PUSH:
     m = new MOSDPGPush;
     break;
index a3c3ffa4b0707ea49d07afdb636fb69f2d6c5e14..bffd8ebc50be27375266f5ce68e6c0e47f8948f2 100644 (file)
@@ -93,6 +93,7 @@
 
 #define MSG_OSD_PG_SCAN        94
 #define MSG_OSD_PG_BACKFILL    95
+#define MSG_OSD_PG_BACKFILL_REMOVE 96
 
 #define MSG_COMMAND            97
 #define MSG_COMMAND_REPLY      98
index 7efcd376cb4af6185a0da447f46bffafaa616702..c4dbfe35d137c627ce4c2dee58af5e7829012d2d 100644 (file)
@@ -2331,6 +2331,7 @@ protected:
     case MSG_OSD_PG_PUSH_REPLY:
     case MSG_OSD_PG_SCAN:
     case MSG_OSD_PG_BACKFILL:
+    case MSG_OSD_PG_BACKFILL_REMOVE:
     case MSG_OSD_EC_WRITE:
     case MSG_OSD_EC_WRITE_REPLY:
     case MSG_OSD_EC_READ:
index 8c5976b0a63c9f6e757a48f32cc437427c328156..cf686874f17499509e4c6af5ed2fb1022520e92d 100644 (file)
@@ -36,6 +36,7 @@
 #include "messages/MOSDPGTrim.h"
 #include "messages/MOSDPGScan.h"
 #include "messages/MOSDPGBackfill.h"
+#include "messages/MOSDPGBackfillRemove.h"
 #include "messages/MBackfillReserve.h"
 #include "messages/MRecoveryReserve.h"
 #include "messages/MOSDPGPush.h"
@@ -5513,6 +5514,9 @@ bool PG::can_discard_request(OpRequestRef& op)
     return can_discard_scan(op);
   case MSG_OSD_PG_BACKFILL:
     return can_discard_backfill(op);
+  case MSG_OSD_PG_BACKFILL_REMOVE:
+    return can_discard_replica_op<MOSDPGBackfillRemove,
+                                 MSG_OSD_PG_BACKFILL_REMOVE>(op);
   }
   return true;
 }
@@ -5558,6 +5562,11 @@ bool PG::op_must_wait_for_map(epoch_t cur_epoch, OpRequestRef& op)
       cur_epoch,
       static_cast<const MOSDPGBackfill*>(op->get_req())->map_epoch);
 
+  case MSG_OSD_PG_BACKFILL_REMOVE:
+    return !have_same_or_newer_map(
+      cur_epoch,
+      static_cast<const MOSDPGBackfillRemove*>(op->get_req())->map_epoch);
+
   case MSG_OSD_PG_PUSH:
     return !have_same_or_newer_map(
       cur_epoch,
index c64ba07a477b3b460591510e748108e13f71ff40..b026d969c1b22ce6b0296b7d457d0d71f510a40a 100644 (file)
@@ -37,6 +37,7 @@
 #include "messages/MOSDPGScan.h"
 #include "messages/MOSDRepScrub.h"
 #include "messages/MOSDPGBackfill.h"
+#include "messages/MOSDPGBackfillRemove.h"
 #include "messages/MOSDPGUpdateLogMissing.h"
 #include "messages/MOSDPGUpdateLogMissingReply.h"
 #include "messages/MCommandReply.h"
@@ -1680,6 +1681,10 @@ void PrimaryLogPG::do_request(
     do_backfill(op);
     break;
 
+  case MSG_OSD_PG_BACKFILL_REMOVE:
+    do_backfill_remove(op);
+    break;
+
   case MSG_OSD_REP_SCRUB:
     replica_scrub(op, handle);
     break;
@@ -3405,6 +3410,23 @@ void PrimaryLogPG::do_backfill(OpRequestRef op)
   }
 }
 
+void PrimaryLogPG::do_backfill_remove(OpRequestRef op)
+{
+  const MOSDPGBackfillRemove *m = static_cast<const MOSDPGBackfillRemove*>(
+    op->get_req());
+  assert(m->get_type() == MSG_OSD_PG_BACKFILL_REMOVE);
+  dout(7) << __func__ << " " << m->ls << dendl;
+
+  op->mark_started();
+
+  ObjectStore::Transaction t;
+  for (auto& p : m->ls) {
+    remove_snap_mapped_object(t, p.first);
+  }
+  int r = osd->store->queue_transaction(osr.get(), std::move(t), NULL);
+  assert(r == 0);
+}
+
 PrimaryLogPG::OpContextUPtr PrimaryLogPG::trim_object(bool first, const hobject_t &coid)
 {
   // load clone info
@@ -11016,14 +11038,43 @@ uint64_t PrimaryLogPG::recover_backfill(
     add_object_context_to_pg_stat(obc, &stat);
     pending_backfill_updates[*i] = stat;
   }
-  for (unsigned i = 0; i < to_remove.size(); ++i) {
-    handle.reset_tp_timeout();
+  if (HAVE_FEATURE(get_min_upacting_features(), SERVER_LUMINOUS)) {
+    map<pg_shard_t,MOSDPGBackfillRemove*> reqs;
+    for (unsigned i = 0; i < to_remove.size(); ++i) {
+      handle.reset_tp_timeout();
+      const hobject_t& oid = to_remove[i].get<0>();
+      eversion_t v = to_remove[i].get<1>();
+      pg_shard_t peer = to_remove[i].get<2>();
+      MOSDPGBackfillRemove *m;
+      auto it = reqs.find(peer);
+      if (it != reqs.end()) {
+       m = it->second;
+      } else {
+       m = reqs[peer] = new MOSDPGBackfillRemove(
+         spg_t(info.pgid.pgid, peer.shard),
+         get_osdmap()->get_epoch());
+      }
+      m->ls.push_back(make_pair(oid, v));
 
-    // ordered before any subsequent updates
-    send_remove_op(to_remove[i].get<0>(), to_remove[i].get<1>(), to_remove[i].get<2>());
+      if (oid <= last_backfill_started)
+       pending_backfill_updates[oid]; // add empty stat!
+    }
+    for (auto p : reqs) {
+      osd->send_message_osd_cluster(p.first.osd, p.second,
+                                   get_osdmap()->get_epoch());
+    }
+  } else {
+    // for jewel targets
+    for (unsigned i = 0; i < to_remove.size(); ++i) {
+      handle.reset_tp_timeout();
+
+      // ordered before any subsequent updates
+      send_remove_op(to_remove[i].get<0>(), to_remove[i].get<1>(),
+                    to_remove[i].get<2>());
 
-    if (to_remove[i].get<0>() <= last_backfill_started)
-      pending_backfill_updates[to_remove[i].get<0>()]; // add empty stat!
+      if (to_remove[i].get<0>() <= last_backfill_started)
+       pending_backfill_updates[to_remove[i].get<0>()]; // add empty stat!
+    }
   }
 
   PGBackend::RecoveryHandle *h = pgbackend->open_recovery_op();
index d64c08e655540adb85afdc4fd388f94ffa758707..56a66a72050b68addbab17b8086af46fcad6db3d 100644 (file)
@@ -1357,6 +1357,7 @@ public:
     OpRequestRef op,
     ThreadPool::TPHandle &handle) override;
   void do_backfill(OpRequestRef op) override;
+  void do_backfill_remove(OpRequestRef op);
 
   void handle_backoff(OpRequestRef& op);