Print this page
8264 want support for promoting datasets in libzfs_core

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 ↓ 23 lines elided ↑ open up ↑
  24   24   * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved.
  25   25   * Portions Copyright 2011 Martin Matuska
  26   26   * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
  27   27   * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  28   28   * Copyright (c) 2014, 2016 Joyent, Inc. All rights reserved.
  29   29   * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
  30   30   * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
  31   31   * Copyright (c) 2013 Steven Hartland. All rights reserved.
  32   32   * Copyright (c) 2014 Integros [integros.com]
  33   33   * Copyright 2016 Toomas Soome <tsoome@me.com>
       34 + * Copyright 2017 RackTop Systems.
  34   35   */
  35   36  
  36   37  /*
  37   38   * ZFS ioctls.
  38   39   *
  39   40   * This file handles the ioctls to /dev/zfs, used for configuring ZFS storage
  40   41   * pools and filesystems, e.g. with /sbin/zfs and /sbin/zpool.
  41   42   *
  42   43   * There are two ways that we handle ioctls: the legacy way where almost
  43   44   * all of the logic is in the ioctl callback, and the new way where most
↓ open down ↓ 4651 lines elided ↑ open up ↑
4695 4696          vdev_reopen(spa->spa_root_vdev);
4696 4697          spa->spa_scrub_reopen = B_FALSE;
4697 4698  
4698 4699          (void) spa_vdev_state_exit(spa, NULL, 0);
4699 4700          spa_close(spa, FTAG);
4700 4701          return (0);
4701 4702  }
4702 4703  /*
4703 4704   * inputs:
4704 4705   * zc_name      name of filesystem
4705      - * zc_value     name of origin snapshot
4706 4706   *
4707 4707   * outputs:
4708 4708   * zc_string    name of conflicting snapshot, if there is one
4709 4709   */
4710 4710  static int
4711 4711  zfs_ioc_promote(zfs_cmd_t *zc)
4712 4712  {
     4713 +        dsl_pool_t *dp;
     4714 +        dsl_dataset_t *ds, *ods;
     4715 +        char origin[ZFS_MAX_DATASET_NAME_LEN];
4713 4716          char *cp;
     4717 +        int error;
4714 4718  
     4719 +        error = dsl_pool_hold(zc->zc_name, FTAG, &dp);
     4720 +        if (error != 0)
     4721 +                return (error);
     4722 +
     4723 +        error = dsl_dataset_hold(dp, zc->zc_name, FTAG, &ds);
     4724 +        if (error != 0) {
     4725 +                dsl_pool_rele(dp, FTAG);
     4726 +                return (error);
     4727 +        }
     4728 +
     4729 +        if (!dsl_dir_is_clone(ds->ds_dir)) {
     4730 +                dsl_dataset_rele(ds, FTAG);
     4731 +                dsl_pool_rele(dp, FTAG);
     4732 +                return (SET_ERROR(EINVAL));
     4733 +        }
     4734 +
     4735 +        error = dsl_dataset_hold_obj(dp,
     4736 +            dsl_dir_phys(ds->ds_dir)->dd_origin_obj, FTAG, &ods);
     4737 +        if (error != 0) {
     4738 +                dsl_dataset_rele(ds, FTAG);
     4739 +                dsl_pool_rele(dp, FTAG);
     4740 +                return (error);
     4741 +        }
     4742 +
     4743 +        dsl_dataset_name(ods, origin);
     4744 +        dsl_dataset_rele(ods, FTAG);
     4745 +        dsl_dataset_rele(ds, FTAG);
     4746 +        dsl_pool_rele(dp, FTAG);
     4747 +
4715 4748          /*
4716 4749           * We don't need to unmount *all* the origin fs's snapshots, but
4717 4750           * it's easier.
4718 4751           */
4719      -        cp = strchr(zc->zc_value, '@');
     4752 +        cp = strchr(origin, '@');
4720 4753          if (cp)
4721 4754                  *cp = '\0';
4722      -        (void) dmu_objset_find(zc->zc_value,
     4755 +        (void) dmu_objset_find(origin,
4723 4756              zfs_unmount_snap_cb, NULL, DS_FIND_SNAPSHOTS);
4724 4757          return (dsl_dataset_promote(zc->zc_name, zc->zc_string));
4725 4758  }
4726 4759  
4727 4760  /*
4728 4761   * Retrieve a single {user|group}{used|quota}@... property.
4729 4762   *
4730 4763   * inputs:
4731 4764   * zc_name      name of filesystem
4732 4765   * zc_objset_type zfs_userquota_prop_t
↓ open down ↓ 1586 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX