|
|
|
|
@@ -3453,6 +3453,107 @@ void test_read_enoent_without_racing_op_marks_corrupted()
|
|
|
|
|
printf("test_read_enoent_without_racing_op_marks_corrupted passed\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The same -ENOENT, but the PG stops while the read is in flight. The object
|
|
|
|
|
// state may be stale then (a repeat delete reached the copy and the stop
|
|
|
|
|
// cancelled it), and peering rebuilds it anyway: the read ends with -EPIPE like
|
|
|
|
|
// any other operation of a stopped PG
|
|
|
|
|
void test_read_enoent_in_stopped_pg_returns_epipe()
|
|
|
|
|
{
|
|
|
|
|
printf("test_read_enoent_in_stopped_pg_returns_epipe\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.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 inode = INODE_WITH_POOL(1, 1);
|
|
|
|
|
object_id oid = { .inode = inode, .stripe = 0 };
|
|
|
|
|
f.reply_local_list({ { oid, 1 } }, 1);
|
|
|
|
|
f.reply_peer_list(2, {}, 0);
|
|
|
|
|
f.pump();
|
|
|
|
|
assert(f.pg(1, 1).state == (PG_ACTIVE|PG_HAS_DEGRADED));
|
|
|
|
|
|
|
|
|
|
int read_retval = 0;
|
|
|
|
|
auto *read = make_self_rw(OSD_OP_READ, inode, 0, 4096);
|
|
|
|
|
read->callback = [&read_retval](osd_op_t *op) { read_retval = op->reply.hdr.retval; };
|
|
|
|
|
f.exec(read);
|
|
|
|
|
auto *local_read = f.bs->take(BS_OP_READ);
|
|
|
|
|
|
|
|
|
|
f.repeer_pgs(2);
|
|
|
|
|
assert(!(f.pg(1, 1).state & PG_ACTIVE));
|
|
|
|
|
local_read->retval = -ENOENT;
|
|
|
|
|
local_read->callback(local_read);
|
|
|
|
|
|
|
|
|
|
assert(read_retval == -EPIPE);
|
|
|
|
|
|
|
|
|
|
delete read;
|
|
|
|
|
printf("test_read_enoent_in_stopped_pg_returns_epipe passed\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The same for a read through a snapshot chain: the parent layer's copy answers
|
|
|
|
|
// -ENOENT after the PG stopped, and the read ends with -EPIPE
|
|
|
|
|
void test_chained_read_in_stopped_pg_returns_epipe()
|
|
|
|
|
{
|
|
|
|
|
printf("test_chained_read_in_stopped_pg_returns_epipe\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);
|
|
|
|
|
object_id parent_oid = { .inode = INODE_WITH_POOL(1, 3), .stripe = 0 };
|
|
|
|
|
// The parent object is only on OSD 1; the child has no data of its own
|
|
|
|
|
f.reply_local_list({ { parent_oid, 1 } }, 1);
|
|
|
|
|
f.reply_peer_list(2, {}, 0);
|
|
|
|
|
f.pump();
|
|
|
|
|
assert(f.pg(1, 1).state == (PG_ACTIVE|PG_HAS_DEGRADED));
|
|
|
|
|
f.bs->bitmaps[parent_oid] = std::vector<uint8_t>(4, 0xff);
|
|
|
|
|
|
|
|
|
|
int read_retval = 0;
|
|
|
|
|
auto *read = make_self_rw(OSD_OP_READ, child_inode, 0, 4096);
|
|
|
|
|
// The inode revision the client saw: that makes it a chained read
|
|
|
|
|
read->req.rw.meta_revision = 1;
|
|
|
|
|
read->callback = [&read_retval](osd_op_t *op) { read_retval = op->reply.hdr.retval; };
|
|
|
|
|
f.exec(read);
|
|
|
|
|
auto *parent_read = f.bs->take(BS_OP_READ);
|
|
|
|
|
assert(parent_read->oid == parent_oid);
|
|
|
|
|
|
|
|
|
|
f.repeer_pgs(2);
|
|
|
|
|
assert(!(f.pg(1, 1).state & PG_ACTIVE));
|
|
|
|
|
parent_read->retval = -ENOENT;
|
|
|
|
|
parent_read->callback(parent_read);
|
|
|
|
|
|
|
|
|
|
assert(read_retval == -EPIPE);
|
|
|
|
|
|
|
|
|
|
delete read;
|
|
|
|
|
printf("test_chained_read_in_stopped_pg_returns_epipe passed\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Peering must not forget an outdated copy just because its OSD already holds
|
|
|
|
|
// the object at another role. A stale piece kept by a set member after a set
|
|
|
|
|
// change looks, by OSD number alone, like a copy that the target set already
|
|
|
|
|
@@ -4689,6 +4790,8 @@ int main(int narg, char *args[])
|
|
|
|
|
test_repeated_delete_is_noop();
|
|
|
|
|
test_read_enoent_waits_behind_running_delete();
|
|
|
|
|
test_read_enoent_without_racing_op_marks_corrupted();
|
|
|
|
|
test_read_enoent_in_stopped_pg_returns_epipe();
|
|
|
|
|
test_chained_read_in_stopped_pg_returns_epipe();
|
|
|
|
|
test_peering_outdated_copy_other_role();
|
|
|
|
|
test_pg_epoch_base_is_reported_epoch();
|
|
|
|
|
test_pg_epoch_bump_above_reported_epoch();
|
|
|
|
|
|