|
|
|
|
@@ -4652,6 +4652,94 @@ void test_replicated_add_object_to_set_degraded()
|
|
|
|
|
printf("test_replicated_add_object_to_set_degraded passed\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// A replicated parent-layer object that lost its last copy from its OSD set (here recovery
|
|
|
|
|
// got ENOENT from the only copy) is incomplete with no OSD to read from, while the PG stays
|
|
|
|
|
// active. A chained read through it must end with -EIO, as a plain read of it does
|
|
|
|
|
void test_chained_read_through_incomplete_parent()
|
|
|
|
|
{
|
|
|
|
|
printf("test_chained_read_through_incomplete_parent\n");
|
|
|
|
|
|
|
|
|
|
osd_test_fixture_t f;
|
|
|
|
|
f.configure_replicated_pool(/*pool_id*/ 1, /*pg_size*/ 2, /*pg_minsize*/ 1, /*pg_count*/ 1,
|
|
|
|
|
{ { 1, 2 } });
|
|
|
|
|
f.st_cli->set("/vitastor/config/inode/1/2", json11::Json::object {
|
|
|
|
|
{ "name", "child" },
|
|
|
|
|
{ "parent_id", 3 },
|
|
|
|
|
}, 1);
|
|
|
|
|
f.st_cli->set("/vitastor/config/inode/1/3", json11::Json::object {
|
|
|
|
|
{ "name", "parent" },
|
|
|
|
|
}, 1);
|
|
|
|
|
f.start(json11::Json::object {
|
|
|
|
|
{ "osd_num", 1 },
|
|
|
|
|
{ "etcd_address", "127.0.0.1:2379" },
|
|
|
|
|
{ "immediate_commit", "all" },
|
|
|
|
|
{ "block_size", 131072 },
|
|
|
|
|
{ "bitmap_granularity", 4096 },
|
|
|
|
|
{ "no_recovery", true },
|
|
|
|
|
});
|
|
|
|
|
f.connect_peer(2);
|
|
|
|
|
|
|
|
|
|
inode_t child_inode = INODE_WITH_POOL(1, 2);
|
|
|
|
|
inode_t parent_inode = INODE_WITH_POOL(1, 3);
|
|
|
|
|
object_id parent_oid = { .inode = parent_inode, .stripe = 0 };
|
|
|
|
|
// The parent object is only on OSD 1: degraded
|
|
|
|
|
f.reply_local_list({ { parent_oid, 1 } }, 1);
|
|
|
|
|
f.reply_peer_list(2, {}, 0);
|
|
|
|
|
f.pump();
|
|
|
|
|
pg_t & pg = f.pg(1, 1);
|
|
|
|
|
assert(pg.state == (PG_ACTIVE|PG_HAS_DEGRADED));
|
|
|
|
|
|
|
|
|
|
// Recovery (the zero-length write submit_recovery_op() sends) gets ENOENT from the only copy
|
|
|
|
|
const int NOT_DONE = 1;
|
|
|
|
|
int rec_retval = NOT_DONE;
|
|
|
|
|
auto *rec = new osd_op_t();
|
|
|
|
|
rec->op_type = OSD_OP_OUT;
|
|
|
|
|
rec->client_id = 0; // SELF_CLIENT
|
|
|
|
|
rec->req.rw.header.magic = SECONDARY_OSD_OP_MAGIC;
|
|
|
|
|
rec->req.rw.header.id = 1;
|
|
|
|
|
rec->req.rw.header.opcode = OSD_OP_WRITE;
|
|
|
|
|
rec->req.rw.inode = parent_inode;
|
|
|
|
|
rec->req.rw.offset = 0;
|
|
|
|
|
rec->req.rw.len = 0;
|
|
|
|
|
rec->callback = [&](osd_op_t *op) { rec_retval = op->reply.hdr.retval; };
|
|
|
|
|
f.exec(rec);
|
|
|
|
|
auto *rec_read = f.bs->take(BS_OP_READ);
|
|
|
|
|
assert(rec_read->oid == parent_oid);
|
|
|
|
|
rec_read->retval = -ENOENT;
|
|
|
|
|
rec_read->callback(rec_read);
|
|
|
|
|
f.pump();
|
|
|
|
|
assert(rec_retval == -EIO);
|
|
|
|
|
assert(pg.state == (PG_ACTIVE|PG_HAS_INCOMPLETE));
|
|
|
|
|
|
|
|
|
|
auto read = [&](inode_t inode, uint64_t meta_revision)
|
|
|
|
|
{
|
|
|
|
|
int retval = NOT_DONE;
|
|
|
|
|
auto *op = new osd_op_t();
|
|
|
|
|
op->op_type = OSD_OP_IN;
|
|
|
|
|
op->client_id = 0;
|
|
|
|
|
op->req.rw.header.magic = SECONDARY_OSD_OP_MAGIC;
|
|
|
|
|
op->req.rw.header.id = 2;
|
|
|
|
|
op->req.rw.header.opcode = OSD_OP_READ;
|
|
|
|
|
op->req.rw.inode = inode;
|
|
|
|
|
op->req.rw.offset = 0;
|
|
|
|
|
op->req.rw.len = 4096;
|
|
|
|
|
// A revision the client saw makes a read of the child a chained read
|
|
|
|
|
op->req.rw.meta_revision = meta_revision;
|
|
|
|
|
op->callback = [&retval](osd_op_t *op) { retval = op->reply.hdr.retval; };
|
|
|
|
|
f.exec(op);
|
|
|
|
|
f.pump();
|
|
|
|
|
assert(retval != NOT_DONE);
|
|
|
|
|
delete op;
|
|
|
|
|
return retval;
|
|
|
|
|
};
|
|
|
|
|
assert(read(parent_inode, 0) == -EIO);
|
|
|
|
|
assert(read(child_inode, 1) == -EIO);
|
|
|
|
|
assert(f.bs->queued.empty() && !f.peer_take_opt(2, OSD_OP_SEC_READ_BMP) && !f.peer_take_opt(2, OSD_OP_SEC_READ));
|
|
|
|
|
|
|
|
|
|
delete rec;
|
|
|
|
|
printf("test_chained_read_through_incomplete_parent passed\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int narg, char *args[])
|
|
|
|
|
{
|
|
|
|
|
test_load_global_config();
|
|
|
|
|
@@ -4693,6 +4781,7 @@ int main(int narg, char *args[])
|
|
|
|
|
test_pg_epoch_base_is_reported_epoch();
|
|
|
|
|
test_pg_epoch_bump_above_reported_epoch();
|
|
|
|
|
test_chained_read_large_chain_info();
|
|
|
|
|
test_chained_read_through_incomplete_parent();
|
|
|
|
|
test_peering_partial_unstable_ec_rolls_back();
|
|
|
|
|
test_peering_flush_primary_lost({ 2, 1, 2 }, 2);
|
|
|
|
|
test_peering_flush_primary_lost({ 2, 1, 2 }, 3);
|
|
|
|
|
|