Print this page
9286 want refreservation=auto

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libzfs/common/libzfs_util.c
          +++ new/usr/src/lib/libzfs/common/libzfs_util.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24      - * Copyright (c) 2013, Joyent, Inc. All rights reserved.
       24 + * Copyright (c) 2018 Joyent, Inc.
  25   25   * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
  26   26   * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
  27   27   * Copyright (c) 2017 Datto Inc.
  28   28   */
  29   29  
  30   30  /*
  31   31   * Internal utility routines for the ZFS library.
  32   32   */
  33   33  
  34   34  #include <errno.h>
↓ open down ↓ 1142 lines elided ↑ open up ↑
1177 1177  int
1178 1178  zprop_parse_value(libzfs_handle_t *hdl, nvpair_t *elem, int prop,
1179 1179      zfs_type_t type, nvlist_t *ret, char **svalp, uint64_t *ivalp,
1180 1180      const char *errbuf)
1181 1181  {
1182 1182          data_type_t datatype = nvpair_type(elem);
1183 1183          zprop_type_t proptype;
1184 1184          const char *propname;
1185 1185          char *value;
1186 1186          boolean_t isnone = B_FALSE;
     1187 +        boolean_t isauto = B_FALSE;
1187 1188  
1188 1189          if (type == ZFS_TYPE_POOL) {
1189 1190                  proptype = zpool_prop_get_type(prop);
1190 1191                  propname = zpool_prop_to_name(prop);
1191 1192          } else {
1192 1193                  proptype = zfs_prop_get_type(prop);
1193 1194                  propname = zfs_prop_to_name(prop);
1194 1195          }
1195 1196  
1196 1197          /*
↓ open down ↓ 15 lines elided ↑ open up ↑
1212 1213                              "'%s' is too long"), nvpair_name(elem));
1213 1214                          goto error;
1214 1215                  }
1215 1216                  break;
1216 1217  
1217 1218          case PROP_TYPE_NUMBER:
1218 1219                  if (datatype == DATA_TYPE_STRING) {
1219 1220                          (void) nvpair_value_string(elem, &value);
1220 1221                          if (strcmp(value, "none") == 0) {
1221 1222                                  isnone = B_TRUE;
1222      -                        } else if (zfs_nicestrtonum(hdl, value, ivalp)
1223      -                            != 0) {
     1223 +                        } else if (strcmp(value, "auto") == 0) {
     1224 +                                isauto = B_TRUE;
     1225 +                        } else if (zfs_nicestrtonum(hdl, value, ivalp) != 0) {
1224 1226                                  goto error;
1225 1227                          }
1226 1228                  } else if (datatype == DATA_TYPE_UINT64) {
1227 1229                          (void) nvpair_value_uint64(elem, ivalp);
1228 1230                  } else {
1229 1231                          zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
1230 1232                              "'%s' must be a number"), nvpair_name(elem));
1231 1233                          goto error;
1232 1234                  }
1233 1235  
↓ open down ↓ 9 lines elided ↑ open up ↑
1243 1245  
1244 1246                  /*
1245 1247                   * Special handling for "*_limit=none". In this case it's not
1246 1248                   * 0 but UINT64_MAX.
1247 1249                   */
1248 1250                  if ((type & ZFS_TYPE_DATASET) && isnone &&
1249 1251                      (prop == ZFS_PROP_FILESYSTEM_LIMIT ||
1250 1252                      prop == ZFS_PROP_SNAPSHOT_LIMIT)) {
1251 1253                          *ivalp = UINT64_MAX;
1252 1254                  }
     1255 +
     1256 +                /*
     1257 +                 * Special handling for setting 'reservation' and
     1258 +                 * 'refreservation' to 'auto'.  Use UINT64_MAX to tell the
     1259 +                 * caller to use zfs_fix_auto_resv().  'auto' is only allowed on
     1260 +                 * volumes.
     1261 +                 */
     1262 +                if (isauto) {
     1263 +                        switch (prop) {
     1264 +                        case ZFS_PROP_RESERVATION:
     1265 +                        case ZFS_PROP_REFRESERVATION:
     1266 +                                if ((type & ZFS_TYPE_VOLUME) == 0) {
     1267 +                                        zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
     1268 +                                            "'%s=auto' only allowed on "
     1269 +                                            "volumes"), nvpair_name(elem));
     1270 +                                        goto error;
     1271 +                                }
     1272 +                                *ivalp = UINT64_MAX;
     1273 +                                break;
     1274 +                        default:
     1275 +                                zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
     1276 +                                    "'auto' is invalid value for '%s'"),
     1277 +                                    nvpair_name(elem));
     1278 +                                goto error;
     1279 +                        }
     1280 +                }
     1281 +
1253 1282                  break;
1254 1283  
1255 1284          case PROP_TYPE_INDEX:
1256 1285                  if (datatype != DATA_TYPE_STRING) {
1257 1286                          zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
1258 1287                              "'%s' must be a string"), nvpair_name(elem));
1259 1288                          goto error;
1260 1289                  }
1261 1290  
1262 1291                  (void) nvpair_value_string(elem, &value);
↓ open down ↓ 302 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX