]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Replace ZPROP_INVAL with ZPROP_USERPROP where it means a user property
authorAllan Jude <allan@klarasystems.com>
Tue, 14 Jun 2022 18:27:53 +0000 (14:27 -0400)
committerGitHub <noreply@github.com>
Tue, 14 Jun 2022 18:27:53 +0000 (11:27 -0700)
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Sponsored-by: Klara Inc.
Closes #12676

12 files changed:
cmd/zfs/zfs_iter.c
cmd/zfs/zfs_main.c
cmd/zpool/zpool_main.c
include/sys/fs/zfs.h
lib/libzfs/libzfs_dataset.c
lib/libzfs/libzfs_pool.c
lib/libzfs/libzfs_sendrecv.c
lib/libzfs/libzfs_util.c
module/zfs/dsl_prop.c
module/zfs/vdev.c
module/zfs/zcp_synctask.c
module/zfs/zfs_ioctl.c

index d44bc2ad7621c5a1b8c9d98291b569076ea83238..c0426d4f81ea7218185595ee365bef67b9b8708a 100644 (file)
@@ -174,7 +174,7 @@ zfs_add_sort_column(zfs_sort_column_t **sc, const char *name,
        zfs_sort_column_t *col;
        zfs_prop_t prop;
 
-       if ((prop = zfs_name_to_prop(name)) == ZPROP_INVAL &&
+       if ((prop = zfs_name_to_prop(name)) == ZPROP_USERPROP &&
            !zfs_prop_user(name))
                return (-1);
 
@@ -182,7 +182,7 @@ zfs_add_sort_column(zfs_sort_column_t **sc, const char *name,
 
        col->sc_prop = prop;
        col->sc_reverse = reverse;
-       if (prop == ZPROP_INVAL) {
+       if (prop == ZPROP_USERPROP) {
                col->sc_user_prop = safe_malloc(strlen(name) + 1);
                (void) strcpy(col->sc_user_prop, name);
        }
@@ -311,7 +311,7 @@ zfs_sort(const void *larg, const void *rarg, void *data)
                 * Otherwise, we compare 'lnum' and 'rnum'.
                 */
                lstr = rstr = NULL;
-               if (psc->sc_prop == ZPROP_INVAL) {
+               if (psc->sc_prop == ZPROP_USERPROP) {
                        nvlist_t *luser, *ruser;
                        nvlist_t *lval, *rval;
 
index 30b2ae0c4b4fb59713b209d708847e7c44b994de..3cb88b6a1a155ca43f44d1f8661a322c41163ca7 100644 (file)
@@ -1917,7 +1917,7 @@ get_callback(zfs_handle_t *zhp, void *data)
                    pl == cbp->cb_proplist)
                        continue;
 
-               if (pl->pl_prop != ZPROP_INVAL) {
+               if (pl->pl_prop != ZPROP_USERPROP) {
                        if (zfs_prop_get(zhp, pl->pl_prop, buf,
                            sizeof (buf), &sourcetype, source,
                            sizeof (source),
@@ -2307,7 +2307,7 @@ zfs_do_inherit(int argc, char **argv)
        argc--;
        argv++;
 
-       if ((prop = zfs_name_to_prop(propname)) != ZPROP_INVAL) {
+       if ((prop = zfs_name_to_prop(propname)) != ZPROP_USERPROP) {
                if (zfs_prop_readonly(prop)) {
                        (void) fprintf(stderr, gettext(
                            "%s property is read-only\n"),
@@ -3443,7 +3443,7 @@ print_header(list_cbdata_t *cb)
                }
 
                right_justify = B_FALSE;
-               if (pl->pl_prop != ZPROP_INVAL) {
+               if (pl->pl_prop != ZPROP_USERPROP) {
                        header = zfs_prop_column_name(pl->pl_prop);
                        right_justify = zfs_prop_align_right(pl->pl_prop);
                } else {
@@ -3494,7 +3494,7 @@ print_dataset(zfs_handle_t *zhp, list_cbdata_t *cb)
                            sizeof (property));
                        propstr = property;
                        right_justify = zfs_prop_align_right(pl->pl_prop);
-               } else if (pl->pl_prop != ZPROP_INVAL) {
+               } else if (pl->pl_prop != ZPROP_USERPROP) {
                        if (zfs_prop_get(zhp, pl->pl_prop, property,
                            sizeof (property), NULL, NULL, 0,
                            cb->cb_literal) != 0)
index 598d8b1bbb6587f2629a5c1ece1232b170d2802c..a0aeb8c06bd73a78cf9b51e8f4a77b1aeeb10fb4 100644 (file)
@@ -5946,7 +5946,7 @@ print_header(list_cbdata_t *cb)
                        first = B_FALSE;
 
                right_justify = B_FALSE;
-               if (pl->pl_prop != ZPROP_INVAL) {
+               if (pl->pl_prop != ZPROP_USERPROP) {
                        header = zpool_prop_column_name(pl->pl_prop);
                        right_justify = zpool_prop_align_right(pl->pl_prop);
                } else {
@@ -6004,7 +6004,7 @@ print_pool(zpool_handle_t *zhp, list_cbdata_t *cb)
                }
 
                right_justify = B_FALSE;
-               if (pl->pl_prop != ZPROP_INVAL) {
+               if (pl->pl_prop != ZPROP_USERPROP) {
                        if (zpool_get_prop(zhp, pl->pl_prop, property,
                            sizeof (property), NULL, cb->cb_literal) != 0)
                                propstr = "-";
index bc6666a2a1b7f65a9c47cf4ca07e854f8e571855..f013e6b2060327deb6be82762bc315f08646e940 100644 (file)
@@ -93,6 +93,7 @@ typedef enum dmu_objset_type {
 typedef enum {
        ZPROP_CONT = -2,
        ZPROP_INVAL = -1,
+       ZPROP_USERPROP = ZPROP_INVAL,
        ZFS_PROP_TYPE = 0,
        ZFS_PROP_CREATION,
        ZFS_PROP_USED,
@@ -310,7 +311,7 @@ typedef int (*zprop_func)(int, void *);
  */
 typedef enum {
        VDEV_PROP_INVAL = -1,
-#define        VDEV_PROP_USER  VDEV_PROP_INVAL
+       VDEV_PROP_USERPROP = VDEV_PROP_INVAL,
        VDEV_PROP_NAME,
        VDEV_PROP_CAPACITY,
        VDEV_PROP_STATE,
index b449fabdf5348806c314f95816f6d5cf34413492..24d9b81f4976cfd7cd357ebec69934f9c95dd2c4 100644 (file)
@@ -1022,7 +1022,7 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
                const char *propname = nvpair_name(elem);
 
                prop = zfs_name_to_prop(propname);
-               if (prop == ZPROP_INVAL && zfs_prop_user(propname)) {
+               if (prop == ZPROP_USERPROP && zfs_prop_user(propname)) {
                        /*
                         * This is a user property: make sure it's a
                         * string, and that it's less than ZAP_MAXNAMELEN.
@@ -1061,7 +1061,7 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
                        goto error;
                }
 
-               if (prop == ZPROP_INVAL && zfs_prop_userquota(propname)) {
+               if (prop == ZPROP_USERPROP && zfs_prop_userquota(propname)) {
                        zfs_userquota_prop_t uqtype;
                        char *newpropname = NULL;
                        char domain[128];
@@ -1143,7 +1143,8 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
                        }
                        free(newpropname);
                        continue;
-               } else if (prop == ZPROP_INVAL && zfs_prop_written(propname)) {
+               } else if (prop == ZPROP_USERPROP &&
+                   zfs_prop_written(propname)) {
                        zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
                            "'%s' is readonly"),
                            propname);
@@ -1937,7 +1938,7 @@ zfs_prop_inherit(zfs_handle_t *zhp, const char *propname, boolean_t received)
            "cannot inherit %s for '%s'"), propname, zhp->zfs_name);
 
        zc.zc_cookie = received;
-       if ((prop = zfs_name_to_prop(propname)) == ZPROP_INVAL) {
+       if ((prop = zfs_name_to_prop(propname)) == ZPROP_USERPROP) {
                /*
                 * For user properties, the amount of work we have to do is very
                 * small, so just do it here.
@@ -2356,7 +2357,7 @@ zfs_prop_get_recvd(zfs_handle_t *zhp, const char *propname, char *propbuf,
 
        prop = zfs_name_to_prop(propname);
 
-       if (prop != ZPROP_INVAL) {
+       if (prop != ZPROP_USERPROP) {
                uint64_t cookie;
                if (!nvlist_exists(zhp->zfs_recvd_props, propname))
                        return (-1);
@@ -4635,7 +4636,7 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp, boolean_t received,
                 */
                start = plp;
                while (*start != NULL) {
-                       if ((*start)->pl_prop == ZPROP_INVAL)
+                       if ((*start)->pl_prop == ZPROP_USERPROP)
                                break;
                        start = &(*start)->pl_next;
                }
@@ -4656,7 +4657,7 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp, boolean_t received,
                                entry = zfs_alloc(hdl, sizeof (zprop_list_t));
                                entry->pl_user_prop =
                                    zfs_strdup(hdl, nvpair_name(elem));
-                               entry->pl_prop = ZPROP_INVAL;
+                               entry->pl_prop = ZPROP_USERPROP;
                                entry->pl_width = strlen(nvpair_name(elem));
                                entry->pl_all = B_TRUE;
                                *last = entry;
@@ -4671,7 +4672,7 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp, boolean_t received,
                if (entry->pl_fixed && !literal)
                        continue;
 
-               if (entry->pl_prop != ZPROP_INVAL) {
+               if (entry->pl_prop != ZPROP_USERPROP) {
                        if (zfs_prop_get(zhp, entry->pl_prop,
                            buf, sizeof (buf), NULL, NULL, 0, literal) == 0) {
                                if (strlen(buf) > entry->pl_width)
@@ -4720,13 +4721,14 @@ zfs_prune_proplist(zfs_handle_t *zhp, uint8_t *props)
                next = nvlist_next_nvpair(zhp->zfs_props, curr);
 
                /*
-                * User properties will result in ZPROP_INVAL, and since we
+                * User properties will result in ZPROP_USERPROP (an alias
+                * for ZPROP_INVAL), and since we
                 * only know how to prune standard ZFS properties, we always
                 * leave these in the list.  This can also happen if we
                 * encounter an unknown DSL property (when running older
                 * software, for example).
                 */
-               if (zfs_prop != ZPROP_INVAL && props[zfs_prop] == B_FALSE)
+               if (zfs_prop != ZPROP_USERPROP && props[zfs_prop] == B_FALSE)
                        (void) nvlist_remove(zhp->zfs_props,
                            nvpair_name(curr), nvpair_type(curr));
                curr = next;
index 73283505a10b2dba9866e2bb3a69659345f90649..8333e0e786eb683080310a01ecc462a7adae41ce 100644 (file)
@@ -854,7 +854,7 @@ zpool_expand_proplist(zpool_handle_t *zhp, zprop_list_t **plp,
                for (i = 0; i < SPA_FEATURES; i++) {
                        zprop_list_t *entry = zfs_alloc(hdl,
                            sizeof (zprop_list_t));
-                       entry->pl_prop = ZPROP_INVAL;
+                       entry->pl_prop = ZPROP_USERPROP;
                        entry->pl_user_prop = zfs_asprintf(hdl, "feature@%s",
                            spa_feature_table[i].fi_uname);
                        entry->pl_width = strlen(entry->pl_user_prop);
@@ -898,7 +898,7 @@ zpool_expand_proplist(zpool_handle_t *zhp, zprop_list_t **plp,
                }
 
                entry = zfs_alloc(hdl, sizeof (zprop_list_t));
-               entry->pl_prop = ZPROP_INVAL;
+               entry->pl_prop = ZPROP_USERPROP;
                entry->pl_user_prop = propname;
                entry->pl_width = strlen(entry->pl_user_prop);
                entry->pl_all = B_TRUE;
@@ -911,7 +911,7 @@ zpool_expand_proplist(zpool_handle_t *zhp, zprop_list_t **plp,
                if (entry->pl_fixed && !literal)
                        continue;
 
-               if (entry->pl_prop != ZPROP_INVAL &&
+               if (entry->pl_prop != ZPROP_USERPROP &&
                    zpool_get_prop(zhp, entry->pl_prop, buf, sizeof (buf),
                    NULL, literal) == 0) {
                        if (strlen(buf) > entry->pl_width)
@@ -967,7 +967,7 @@ vdev_expand_proplist(zpool_handle_t *zhp, const char *vdevname,
 
                        /* Skip properties that are not user defined */
                        if ((prop = vdev_name_to_prop(propname)) !=
-                           VDEV_PROP_USER)
+                           VDEV_PROP_USERPROP)
                                continue;
 
                        if (nvpair_value_nvlist(elem, &propval) != 0)
@@ -5033,7 +5033,7 @@ zpool_get_vdev_prop_value(nvlist_t *nvprop, vdev_prop_t prop, char *prop_name,
        uint64_t intval;
        zprop_source_t src = ZPROP_SRC_NONE;
 
-       if (prop == VDEV_PROP_USER) {
+       if (prop == VDEV_PROP_USERPROP) {
                /* user property, prop_name must contain the property name */
                assert(prop_name != NULL);
                if (nvlist_lookup_nvlist(nvprop, prop_name, &nv) == 0) {
@@ -5195,7 +5195,7 @@ zpool_get_vdev_prop(zpool_handle_t *zhp, const char *vdevname, vdev_prop_t prop,
 
        fnvlist_add_uint64(reqnvl, ZPOOL_VDEV_PROPS_GET_VDEV, vdev_guid);
 
-       if (prop != VDEV_PROP_USER) {
+       if (prop != VDEV_PROP_USERPROP) {
                /* prop_name overrides prop value */
                if (prop_name != NULL)
                        prop = vdev_name_to_prop(prop_name);
index 683813ee3ba9af8640bb470301443af4e7877cae..f7b2a0e870f3264e41fa2eac1e8d5df4f44b1de8 100644 (file)
@@ -5107,7 +5107,7 @@ zfs_receive_checkprops(libzfs_handle_t *hdl, nvlist_t *props,
                name = nvpair_name(nvp);
                prop = zfs_name_to_prop(name);
 
-               if (prop == ZPROP_INVAL) {
+               if (prop == ZPROP_USERPROP) {
                        if (!zfs_prop_user(name)) {
                                zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
                                    "%s: invalid property '%s'"), errbuf, name);
index 1d40cbbfcaa701873d3db4c51918d0e690b269b6..3ab82c350fd5867e8661a7a45d9a2a88dc09cdda 100644 (file)
@@ -1282,7 +1282,7 @@ zprop_print_headers(zprop_get_cbdata_t *cbp, zfs_type_t type)
                /*
                 * 'PROPERTY' column
                 */
-               if (pl->pl_prop != ZPROP_INVAL) {
+               if (pl->pl_prop != ZPROP_USERPROP) {
                        const char *propname = (type == ZFS_TYPE_POOL) ?
                            zpool_prop_to_name(pl->pl_prop) :
                            ((type == ZFS_TYPE_VDEV) ?
@@ -1755,7 +1755,7 @@ addlist(libzfs_handle_t *hdl, const char *propname, zprop_list_t **listp,
         * Return failure if no property table entry was found and this isn't
         * a user-defined property.
         */
-       if (prop == ZPROP_INVAL && ((type == ZFS_TYPE_POOL &&
+       if (prop == ZPROP_USERPROP && ((type == ZFS_TYPE_POOL &&
            !zpool_prop_feature(propname) &&
            !zpool_prop_unsupported(propname)) ||
            ((type == ZFS_TYPE_DATASET) && !zfs_prop_user(propname) &&
@@ -1770,7 +1770,7 @@ addlist(libzfs_handle_t *hdl, const char *propname, zprop_list_t **listp,
        zprop_list_t *entry = zfs_alloc(hdl, sizeof (*entry));
 
        entry->pl_prop = prop;
-       if (prop == ZPROP_INVAL) {
+       if (prop == ZPROP_USERPROP) {
                entry->pl_user_prop = zfs_strdup(hdl, propname);
                entry->pl_width = strlen(propname);
        } else {
index cfdafd2f443642be7177277fde226e0993f90d27..51d689355ef0dec0d7ec6e9863d51650135cbae6 100644 (file)
@@ -88,7 +88,7 @@ dsl_prop_get_dd(dsl_dir_t *dd, const char *propname,
                setpoint[0] = '\0';
 
        prop = zfs_name_to_prop(propname);
-       inheritable = (prop == ZPROP_INVAL || zfs_prop_inheritable(prop));
+       inheritable = (prop == ZPROP_USERPROP || zfs_prop_inheritable(prop));
        inheritstr = kmem_asprintf("%s%s", propname, ZPROP_INHERIT_SUFFIX);
        recvdstr = kmem_asprintf("%s%s", propname, ZPROP_RECVD_SUFFIX);
 
@@ -168,7 +168,7 @@ dsl_prop_get_ds(dsl_dataset_t *ds, const char *propname,
        uint64_t zapobj;
 
        ASSERT(dsl_pool_config_held(ds->ds_dir->dd_pool));
-       inheritable = (prop == ZPROP_INVAL || zfs_prop_inheritable(prop));
+       inheritable = (prop == ZPROP_USERPROP || zfs_prop_inheritable(prop));
        zapobj = dsl_dataset_phys(ds)->ds_props_obj;
 
        if (zapobj != 0) {
@@ -1055,12 +1055,12 @@ dsl_prop_get_all_impl(objset_t *mos, uint64_t propobj,
                prop = zfs_name_to_prop(propname);
 
                /* Skip non-inheritable properties. */
-               if ((flags & DSL_PROP_GET_INHERITING) && prop != ZPROP_INVAL &&
-                   !zfs_prop_inheritable(prop))
+               if ((flags & DSL_PROP_GET_INHERITING) &&
+                   prop != ZPROP_USERPROP && !zfs_prop_inheritable(prop))
                        continue;
 
                /* Skip properties not valid for this type. */
-               if ((flags & DSL_PROP_GET_SNAPSHOT) && prop != ZPROP_INVAL &&
+               if ((flags & DSL_PROP_GET_SNAPSHOT) && prop != ZPROP_USERPROP &&
                    !zfs_prop_valid_for_type(prop, ZFS_TYPE_SNAPSHOT, B_FALSE))
                        continue;
 
index ce7f020a0d86f701953aabc8e5456ca702954f9a..2dcb97b7feb47c23f23acd8505f23fdc9c3d3f23 100644 (file)
@@ -5496,7 +5496,7 @@ vdev_props_set_sync(void *arg, dmu_tx_t *tx)
                }
 
                switch (prop = vdev_name_to_prop(propname)) {
-               case VDEV_PROP_USER:
+               case VDEV_PROP_USERPROP:
                        if (vdev_prop_user(propname)) {
                                strval = fnvpair_value_string(elem);
                                if (strlen(strval) == 0) {
@@ -5580,7 +5580,7 @@ vdev_prop_set(vdev_t *vd, nvlist_t *innvl, nvlist_t *outnvl)
                uint64_t intval = 0;
                char *strval = NULL;
 
-               if (prop == VDEV_PROP_USER && !vdev_prop_user(propname)) {
+               if (prop == VDEV_PROP_USERPROP && !vdev_prop_user(propname)) {
                        error = EINVAL;
                        goto end;
                }
@@ -5937,7 +5937,7 @@ vdev_prop_get(vdev_t *vd, nvlist_t *innvl, nvlist_t *outnvl)
                        case VDEV_PROP_COMMENT:
                                /* Exists in the ZAP below */
                                /* FALLTHRU */
-                       case VDEV_PROP_USER:
+                       case VDEV_PROP_USERPROP:
                                /* User Properites */
                                src = ZPROP_SRC_LOCAL;
 
index 403856ae3571fd9e79d3bef44557aec5da265bf6..24210117eca0443f6b846dc28c53fd9d257e6a10 100644 (file)
@@ -325,7 +325,7 @@ zcp_synctask_inherit_prop_check(void *arg, dmu_tx_t *tx)
        zcp_inherit_prop_arg_t *args = arg;
        zfs_prop_t prop = zfs_name_to_prop(args->zipa_prop);
 
-       if (prop == ZPROP_INVAL) {
+       if (prop == ZPROP_USERPROP) {
                if (zfs_prop_user(args->zipa_prop))
                        return (0);
 
index b3f32d64f3efd356961c4fad5c27198c094e35b9..35aec522623303c1d70d85f58579275039a5b72d 100644 (file)
@@ -1104,7 +1104,7 @@ zfs_secpolicy_inherit_prop(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
        (void) innvl;
        zfs_prop_t prop = zfs_name_to_prop(zc->zc_value);
 
-       if (prop == ZPROP_INVAL) {
+       if (prop == ZPROP_USERPROP) {
                if (!zfs_prop_user(zc->zc_value))
                        return (SET_ERROR(EINVAL));
                return (zfs_secpolicy_write_perms(zc->zc_name,
@@ -2406,7 +2406,7 @@ zfs_prop_set_special(const char *dsname, zprop_source_t source,
        const char *strval = NULL;
        int err = -1;
 
-       if (prop == ZPROP_INVAL) {
+       if (prop == ZPROP_USERPROP) {
                if (zfs_prop_userquota(propname))
                        return (zfs_prop_set_userquota(dsname, pair));
                return (-1);
@@ -2577,7 +2577,7 @@ retry:
                        /* inherited properties are expected to be booleans */
                        if (nvpair_type(propval) != DATA_TYPE_BOOLEAN)
                                err = SET_ERROR(EINVAL);
-               } else if (err == 0 && prop == ZPROP_INVAL) {
+               } else if (err == 0 && prop == ZPROP_USERPROP) {
                        if (zfs_prop_user(propname)) {
                                if (nvpair_type(propval) != DATA_TYPE_STRING)
                                        err = SET_ERROR(EINVAL);
@@ -2853,11 +2853,11 @@ zfs_ioc_inherit_prop(zfs_cmd_t *zc)
                 * and reservation to the received or default values even though
                 * they are not considered inheritable.
                 */
-               if (prop != ZPROP_INVAL && !zfs_prop_inheritable(prop))
+               if (prop != ZPROP_USERPROP && !zfs_prop_inheritable(prop))
                        return (SET_ERROR(EINVAL));
        }
 
-       if (prop == ZPROP_INVAL) {
+       if (prop == ZPROP_USERPROP) {
                if (!zfs_prop_user(propname))
                        return (SET_ERROR(EINVAL));
 
@@ -4488,7 +4488,7 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
        uint64_t intval, compval;
        int err;
 
-       if (prop == ZPROP_INVAL) {
+       if (prop == ZPROP_USERPROP) {
                if (zfs_prop_user(propname)) {
                        if ((err = zfs_secpolicy_write_perms(dsname,
                            ZFS_DELEG_PERM_USERPROP, cr)))
@@ -5034,7 +5034,7 @@ zfs_ioc_recv_impl(char *tofs, char *tosnap, char *origin, nvlist_t *recvprops,
                                /* -x property */
                                const char *name = nvpair_name(nvp);
                                zfs_prop_t prop = zfs_name_to_prop(name);
-                               if (prop != ZPROP_INVAL) {
+                               if (prop != ZPROP_USERPROP) {
                                        if (!zfs_prop_inheritable(prop))
                                                continue;
                                } else if (!zfs_prop_user(name))