diff --git a/src/osd/osd_flush.cpp b/src/osd/osd_flush.cpp index 917b5e05..2c22ccdd 100644 --- a/src/osd/osd_flush.cpp +++ b/src/osd/osd_flush.cpp @@ -56,12 +56,8 @@ void osd_t::submit_pg_flush_ops(pg_t & pg) if (pg.epoch > pg.reported_epoch) { // Flushes wait until the history with the holders of their versions is reported - if (pg.epoch > pg.reporting_epoch) - { - this->pg_state_dirty.insert({ .pool_id = pg.pool_id, .pg_num = pg.pg_num }); - pg.history_changed = true; - report_pg_states(); - } + // Report it like a write does, with the current OSD set: the first write of this epoch won't + report_epoch(pg); return; } submit_flush_batch(pg); diff --git a/src/test/osd_test.cpp b/src/test/osd_test.cpp index 3921c6ab..5b13f919 100644 --- a/src/test/osd_test.cpp +++ b/src/test/osd_test.cpp @@ -4817,8 +4817,8 @@ void test_peering_flush_misplaced_primary_lost(bool on_osd2) } // Version 2 of object A is unstable on OSDs 1 and 2 of an EC 2+1 PG, so the peering flush batch waits until -// the history with its holders is reported. OSD 3 drops out before the report lands: the batch must be -// dropped without sending anything, and the PG must peer again +// the history with its holders and the current OSD set is reported. OSD 3 drops out before the report lands: +// the batch must be dropped without sending anything, and the PG must peer again void test_peering_flush_waiting_batch_repeer() { printf("test_peering_flush_waiting_batch_repeer\n"); @@ -4837,7 +4837,7 @@ void test_peering_flush_waiting_batch_repeer() f.pump(); assert(pg.state == (PG_ACTIVE|PG_HAS_DEGRADED|PG_HAS_UNCLEAN)); assert(pg.flush_batch && !pg.flush_batch->flush_ops); - assert(pg.target_history == std::vector>({ { 1, 2 } })); + assert(pg.target_history == std::vector>({ { 1, 2 }, { 1, 2, 3 } })); assert(f.st_cli->queue.size() == 1); f.repeer_pgs(3); @@ -4891,10 +4891,12 @@ void test_peering_flush_replicated_history() // The same for a client write to a degraded PG of pg_minsize OSDs: OSD 1 writes version 2 of object A to them // all, stabilizes its own part and loses its peers before the others stabilize theirs. The degraded OSD set is -// in the PG history before the write -void test_degraded_write_primary_lost(ec_scheme_t ec) +// in the PG history before the write. With , the peering first rolls back version 2 of object B on OSD 1 +// alone, and that flush reports the epoch of the write +void test_degraded_write_primary_lost(ec_scheme_t ec, bool flush) { - printf("test_degraded_write_primary_lost[EC %d+%d, pg_minsize %d]\n", ec.data, ec.parity, ec.pg_minsize); + const char *desc = flush ? ", after a peering flush" : ""; + printf("test_degraded_write_primary_lost[EC %d+%d, pg_minsize %d%s]\n", ec.data, ec.parity, ec.pg_minsize, desc); inode_t ino = INODE_WITH_POOL(1, 1); int pg_size = ec.data+ec.parity; @@ -4910,11 +4912,21 @@ void test_degraded_write_primary_lost(ec_scheme_t ec) peers.push_back(osd); for (auto p: peers) f.connect_peer(p); + uint64_t b = 131072*ec.data; for (auto p: peers) - f.reply_peer_list(p, { { { ino, p-1 }, 1 } }, 1); - f.reply_local_list({ { { ino, 0 }, 1 } }, 1); + f.reply_peer_list(p, { { { ino, p-1 }, 1 }, { { ino, b+p-1 }, 1 } }, 2); + std::vector local = { { { ino, 0 }, 1 }, { { ino, b }, 1 } }; + if (flush) + local.push_back({ { ino, b }, 2 }); + f.reply_local_list(local, 2); f.pump(); assert((f.pg(1, 1).state & (PG_ACTIVE|PG_DEGRADED)) == (PG_ACTIVE|PG_DEGRADED)); + if (flush) + { + bs_complete(f.bs->take(BS_OP_ROLLBACK), 0); + f.pump(); + assert(f.pg(1, 1).reported_epoch == f.pg(1, 1).epoch); + } auto *wr = make_write_op(ino, 0, 131072*ec.data, 0xab); int retval = 0; wr->callback = [&](osd_op_t *op) { retval = op->reply.hdr.retval; }; @@ -4949,7 +4961,7 @@ void test_degraded_write_primary_lost(ec_scheme_t ec) assert(complete); assert(active_without || ec.pg_minsize == ec.data); - printf("test_degraded_write_primary_lost[EC %d+%d, pg_minsize %d] passed\n", ec.data, ec.parity, ec.pg_minsize); + printf("test_degraded_write_primary_lost[EC %d+%d, pg_minsize %d%s] passed\n", ec.data, ec.parity, ec.pg_minsize, desc); } // A dispatched SYNC holds its stabilize snapshot; a delete of a covered object must @@ -5709,8 +5721,10 @@ int main(int narg, char *args[]) test_peering_flush_primary_lost({ 3, 2, 4 }, 3); test_peering_flush_primary_lost({ 3, 2, 4 }, 4); test_peering_flush_primary_lost({ 3, 2, 4 }, 5); - test_degraded_write_primary_lost({ 2, 1, 2 }); - test_degraded_write_primary_lost({ 3, 2, 4 }); + test_degraded_write_primary_lost({ 2, 1, 2 }, false); + test_degraded_write_primary_lost({ 3, 2, 4 }, false); + test_degraded_write_primary_lost({ 2, 1, 2 }, true); + test_degraded_write_primary_lost({ 3, 1, 3 }, true); test_peering_flush_then_holder_lost({ 2, 1, 2 }, 2, 2); test_peering_flush_then_holder_lost({ 2, 1, 2 }, 3, 2); test_peering_flush_then_holder_lost({ 3, 2, 4 }, 4, 3);