Permalink
Browse files

OSD: process_peering_event check for new map on each pg

Signed-off-by: Samuel Just <sam.just@inktank.com>
  • Loading branch information...
1 parent c1f2a80 commit 0ee3d87f4f82cf4c17a63e0cebdf2c0f730d4bc3 Samuel Just committed Jun 8, 2012
Showing with 25 additions and 7 deletions.
  1. +1 −0 src/osd/OSD.cc
  2. +24 −7 src/osd/OSD.h
View
@@ -5190,6 +5190,7 @@ void OSD::process_peering_events(const list<PG*> &pgs)
++i) {
PG *pg = *i;
pg->lock();
+ curmap = service.get_osdmap();
if (pg->deleting) {
pg->unlock();
continue;
View
@@ -569,9 +569,11 @@ class OSD : public Dispatcher {
struct PeeringWQ : public ThreadPool::BatchWorkQueue<PG> {
list<PG*> peering_queue;
OSD *osd;
+ set<PG*> in_use;
+ const size_t batch_size;
PeeringWQ(OSD *o, time_t ti, ThreadPool *tp, size_t batch_size)
: ThreadPool::BatchWorkQueue<PG>(
- "OSD::PeeringWQ", ti, ti*10, tp, batch_size), osd(o) {}
+ "OSD::PeeringWQ", ti, ti*10, tp), osd(o), batch_size(batch_size) {}
void _dequeue(PG *pg) {
for (list<PG*>::iterator i = peering_queue.begin();
@@ -591,12 +593,20 @@ class OSD : public Dispatcher {
bool _empty() {
return peering_queue.empty();
}
- PG *_dequeue() {
- if (peering_queue.empty())
- return 0;
- PG *retval = peering_queue.front();
- peering_queue.pop_front();
- return retval;
+ void _dequeue(list<PG*> *out) {
+ set<PG*> got;
+ for (list<PG*>::iterator i = peering_queue.begin();
+ i != peering_queue.end() && out->size() < batch_size;
+ ) {
+ if (in_use.count(*i)) {
+ ++i;
+ } else {
+ out->push_back(*i);
+ got.insert(*i);
+ peering_queue.erase(i++);
+ }
+ }
+ in_use.insert(got.begin(), got.end());
}
void _process(const list<PG *> &pgs) {
osd->process_peering_events(pgs);
@@ -606,6 +616,13 @@ class OSD : public Dispatcher {
(*i)->put();
}
}
+ void _process_finish(const list<PG *> &pgs) {
+ for (list<PG*>::const_iterator i = pgs.begin();
+ i != pgs.end();
+ ++i) {
+ in_use.erase(*i);
+ }
+ }
void _clear() {
assert(peering_queue.empty());
}

0 comments on commit 0ee3d87

Please sign in to comment.