Skip to content

Commit

Permalink
Merge pull request #51262 from k0ste/wip-52841-pacific
Browse files Browse the repository at this point in the history
pacific: osd: fix shard-threads cannot wakeup bug

Reviewed-by: Neha Ojha <nojha@redhat.com>
  • Loading branch information
yuriw committed Nov 28, 2023
2 parents 52f7a39 + 8662711 commit 0edb66e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions src/osd/OSD.cc
Expand Up @@ -10647,7 +10647,7 @@ void OSDShard::consume_map(
dout(10) << new_osdmap->get_epoch()
<< " (was " << (old_osdmap ? old_osdmap->get_epoch() : 0) << ")"
<< dendl;
bool queued = false;
int queued = 0;

// check slots
auto p = pg_slots.begin();
Expand All @@ -10674,8 +10674,7 @@ void OSDShard::consume_map(
dout(20) << __func__ << " " << pgid
<< " pending_peering first epoch " << first
<< " <= " << new_osdmap->get_epoch() << ", requeueing" << dendl;
_wake_pg_slot(pgid, slot);
queued = true;
queued += _wake_pg_slot(pgid, slot);
}
++p;
continue;
Expand Down Expand Up @@ -10715,14 +10714,18 @@ void OSDShard::consume_map(
}
if (queued) {
std::lock_guard l{sdata_wait_lock};
sdata_cond.notify_one();
if (queued == 1)
sdata_cond.notify_one();
else
sdata_cond.notify_all();
}
}

void OSDShard::_wake_pg_slot(
int OSDShard::_wake_pg_slot(
spg_t pgid,
OSDShardPGSlot *slot)
{
int count = 0;
dout(20) << __func__ << " " << pgid
<< " to_process " << slot->to_process
<< " waiting " << slot->waiting
Expand All @@ -10731,12 +10734,14 @@ void OSDShard::_wake_pg_slot(
i != slot->to_process.rend();
++i) {
scheduler->enqueue_front(std::move(*i));
count++;
}
slot->to_process.clear();
for (auto i = slot->waiting.rbegin();
i != slot->waiting.rend();
++i) {
scheduler->enqueue_front(std::move(*i));
count++;
}
slot->waiting.clear();
for (auto i = slot->waiting_peering.rbegin();
Expand All @@ -10747,10 +10752,12 @@ void OSDShard::_wake_pg_slot(
// someday, if we decide this inefficiency matters
for (auto j = i->second.rbegin(); j != i->second.rend(); ++j) {
scheduler->enqueue_front(std::move(*j));
count++;
}
}
slot->waiting_peering.clear();
++slot->requeue_seq;
return count;
}

void OSDShard::identify_splits_and_merges(
Expand Down
2 changes: 1 addition & 1 deletion src/osd/OSD.h
Expand Up @@ -1094,7 +1094,7 @@ struct OSDShard {
const OSDMapRef& osdmap,
unsigned *pushes_to_free);

void _wake_pg_slot(spg_t pgid, OSDShardPGSlot *slot);
int _wake_pg_slot(spg_t pgid, OSDShardPGSlot *slot);

void identify_splits_and_merges(
const OSDMapRef& as_of_osdmap,
Expand Down

0 comments on commit 0edb66e

Please sign in to comment.