osd: move part of wake_pg_waiters into helper

We'll need this shortly.

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2017-12-18 13:55:45 -06:00
parent 8e8c7cce1f
commit f9aea5da93
2 changed files with 26 additions and 14 deletions

View File

@ -9488,6 +9488,28 @@ int OSD::init_op_flags(OpRequestRef& op)
#undef dout_prefix
#define dout_prefix *_dout << "osd." << osd->whoami << " op_wq "
void OSD::ShardedOpWQ::_wake_pg_slot(
spg_t pgid,
ShardData *sdata,
ShardData::pg_slot& slot,
unsigned *pushes_to_free)
{
dout(20) << __func__ << " " << pgid
<< " to_process " << slot.to_process
<< " waiting_for_pg=" << (int)slot.waiting_for_pg << dendl;
for (auto& q : slot.to_process) {
*pushes_to_free += q.get_reserved_pushes();
}
for (auto i = slot.to_process.rbegin();
i != slot.to_process.rend();
++i) {
sdata->_enqueue_front(std::move(*i), osd->op_prio_cutoff);
}
slot.to_process.clear();
slot.waiting_for_pg = false;
++slot.requeue_seq;
}
void OSD::ShardedOpWQ::wake_pg_waiters(spg_t pgid)
{
uint32_t shard_index = pgid.hash_to_shard(shard_list.size());
@ -9498,20 +9520,7 @@ void OSD::ShardedOpWQ::wake_pg_waiters(spg_t pgid)
Mutex::Locker l(sdata->sdata_op_ordering_lock);
auto p = sdata->pg_slots.find(pgid);
if (p != sdata->pg_slots.end()) {
dout(20) << __func__ << " " << pgid
<< " to_process " << p->second.to_process
<< " waiting_for_pg=" << (int)p->second.waiting_for_pg << dendl;
for (auto& q : p->second.to_process) {
pushes_to_free += q.get_reserved_pushes();
}
for (auto i = p->second.to_process.rbegin();
i != p->second.to_process.rend();
++i) {
sdata->_enqueue_front(std::move(*i), osd->op_prio_cutoff);
}
p->second.to_process.clear();
p->second.waiting_for_pg = false;
++p->second.requeue_seq;
_wake_pg_slot(pgid, sdata, p->second, &pushes_to_free);
queued = true;
}
}

View File

@ -1659,6 +1659,9 @@ private:
/// wake any pg waiters after a PG is created/instantiated
void wake_pg_waiters(spg_t pgid);
void _wake_pg_slot(spg_t pgid, ShardData *sdata, ShardData::pg_slot& slot,
unsigned *pushes_to_free);
/// prune ops (and possibly pg_slots) for pgs that shouldn't be here
void prune_pg_waiters(OSDMapRef osdmap, int whoami);