Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DE249] Destroying all snapshot of rebuild clone dataset once rebuild completes #199

Merged
merged 4 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
41 changes: 41 additions & 0 deletions lib/libzpool/uzfs_rebuilding.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,44 @@ 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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name change to 'uzfs_destroy_all_internal_snapshots'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

{
int ret;
char snapname[MAXNAMELEN];
objset_t *os = zv->zv_objset;
uint64_t obj = 0, cookie = 0;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put a null check for zv.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

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) &&

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use internal_snapshot() here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

internal_snapshot is from libzrepl. So, we cannot use it here unless we link libzpool with libzrepl.

!(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 @@ -379,9 +379,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