Print this page
3996 want a libzfs_core API to rollback to latest snapshot
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>

*** 3491,3523 **** (void) zvol_remove_minor(zc->zc_name); return (err); } /* ! * inputs: ! * zc_name name of dataset to rollback (to most recent snapshot) * ! * outputs: none */ static int ! zfs_ioc_rollback(zfs_cmd_t *zc) { zfsvfs_t *zfsvfs; int error; ! if (getzfsvfs(zc->zc_name, &zfsvfs) == 0) { error = zfs_suspend_fs(zfsvfs); if (error == 0) { int resume_err; ! error = dsl_dataset_rollback(zc->zc_name, zfsvfs); ! resume_err = zfs_resume_fs(zfsvfs, zc->zc_name); error = error ? error : resume_err; } VFS_RELE(zfsvfs->z_vfs); } else { ! error = dsl_dataset_rollback(zc->zc_name, NULL); } return (error); } static int --- 3491,3526 ---- (void) zvol_remove_minor(zc->zc_name); return (err); } /* ! * fsname is name of dataset to rollback (to most recent snapshot) * ! * innvl is not used. ! * ! * outnvl: "target" -> name of most recent snapshot ! * } */ + /* ARGSUSED */ static int ! zfs_ioc_rollback(const char *fsname, nvlist_t *args, nvlist_t *outnvl) { zfsvfs_t *zfsvfs; int error; ! if (getzfsvfs(fsname, &zfsvfs) == 0) { error = zfs_suspend_fs(zfsvfs); if (error == 0) { int resume_err; ! error = dsl_dataset_rollback(fsname, zfsvfs, outnvl); ! resume_err = zfs_resume_fs(zfsvfs, fsname); error = error ? error : resume_err; } VFS_RELE(zfsvfs->z_vfs); } else { ! error = dsl_dataset_rollback(fsname, NULL, outnvl); } return (error); } static int
*** 5325,5334 **** --- 5328,5341 ---- zfs_ioctl_register("get_holds", ZFS_IOC_GET_HOLDS, zfs_ioc_get_holds, zfs_secpolicy_read, DATASET_NAME, POOL_CHECK_SUSPENDED, B_FALSE, B_FALSE); + zfs_ioctl_register("rollback", ZFS_IOC_ROLLBACK, + zfs_ioc_rollback, zfs_secpolicy_rollback, DATASET_NAME, + POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_FALSE, B_TRUE); + /* IOCTLS that use the legacy function signature */ zfs_ioctl_register_legacy(ZFS_IOC_POOL_FREEZE, zfs_ioc_pool_freeze, zfs_secpolicy_config, NO_NAME, B_FALSE, POOL_CHECK_READONLY);
*** 5436,5447 **** zfs_ioctl_register_dataset_modify(ZFS_IOC_SET_PROP, zfs_ioc_set_prop, zfs_secpolicy_none); zfs_ioctl_register_dataset_modify(ZFS_IOC_DESTROY, zfs_ioc_destroy, zfs_secpolicy_destroy); - zfs_ioctl_register_dataset_modify(ZFS_IOC_ROLLBACK, zfs_ioc_rollback, - zfs_secpolicy_rollback); zfs_ioctl_register_dataset_modify(ZFS_IOC_RENAME, zfs_ioc_rename, zfs_secpolicy_rename); zfs_ioctl_register_dataset_modify(ZFS_IOC_RECV, zfs_ioc_recv, zfs_secpolicy_recv); zfs_ioctl_register_dataset_modify(ZFS_IOC_PROMOTE, zfs_ioc_promote, --- 5443,5452 ----