Print this page
NEX-9406 Add a property to show that a dataset has been modified since a snapshot
Reviewed by: Alexey Komarov <alexey.komarov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Fixup merge results
re #12585 rb4049 ZFS++ work port - refactoring to improve separation of open/closed code, bug fixes, performance improvements - open code
Bug 11205: add missing libzfs_closed_stubs.c to fix opensource-only build.
ZFS plus work: special vdevs, cos, cos/vdev properties


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 /*
  26  * Copyright (c) 2012 by Delphix. All rights reserved.

  27  */
  28 
  29 /*
  30  * Common routines used by zfs and zpool property management.
  31  */
  32 
  33 #include <sys/zio.h>
  34 #include <sys/spa.h>
  35 #include <sys/zfs_acl.h>
  36 #include <sys/zfs_ioctl.h>
  37 #include <sys/zfs_znode.h>
  38 #include <sys/fs/zfs.h>
  39 
  40 #include "zfs_prop.h"
  41 #include "zfs_deleg.h"
  42 
  43 #if defined(_KERNEL)
  44 #include <sys/systm.h>
  45 #include <util/qsort.h>
  46 #else
  47 #include <stdlib.h>
  48 #include <string.h>
  49 #include <ctype.h>
  50 #endif
  51 
  52 static zprop_desc_t *
  53 zprop_get_proptable(zfs_type_t type)
  54 {
  55         if (type == ZFS_TYPE_POOL)

  56                 return (zpool_prop_get_table());
  57         else




  58                 return (zfs_prop_get_table());

  59 }
  60 
  61 static int
  62 zprop_get_numprops(zfs_type_t type)
  63 {
  64         if (type == ZFS_TYPE_POOL)

  65                 return (ZPOOL_NUM_PROPS);
  66         else




  67                 return (ZFS_NUM_PROPS);

  68 }
  69 
  70 void
  71 zprop_register_impl(int prop, const char *name, zprop_type_t type,
  72     uint64_t numdefault, const char *strdefault, zprop_attr_t attr,
  73     int objset_types, const char *values, const char *colname,
  74     boolean_t rightalign, boolean_t visible, const zprop_index_t *idx_tbl)
  75 {
  76         zprop_desc_t *prop_tbl = zprop_get_proptable(objset_types);
  77         zprop_desc_t *pd;
  78 
  79         pd = &prop_tbl[prop];
  80 
  81         ASSERT(pd->pd_name == NULL || pd->pd_name == name);
  82         ASSERT(name != NULL);
  83         ASSERT(colname != NULL);
  84 
  85         pd->pd_name = name;
  86         pd->pd_propnum = prop;
  87         pd->pd_proptype = type;


 110 }
 111 
 112 void
 113 zprop_register_number(int prop, const char *name, uint64_t def,
 114     zprop_attr_t attr, int objset_types, const char *values,
 115     const char *colname)
 116 {
 117         zprop_register_impl(prop, name, PROP_TYPE_NUMBER, def, NULL, attr,
 118             objset_types, values, colname, B_TRUE, B_TRUE, NULL);
 119 }
 120 
 121 void
 122 zprop_register_index(int prop, const char *name, uint64_t def,
 123     zprop_attr_t attr, int objset_types, const char *values,
 124     const char *colname, const zprop_index_t *idx_tbl)
 125 {
 126         zprop_register_impl(prop, name, PROP_TYPE_INDEX, def, NULL, attr,
 127             objset_types, values, colname, B_TRUE, B_TRUE, idx_tbl);
 128 }
 129 










 130 void
 131 zprop_register_hidden(int prop, const char *name, zprop_type_t type,
 132     zprop_attr_t attr, int objset_types, const char *colname)
 133 {
 134         zprop_register_impl(prop, name, type, 0, NULL, attr,
 135             objset_types, NULL, colname,
 136             type == PROP_TYPE_NUMBER, B_FALSE, NULL);
 137 }
 138 
 139 
 140 /*
 141  * A comparison function we can use to order indexes into property tables.
 142  */
 143 static int
 144 zprop_compare(const void *arg1, const void *arg2)
 145 {
 146         const zprop_desc_t *p1 = *((zprop_desc_t **)arg1);
 147         const zprop_desc_t *p2 = *((zprop_desc_t **)arg2);
 148         boolean_t p1ro, p2ro;
 149 




   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.


  24  * Copyright (c) 2012 by Delphix. All rights reserved.
  25  * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
  26  */
  27 
  28 /*
  29  * Common routines used by zfs and zpool property management.
  30  */
  31 
  32 #include <sys/zio.h>
  33 #include <sys/spa.h>
  34 #include <sys/zfs_acl.h>
  35 #include <sys/zfs_ioctl.h>
  36 #include <sys/zfs_znode.h>
  37 #include <sys/fs/zfs.h>
  38 
  39 #include "zfs_prop.h"
  40 #include "zfs_deleg.h"
  41 
  42 #if defined(_KERNEL)
  43 #include <sys/systm.h>
  44 #include <util/qsort.h>
  45 #else
  46 #include <stdlib.h>
  47 #include <string.h>
  48 #include <ctype.h>
  49 #endif
  50 
  51 static zprop_desc_t *
  52 zprop_get_proptable(zfs_type_t type)
  53 {
  54         switch (type) {
  55         case ZFS_TYPE_POOL:
  56                 return (zpool_prop_get_table());
  57         case ZFS_TYPE_VDEV:
  58                 return (vdev_prop_get_table());
  59         case ZFS_TYPE_COS:
  60                 return (cos_prop_get_table());
  61         default:
  62                 return (zfs_prop_get_table());
  63         }
  64 }
  65 
  66 static int
  67 zprop_get_numprops(zfs_type_t type)
  68 {
  69         switch (type) {
  70         case ZFS_TYPE_POOL:
  71                 return (ZPOOL_NUM_PROPS);
  72         case ZFS_TYPE_VDEV:
  73                 return (VDEV_NUM_PROPS);
  74         case ZFS_TYPE_COS:
  75                 return (COS_NUM_PROPS);
  76         default:
  77                 return (ZFS_NUM_PROPS);
  78         }
  79 }
  80 
  81 void
  82 zprop_register_impl(int prop, const char *name, zprop_type_t type,
  83     uint64_t numdefault, const char *strdefault, zprop_attr_t attr,
  84     int objset_types, const char *values, const char *colname,
  85     boolean_t rightalign, boolean_t visible, const zprop_index_t *idx_tbl)
  86 {
  87         zprop_desc_t *prop_tbl = zprop_get_proptable(objset_types);
  88         zprop_desc_t *pd;
  89 
  90         pd = &prop_tbl[prop];
  91 
  92         ASSERT(pd->pd_name == NULL || pd->pd_name == name);
  93         ASSERT(name != NULL);
  94         ASSERT(colname != NULL);
  95 
  96         pd->pd_name = name;
  97         pd->pd_propnum = prop;
  98         pd->pd_proptype = type;


 121 }
 122 
 123 void
 124 zprop_register_number(int prop, const char *name, uint64_t def,
 125     zprop_attr_t attr, int objset_types, const char *values,
 126     const char *colname)
 127 {
 128         zprop_register_impl(prop, name, PROP_TYPE_NUMBER, def, NULL, attr,
 129             objset_types, values, colname, B_TRUE, B_TRUE, NULL);
 130 }
 131 
 132 void
 133 zprop_register_index(int prop, const char *name, uint64_t def,
 134     zprop_attr_t attr, int objset_types, const char *values,
 135     const char *colname, const zprop_index_t *idx_tbl)
 136 {
 137         zprop_register_impl(prop, name, PROP_TYPE_INDEX, def, NULL, attr,
 138             objset_types, values, colname, B_TRUE, B_TRUE, idx_tbl);
 139 }
 140 
 141 /* Same as zprop_register_index, except the property is hidden */
 142 void
 143 zprop_register_index_hidden(int prop, const char *name, uint64_t def,
 144     zprop_attr_t attr, int objset_types, const char *values,
 145     const char *colname, const zprop_index_t *idx_tbl)
 146 {
 147         zprop_register_impl(prop, name, PROP_TYPE_INDEX, def, NULL, attr,
 148             objset_types, values, colname, B_TRUE, B_FALSE, idx_tbl);
 149 }
 150 
 151 void
 152 zprop_register_hidden(int prop, const char *name, zprop_type_t type,
 153     zprop_attr_t attr, int objset_types, const char *colname)
 154 {
 155         zprop_register_impl(prop, name, type, 0, NULL, attr,
 156             objset_types, NULL, colname,
 157             type == PROP_TYPE_NUMBER, B_FALSE, NULL);
 158 }
 159 
 160 
 161 /*
 162  * A comparison function we can use to order indexes into property tables.
 163  */
 164 static int
 165 zprop_compare(const void *arg1, const void *arg2)
 166 {
 167         const zprop_desc_t *p1 = *((zprop_desc_t **)arg1);
 168         const zprop_desc_t *p2 = *((zprop_desc_t **)arg2);
 169         boolean_t p1ro, p2ro;
 170