Skip to content

Commit

Permalink
US1468 Test cases for replication protocol (openzfs#44)
Browse files Browse the repository at this point in the history
Add new test cases as mentioned and fix the code for test cases which did not pass.

Signed-off-by: Jan Kryl <jan.kryl@cloudbyte.com>
  • Loading branch information
Jan Kryl committed Jun 26, 2018
1 parent 7431cdb commit 3afc5cd
Show file tree
Hide file tree
Showing 6 changed files with 341 additions and 35 deletions.
3 changes: 2 additions & 1 deletion cmd/zrepl/data_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,11 @@ uzfs_zvol_worker(void *arg)
break;
}

if (rc < 0) {
if (rc != 0) {
ZREPL_ERRLOG("Zvol op_code :%d failed with "
"error: %d\n", hdr->opcode, errno);
hdr->status = ZVOL_OP_STATUS_FAILED;
hdr->len = 0;
} else {
hdr->status = ZVOL_OP_STATUS_OK;
}
Expand Down
6 changes: 4 additions & 2 deletions cmd/zrepl/mgmt_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,10 @@ uzfs_zvol_rebuild_dw_replica_start(uzfs_mgmt_conn_t *conn, zvol_io_hdr_t *hdrp,
zvol_info_t *zinfo = NULL;

for (; rebuild_op_cnt > 0; rebuild_op_cnt--, mack++) {
printf("Replica %s at %s:%u helping in rebuild\n",
mack->volname, mack->ip, mack->port);
if (mack->volname[0] != '\0') {
printf("Replica %s at %s:%u helping in rebuild\n",
mack->volname, mack->ip, mack->port);
}
if (zinfo == NULL) {
zinfo = uzfs_zinfo_lookup(mack->dw_volname);
if (zinfo == NULL) {
Expand Down
24 changes: 8 additions & 16 deletions cmd/zrepl/zrepl.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,8 @@ uzfs_zvol_io_ack_sender(void *arg)
zio_cmd->hdr.opcode, zio_cmd->hdr.io_seq);

/* account for space taken by metadata headers */
if (zio_cmd->hdr.opcode == ZVOL_OPCODE_READ) {
if (zio_cmd->hdr.status == ZVOL_OP_STATUS_OK &&
zio_cmd->hdr.opcode == ZVOL_OPCODE_READ) {
md_len = 0;
for (metadata_desc_t *md = zio_cmd->metadata_desc;
md != NULL;
Expand All @@ -728,15 +729,8 @@ uzfs_zvol_io_ack_sender(void *arg)
continue;
}

switch (zio_cmd->hdr.opcode) {
case ZVOL_OPCODE_HANDSHAKE:
case ZVOL_OPCODE_WRITE:
case ZVOL_OPCODE_SYNC:
case ZVOL_OPCODE_REBUILD_STEP_DONE:
zinfo->write_req_ack_cnt++;
/* Send handsake ack */
break;
case ZVOL_OPCODE_READ:
if (zio_cmd->hdr.opcode == ZVOL_OPCODE_READ) {
if (zio_cmd->hdr.status == ZVOL_OP_STATUS_OK) {
/* Send data read from disk */
rc = uzfs_send_reads(zio_cmd->conn, zio_cmd);
if (rc == -1) {
Expand All @@ -745,12 +739,10 @@ uzfs_zvol_io_ack_sender(void *arg)
if (zio_cmd->conn == fd)
goto exit;
}
zinfo->read_req_ack_cnt++;
break;

default:
VERIFY(!"Should be a valid opcode");
break;
}
zinfo->read_req_ack_cnt++;
} else {
zinfo->write_req_ack_cnt++;
}
zio_cmd_free(&zio_cmd);
}
Expand Down
7 changes: 5 additions & 2 deletions lib/fio/replica.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ static int fio_repl_getevents(struct thread_data *td, unsigned int min,
}

while (!read_error && count < min) {
assert(count < td->o.iodepth);
ret = poll(pfds, td->o.nr_files, timeout);
if (ret < 0) {
td_verror(td, errno, "poll");
Expand All @@ -769,6 +770,7 @@ static int fio_repl_getevents(struct thread_data *td, unsigned int min,
if (ent == NULL) {
read_error = 1;
} else {
assert(nd->io_completed[count] == NULL);
nd->io_completed[count++] = ent->io_u;
free(ent);
if (count >= max)
Expand All @@ -786,8 +788,9 @@ static int fio_repl_getevents(struct thread_data *td, unsigned int min,
static struct io_u *fio_repl_event(struct thread_data *td, int event)
{
struct netio_data *nd = td->io_ops_data;

return (nd->io_completed[event]);
struct io_u *io_u = nd->io_completed[event];
nd->io_completed[event] = NULL;
return (io_u);
}

struct ioengine_ops ioengine = {
Expand Down
18 changes: 14 additions & 4 deletions lib/libzpool/uzfs_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ uzfs_write_data(zvol_state_t *zv, char *buf, uint64_t offset, uint64_t len,
uint64_t orig_offset = offset;
char *mdata = NULL, *tmdata = NULL, *tmdataend = NULL;

VERIFY(IS_P2ALIGNED(offset, zv->zv_metavolblocksize) &&
IS_P2ALIGNED(len, zv->zv_metavolblocksize));
if (!IS_P2ALIGNED(offset, zv->zv_metavolblocksize) ||
!IS_P2ALIGNED(len, zv->zv_metavolblocksize) ||
len == 0)
return (EINVAL);

if (offset + len > zv->zv_volsize || offset > zv->zv_volsize)
return (EINVAL);

sync = (dmu_objset_syncprop(os) == ZFS_SYNC_ALWAYS) ? 1 : 0;
ASSERT3P(zv->zv_volmetablocksize, !=, 0);
Expand Down Expand Up @@ -240,8 +245,13 @@ uzfs_read_data(zvol_state_t *zv, char *buf, uint64_t offset, uint64_t len,
blk_metadata_t *metadata;
int nmetas;

VERIFY(IS_P2ALIGNED(offset, zv->zv_metavolblocksize) &&
IS_P2ALIGNED(len, zv->zv_metavolblocksize));
if (!IS_P2ALIGNED(offset, zv->zv_metavolblocksize) ||
!IS_P2ALIGNED(len, zv->zv_metavolblocksize) ||
len == 0)
return (EINVAL);

if (offset + len > zv->zv_volsize || offset > zv->zv_volsize)
return (EINVAL);

ASSERT3P(zv->zv_volmetadatasize, ==, sizeof (blk_metadata_t));

Expand Down
Loading

0 comments on commit 3afc5cd

Please sign in to comment.