Compare commits

...

1 Commits

Author SHA1 Message Date
Changwei Ye
f0816f6ed0 osd: use lower_bound to find head operation in pg_cancel_write_queue
std::multimap::find() is not guaranteed by the C++ standard to return the
first element of a range with equivalent keys, which may fail to retrieve
the head operation in pg.write_queue.

Switch to lower_bound() to reliably locate the head of the queue in O(log N)
time, and add an explicit check for it->first == oid to prevent falsely
matching a subsequent larger key when the target oid is missing.
2026-10-15 12:12:55 +08:00

View File

@@ -875,8 +875,8 @@ void osd_t::submit_primary_rollback_subops(osd_op_t *cur_op, const osd_num_t* os
void osd_t::pg_cancel_write_queue(pg_t & pg, osd_op_t *first_op, object_id oid, int retval)
{
auto st_it = pg.write_queue.find(oid), it = st_it;
if (it == pg.write_queue.end() || it->second != first_op)
auto st_it = pg.write_queue.lower_bound(oid), it = st_it;
if (it == pg.write_queue.end() || it->first != oid || it->second != first_op)
{
// Write queue doesn't match the first operation.
// first_op is a leftover operation from the previous peering of the same PG.