Skip to content

Commit

Permalink
feat(rebuild): adding a test case for the SNAP_START op (openzfs#250)
Browse files Browse the repository at this point in the history
We will exchage this op before starting the rebuild
, which will exchange size of the snapshot being rebuild.
If downgraded replica finds that it needs to resize the
volume, it will resize it first then start rebuilding from
the helper.

Signed-off-by: Pawan <[email protected]>
  • Loading branch information
pawanpraka1 authored and vishnuitta committed Jun 7, 2019
1 parent bfe20f1 commit 3810e4d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/cbtest/gtest/test_uzfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,17 @@ uzfs_mock_rebuild_scanner_full(void *arg)
verify_rebuild_io(fd, zinfo);
}

/* Send REBUILD_SNAP_START */
uint64_t volsize = ZVOL_VOLUME_SIZE(zinfo->main_zv);
hdr.opcode = ZVOL_OPCODE_REBUILD_SNAP_START;
hdr.status = ZVOL_OP_STATUS_OK;
hdr.len = sizeof(volsize);
rc = uzfs_zvol_socket_write(fd, (char *)&hdr, sizeof(hdr));
EXPECT_NE(rc, -1);

rc = uzfs_zvol_socket_write(fd, (char *)&volsize, sizeof(volsize));
EXPECT_NE(rc, -1);

/* Write REBUILD_STEP_DONE */
hdr.opcode = ZVOL_OPCODE_REBUILD_STEP_DONE;
hdr.status = ZVOL_OP_STATUS_OK;
Expand Down Expand Up @@ -1832,6 +1843,19 @@ uzfs_mock_zvol_rebuild_dw_replica(void *arg)
continue;
}

if (hdr.opcode == ZVOL_OPCODE_REBUILD_SNAP_START) {
LOG_INFO("ZVOL_OPCODE_REBUILD_SNAP_START received");
rc = uzfs_zvol_handle_rebuild_snap_start(&hdr,
sfd, zinfo);
if (rc != 0) {
LOG_ERR("Rebuild snap start failed.."
"for %s on fd(%d)",
zinfo->name, sfd);
goto exit;
}
continue;
}

ASSERT((hdr.opcode == ZVOL_OPCODE_READ) &&
(hdr.flags & ZVOL_OP_FLAG_REBUILD));
hdr.opcode = ZVOL_OPCODE_WRITE;
Expand Down

0 comments on commit 3810e4d

Please sign in to comment.