Skip to content

Commit

Permalink
feat(resize): resize the volume based on status (#25)
Browse files Browse the repository at this point in the history
Signed-off-by: mittachaitu <[email protected]>
  • Loading branch information
sai chaithanya authored and vishnuitta committed Aug 28, 2019
1 parent 2be4f7c commit 0c3fa2a
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions src/mgmt_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,16 +1042,45 @@ uzfs_zvol_execute_async_command(void *arg)
break;
case ZVOL_OPCODE_RESIZE:
volsize = *(uint64_t *)async_task->payload;
rc = zvol_check_volsize(volsize,
zinfo->main_zv->zv_volblocksize);
if (rc == 0) {
rc = zvol_update_volsize(volsize,
zinfo->main_zv->zv_objset);
if (rc == 0)
zvol_size_changed(zinfo->main_zv, volsize);
// Take rebuild_mtx lock since we are checking the status
LOG_INFO("Resizing zvol %s to %lu bytes",
zinfo->name, volsize);
mutex_enter(&zinfo->main_zv->rebuild_mtx);
if (uzfs_zvol_get_status(zinfo->main_zv) ==
ZVOL_STATUS_HEALTHY) {
rc = uzfs_zvol_resize(zinfo->main_zv, volsize);
if (rc != 0) {
mutex_exit(&zinfo->main_zv->rebuild_mtx);
LOG_ERR("Failed to resize main volume %s",
zinfo->main_zv->zv_name);
goto ret_error;
}
} else {
rc = uzfs_zvol_resize(zinfo->clone_zv, volsize);
if (rc != 0) {
mutex_exit(&zinfo->main_zv->rebuild_mtx);
LOG_ERR("Failed to resize clone volume %s",
zinfo->clone_zv->zv_name);
goto ret_error;
}
if (uzfs_zvol_get_rebuild_status(zinfo->main_zv) ==
ZVOL_REBUILDING_AFS) {
rc = uzfs_zvol_resize(zinfo->main_zv, volsize);
if (rc != 0) {
mutex_exit(
&zinfo->main_zv->rebuild_mtx);
LOG_ERR("Failed to resize main"
" volume %s in AFS mode",
zinfo->main_zv->zv_name);
goto ret_error;
}
}
}
mutex_exit(&zinfo->main_zv->rebuild_mtx);
LOG_INFO("Successfully resized zvol %s "
"to %lu bytes", zinfo->name, volsize);
ret_error:
if (rc != 0) {
LOG_ERR("Failed to resize zvol %s", zinfo->name);
async_task->status = ZVOL_OP_STATUS_FAILED;
} else {
async_task->status = ZVOL_OP_STATUS_OK;
Expand Down

0 comments on commit 0c3fa2a

Please sign in to comment.