3516 int |
3516 int |
3517 zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force) |
3517 zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force) |
3518 { |
3518 { |
3519 rollback_data_t cb = { 0 }; |
3519 rollback_data_t cb = { 0 }; |
3520 int err; |
3520 int err; |
3521 zfs_cmd_t zc = { 0 }; |
|
3522 boolean_t restore_resv = 0; |
3521 boolean_t restore_resv = 0; |
3523 uint64_t old_volsize, new_volsize; |
3522 uint64_t old_volsize, new_volsize; |
3524 zfs_prop_t resv_prop; |
3523 zfs_prop_t resv_prop; |
3525 |
3524 |
3526 assert(zhp->zfs_type == ZFS_TYPE_FILESYSTEM || |
3525 assert(zhp->zfs_type == ZFS_TYPE_FILESYSTEM || |
3548 old_volsize = zfs_prop_get_int(zhp, ZFS_PROP_VOLSIZE); |
3547 old_volsize = zfs_prop_get_int(zhp, ZFS_PROP_VOLSIZE); |
3549 restore_resv = |
3548 restore_resv = |
3550 (old_volsize == zfs_prop_get_int(zhp, resv_prop)); |
3549 (old_volsize == zfs_prop_get_int(zhp, resv_prop)); |
3551 } |
3550 } |
3552 |
3551 |
3553 (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name)); |
|
3554 |
|
3555 if (ZFS_IS_VOLUME(zhp)) |
|
3556 zc.zc_objset_type = DMU_OST_ZVOL; |
|
3557 else |
|
3558 zc.zc_objset_type = DMU_OST_ZFS; |
|
3559 |
|
3560 /* |
3552 /* |
3561 * We rely on zfs_iter_children() to verify that there are no |
3553 * We rely on zfs_iter_children() to verify that there are no |
3562 * newer snapshots for the given dataset. Therefore, we can |
3554 * newer snapshots for the given dataset. Therefore, we can |
3563 * simply pass the name on to the ioctl() call. There is still |
3555 * simply pass the name on to the ioctl() call. There is still |
3564 * an unlikely race condition where the user has taken a |
3556 * an unlikely race condition where the user has taken a |
3565 * snapshot since we verified that this was the most recent. |
3557 * snapshot since we verified that this was the most recent. |
3566 * |
|
3567 */ |
3558 */ |
3568 if ((err = zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_ROLLBACK, &zc)) != 0) { |
3559 err = lzc_rollback(zhp->zfs_name, NULL, 0); |
|
3560 if (err != 0) { |
3569 (void) zfs_standard_error_fmt(zhp->zfs_hdl, errno, |
3561 (void) zfs_standard_error_fmt(zhp->zfs_hdl, errno, |
3570 dgettext(TEXT_DOMAIN, "cannot rollback '%s'"), |
3562 dgettext(TEXT_DOMAIN, "cannot rollback '%s'"), |
3571 zhp->zfs_name); |
3563 zhp->zfs_name); |
3572 return (err); |
3564 return (err); |
3573 } |
3565 } |