Skip to content

Commit

Permalink
[DE249]fix(zrepl): destroying all internal snapshots of rebuild clone…
Browse files Browse the repository at this point in the history
… dataset once rebuild completes (mayadata-io#199)

Two changes in the `zfs stats` output format

Signed-off-by: mayank <mayank.patel@cloudbyte.com>
  • Loading branch information
mynktl authored and mayank committed Feb 19, 2019
1 parent 66a84f1 commit 30d72b2
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
4 changes: 4 additions & 0 deletions include/uzfs_rebuilding.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ int uzfs_zvol_get_or_create_internal_clone(zvol_state_t *zv,
int uzfs_zvol_release_internal_clone(zvol_state_t *zv,
zvol_state_t *snap_zv, zvol_state_t *clone_zv);

/*
* To remove all internal snapshots of a dataset
*/
int uzfs_destroy_internal_all_snap(zvol_state_t *zv);
boolean_t is_stale_clone(zvol_state_t *);

#ifdef __cplusplus
Expand Down
46 changes: 46 additions & 0 deletions lib/libzpool/uzfs_rebuilding.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,49 @@ uzfs_zvol_get_or_create_internal_clone(zvol_state_t *zv,
strfree(snapname);
return (ret);
}

/*
* To destroy all internal created snapshot
* on a dataset
*/
int
uzfs_destroy_internal_all_snap(zvol_state_t *zv)
{
int ret;
char snapname[MAXNAMELEN];
objset_t *os;
uint64_t obj = 0, cookie = 0;

if (!zv || !zv->zv_objset)
return (-1);

os = zv->zv_objset;

while (1) {
dsl_pool_config_enter(spa_get_dsl(zv->zv_spa), FTAG);
ret = dmu_snapshot_list_next(os, sizeof (snapname) - 1,
snapname, &obj, &cookie, NULL);
dsl_pool_config_exit(spa_get_dsl(zv->zv_spa), FTAG);

if (ret) {
if (ret == ENOENT)
ret = 0;
break;
}

if (!(strcmp(snapname, REBUILD_SNAPSHOT_SNAPNAME) == 0) &&
!(strncmp(snapname, IO_DIFF_SNAPNAME,
sizeof (IO_DIFF_SNAPNAME) - 1) == 0)) {
continue;
}

ret = destroy_snapshot_zv(zv, snapname);
if (ret != 0) {
LOG_ERR("Failed to destroy internal snap(%s) on:%s "
"with err:%d", snapname, zv->zv_name, ret);
break;
}
}

return (ret);
}
7 changes: 7 additions & 0 deletions lib/libzpool/zrepl_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,13 @@ uzfs_zvol_destroy_snapshot_clone(zvol_state_t *zv, zvol_state_t *snap_zv,
LOG_INFO("Destroying %s and %s(%s) on:%s", snap_zv->zv_name,
clone_zv->zv_name, clonename, zv->zv_name);

/* Destroy clone's snapshot */
ret = uzfs_destroy_internal_all_snap(clone_zv);
if (ret != 0) {
LOG_ERR("Rebuild_clone snap destroy failed on:%s"
" with err:%d", clone_zv->zv_name, ret);
}

uzfs_zvol_release_internal_clone(zv, snap_zv, clone_zv);

// try_clone_delete_again:
Expand Down
4 changes: 2 additions & 2 deletions module/zfs/zvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,9 @@ uzfs_ioc_stats(zfs_cmd_t *zc, nvlist_t *nvl)
zv->main_zv->rebuild_info.zv_rebuild_status));

fnvlist_add_uint64(innvl, "isIOAckSenderCreated",
zv->is_io_ack_sender_created);
(zv->is_io_ack_sender_created) ? 1 : 0);
fnvlist_add_uint64(innvl, "isIOReceiverCreated",
zv->is_io_receiver_created);
(zv->is_io_receiver_created) ? 1 : 0);
fnvlist_add_uint64(innvl, "runningIONum",
zv->running_ionum);
fnvlist_add_uint64(innvl, "checkpointedIONum",
Expand Down

0 comments on commit 30d72b2

Please sign in to comment.