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>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/zfs_ioctl.c
          +++ new/usr/src/uts/common/fs/zfs/zfs_ioctl.c
↓ open down ↓ 3485 lines elided ↑ open up ↑
3486 3486          if (strchr(zc->zc_name, '@'))
3487 3487                  err = dsl_destroy_snapshot(zc->zc_name, zc->zc_defer_destroy);
3488 3488          else
3489 3489                  err = dsl_destroy_head(zc->zc_name);
3490 3490          if (zc->zc_objset_type == DMU_OST_ZVOL && err == 0)
3491 3491                  (void) zvol_remove_minor(zc->zc_name);
3492 3492          return (err);
3493 3493  }
3494 3494  
3495 3495  /*
3496      - * inputs:
3497      - * zc_name      name of dataset to rollback (to most recent snapshot)
     3496 + * fsname is name of dataset to rollback (to most recent snapshot)
3498 3497   *
3499      - * outputs:     none
     3498 + * innvl is not used.
     3499 + *
     3500 + * outnvl: "target" -> name of most recent snapshot
     3501 + * }
3500 3502   */
     3503 +/* ARGSUSED */
3501 3504  static int
3502      -zfs_ioc_rollback(zfs_cmd_t *zc)
     3505 +zfs_ioc_rollback(const char *fsname, nvlist_t *args, nvlist_t *outnvl)
3503 3506  {
3504 3507          zfsvfs_t *zfsvfs;
3505 3508          int error;
3506 3509  
3507      -        if (getzfsvfs(zc->zc_name, &zfsvfs) == 0) {
     3510 +        if (getzfsvfs(fsname, &zfsvfs) == 0) {
3508 3511                  error = zfs_suspend_fs(zfsvfs);
3509 3512                  if (error == 0) {
3510 3513                          int resume_err;
3511 3514  
3512      -                        error = dsl_dataset_rollback(zc->zc_name, zfsvfs);
3513      -                        resume_err = zfs_resume_fs(zfsvfs, zc->zc_name);
     3515 +                        error = dsl_dataset_rollback(fsname, zfsvfs, outnvl);
     3516 +                        resume_err = zfs_resume_fs(zfsvfs, fsname);
3514 3517                          error = error ? error : resume_err;
3515 3518                  }
3516 3519                  VFS_RELE(zfsvfs->z_vfs);
3517 3520          } else {
3518      -                error = dsl_dataset_rollback(zc->zc_name, NULL);
     3521 +                error = dsl_dataset_rollback(fsname, NULL, outnvl);
3519 3522          }
3520 3523          return (error);
3521 3524  }
3522 3525  
3523 3526  static int
3524 3527  recursive_unmount(const char *fsname, void *arg)
3525 3528  {
3526 3529          const char *snapname = arg;
3527 3530          char fullname[MAXNAMELEN];
3528 3531  
↓ open down ↓ 1791 lines elided ↑ open up ↑
5320 5323              zfs_ioc_hold, zfs_secpolicy_hold, POOL_NAME,
5321 5324              POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE, B_TRUE);
5322 5325          zfs_ioctl_register("release", ZFS_IOC_RELEASE,
5323 5326              zfs_ioc_release, zfs_secpolicy_release, POOL_NAME,
5324 5327              POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE, B_TRUE);
5325 5328  
5326 5329          zfs_ioctl_register("get_holds", ZFS_IOC_GET_HOLDS,
5327 5330              zfs_ioc_get_holds, zfs_secpolicy_read, DATASET_NAME,
5328 5331              POOL_CHECK_SUSPENDED, B_FALSE, B_FALSE);
5329 5332  
     5333 +        zfs_ioctl_register("rollback", ZFS_IOC_ROLLBACK,
     5334 +            zfs_ioc_rollback, zfs_secpolicy_rollback, DATASET_NAME,
     5335 +            POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_FALSE, B_TRUE);
     5336 +
5330 5337          /* IOCTLS that use the legacy function signature */
5331 5338  
5332 5339          zfs_ioctl_register_legacy(ZFS_IOC_POOL_FREEZE, zfs_ioc_pool_freeze,
5333 5340              zfs_secpolicy_config, NO_NAME, B_FALSE, POOL_CHECK_READONLY);
5334 5341  
5335 5342          zfs_ioctl_register_pool(ZFS_IOC_POOL_CREATE, zfs_ioc_pool_create,
5336 5343              zfs_secpolicy_config, B_TRUE, POOL_CHECK_NONE);
5337 5344          zfs_ioctl_register_pool_modify(ZFS_IOC_POOL_SCAN,
5338 5345              zfs_ioc_pool_scan);
5339 5346          zfs_ioctl_register_pool_modify(ZFS_IOC_POOL_UPGRADE,
↓ open down ↓ 91 lines elided ↑ open up ↑
5431 5438              zfs_ioc_userspace_one, zfs_secpolicy_userspace_one);
5432 5439          zfs_ioctl_register_dataset_read_secpolicy(ZFS_IOC_USERSPACE_MANY,
5433 5440              zfs_ioc_userspace_many, zfs_secpolicy_userspace_many);
5434 5441          zfs_ioctl_register_dataset_read_secpolicy(ZFS_IOC_SEND,
5435 5442              zfs_ioc_send, zfs_secpolicy_send);
5436 5443  
5437 5444          zfs_ioctl_register_dataset_modify(ZFS_IOC_SET_PROP, zfs_ioc_set_prop,
5438 5445              zfs_secpolicy_none);
5439 5446          zfs_ioctl_register_dataset_modify(ZFS_IOC_DESTROY, zfs_ioc_destroy,
5440 5447              zfs_secpolicy_destroy);
5441      -        zfs_ioctl_register_dataset_modify(ZFS_IOC_ROLLBACK, zfs_ioc_rollback,
5442      -            zfs_secpolicy_rollback);
5443 5448          zfs_ioctl_register_dataset_modify(ZFS_IOC_RENAME, zfs_ioc_rename,
5444 5449              zfs_secpolicy_rename);
5445 5450          zfs_ioctl_register_dataset_modify(ZFS_IOC_RECV, zfs_ioc_recv,
5446 5451              zfs_secpolicy_recv);
5447 5452          zfs_ioctl_register_dataset_modify(ZFS_IOC_PROMOTE, zfs_ioc_promote,
5448 5453              zfs_secpolicy_promote);
5449 5454          zfs_ioctl_register_dataset_modify(ZFS_IOC_INHERIT_PROP,
5450 5455              zfs_ioc_inherit_prop, zfs_secpolicy_inherit_prop);
5451 5456          zfs_ioctl_register_dataset_modify(ZFS_IOC_SET_FSACL, zfs_ioc_set_fsacl,
5452 5457              zfs_secpolicy_set_fsacl);
↓ open down ↓ 471 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX