]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/: move split_list and split_request into OSD
authorSamuel Just <sam.just@inktank.com>
Tue, 27 May 2014 20:16:41 +0000 (13:16 -0700)
committerSamuel Just <sam.just@inktank.com>
Tue, 27 May 2014 20:16:41 +0000 (13:16 -0700)
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osd/OSD.h
src/osd/PG.cc
src/osd/PG.h

index 0f5f05560c144ab396e93c31e14d6c1d6f21268c..b3e30c57183d8816ef5cbd27dc1b4198667f66bc 100644 (file)
@@ -53,6 +53,7 @@ using namespace std;
 #include "common/simple_cache.hpp"
 #include "common/sharedptr_registry.hpp"
 #include "common/PrioritizedQueue.h"
+#include "messages/MOSDOp.h"
 
 #define CEPH_OSD_PROTOCOL    10 /* cluster internal */
 
@@ -1095,6 +1096,35 @@ private:
 
   // -- sessions --
 public:
+
+
+  static bool split_request(OpRequestRef op, unsigned match, unsigned bits) {
+    unsigned mask = ~((~0)<<bits);
+    switch (op->get_req()->get_type()) {
+    case CEPH_MSG_OSD_OP:
+      return (static_cast<MOSDOp*>(
+               op->get_req())->get_pg().m_seed & mask) == match;
+    }
+    return false;
+  }
+
+  static void split_list(
+    list<OpRequestRef> *from,
+    list<OpRequestRef> *to,
+    unsigned match,
+    unsigned bits) {
+    for (list<OpRequestRef>::iterator i = from->begin();
+        i != from->end();
+      ) {
+      if (split_request(*i, match, bits)) {
+       to->push_back(*i);
+       from->erase(i++);
+      } else {
+       ++i;
+      }
+    }
+  }
+
   struct Session : public RefCountedObject {
     EntityName entity_name;
     OSDCap caps;
index aa3b6d5ac71264d89fc0cea67872449ab9b39423..b994cf24147f087427b39ecce9bf0e5987da55b5 100644 (file)
@@ -1946,24 +1946,6 @@ void PG::finish_recovery_op(const hobject_t& soid, bool dequeue)
   osd->osd->finish_recovery_op(this, soid, dequeue);
 }
 
-static void split_list(
-  list<OpRequestRef> *from,
-  list<OpRequestRef> *to,
-  unsigned match,
-  unsigned bits)
-{
-  for (list<OpRequestRef>::iterator i = from->begin();
-       i != from->end();
-    ) {
-    if (PG::split_request(*i, match, bits)) {
-      to->push_back(*i);
-      from->erase(i++);
-    } else {
-      ++i;
-    }
-  }
-}
-
 static void split_replay_queue(
   map<eversion_t, OpRequestRef> *from,
   map<eversion_t, OpRequestRef> *to,
@@ -1973,7 +1955,7 @@ static void split_replay_queue(
   for (map<eversion_t, OpRequestRef>::iterator i = from->begin();
        i != from->end();
        ) {
-    if (PG::split_request(i->second, match, bits)) {
+    if (OSD::split_request(i->second, match, bits)) {
       to->insert(*i);
       from->erase(i++);
     } else {
@@ -1993,10 +1975,12 @@ void PG::split_ops(PG *child, unsigned split_bits) {
   split_replay_queue(&replay_queue, &(child->replay_queue), match, split_bits);
 
   osd->dequeue_pg(this, &waiting_for_active);
-  split_list(&waiting_for_active, &(child->waiting_for_active), match, split_bits);
+  OSD::split_list(
+    &waiting_for_active, &(child->waiting_for_active), match, split_bits);
   {
     Mutex::Locker l(map_lock); // to avoid a race with the osd dispatch
-    split_list(&waiting_for_map, &(child->waiting_for_map), match, split_bits);
+    OSD::split_list(
+      &waiting_for_map, &(child->waiting_for_map), match, split_bits);
   }
 }
 
@@ -4851,16 +4835,6 @@ bool PG::can_discard_request(OpRequestRef op)
   return true;
 }
 
-bool PG::split_request(OpRequestRef op, unsigned match, unsigned bits)
-{
-  unsigned mask = ~((~0)<<bits);
-  switch (op->get_req()->get_type()) {
-  case CEPH_MSG_OSD_OP:
-    return (static_cast<MOSDOp*>(op->get_req())->get_pg().m_seed & mask) == match;
-  }
-  return false;
-}
-
 bool PG::op_must_wait_for_map(OSDMapRef curmap, OpRequestRef op)
 {
   switch (op->get_req()->get_type()) {
index 1b7311d62528a8538f7c160e8fd41948da6d367c..95179810ac5b26d77f24ac0f6110381602cd1757 100644 (file)
@@ -2053,8 +2053,6 @@ public:
 
   static bool op_must_wait_for_map(OSDMapRef curmap, OpRequestRef op);
 
-  static bool split_request(OpRequestRef op, unsigned match, unsigned bits);
-
   bool old_peering_msg(epoch_t reply_epoch, epoch_t query_epoch);
   bool old_peering_evt(CephPeeringEvtRef evt) {
     return old_peering_msg(evt->get_epoch_sent(), evt->get_epoch_requested());