Print this page
OS-1566 filesystem limits for ZFS datasets

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libzfs/common/libzfs_dataset.c
          +++ new/usr/src/lib/libzfs/common/libzfs_dataset.c
↓ open down ↓ 953 lines elided ↑ open up ↑
 954  954  
 955  955                  if (zfs_prop_readonly(prop) &&
 956  956                      (!zfs_prop_setonce(prop) || zhp != NULL)) {
 957  957                          zfs_error_aux(hdl,
 958  958                              dgettext(TEXT_DOMAIN, "'%s' is readonly"),
 959  959                              propname);
 960  960                          (void) zfs_error(hdl, EZFS_PROPREADONLY, errbuf);
 961  961                          goto error;
 962  962                  }
 963  963  
      964 +                /*
      965 +                 * Special handling for "xxx_limit=none". In this case its not
      966 +                 * 0 but MAXLIMIT.
      967 +                 */
      968 +                if ((prop == ZFS_PROP_FILESYSTEM_LIMIT ||
      969 +                    prop == ZFS_PROP_SNAPSHOT_LIMIT) &&
      970 +                    nvpair_type(elem) == DATA_TYPE_STRING) {
      971 +                        (void) nvpair_value_string(elem, &strval);
      972 +                        if (strcmp(strval, "none") == 0) {
      973 +                                if (nvlist_add_uint64(ret, propname,
      974 +                                    MAXLIMIT) != 0) {
      975 +                                        (void) no_memory(hdl);
      976 +                                        goto error;
      977 +                                }
      978 +                                continue;
      979 +                        }
      980 +                }
      981 +
 964  982                  if (zprop_parse_value(hdl, elem, prop, type, ret,
 965  983                      &strval, &intval, errbuf) != 0)
 966  984                          goto error;
 967  985  
 968  986                  /*
 969  987                   * Perform some additional checks for specific properties.
 970  988                   */
 971  989                  switch (prop) {
 972  990                  case ZFS_PROP_VERSION:
 973  991                  {
↓ open down ↓ 1235 lines elided ↑ open up ↑
2209 2227                          else
2210 2228                                  (void) strlcpy(propbuf, "none", proplen);
2211 2229                  } else {
2212 2230                          if (literal)
2213 2231                                  (void) snprintf(propbuf, proplen, "%llu",
2214 2232                                      (u_longlong_t)val);
2215 2233                          else
2216 2234                                  zfs_nicenum(val, propbuf, proplen);
2217 2235                  }
2218 2236                  break;
     2237 +
     2238 +        case ZFS_PROP_FILESYSTEM_LIMIT:
     2239 +        case ZFS_PROP_SNAPSHOT_LIMIT:
     2240 +
     2241 +                if (get_numeric_property(zhp, prop, src, &source, &val) != 0)
     2242 +                        return (-1);
     2243 +
     2244 +                /*
     2245 +                 * If limit is MAXLIMIT, we translate this into 'none' (unless
     2246 +                 * literal is set), and indicate that it's the default value.
     2247 +                 * Otherwise, we print the number nicely and indicate that its
     2248 +                 * set locally.
     2249 +                 */
     2250 +                if (literal) {
     2251 +                        (void) snprintf(propbuf, proplen, "%llu",
     2252 +                            (u_longlong_t)val);
     2253 +                } else if (val == MAXLIMIT) {
     2254 +                        (void) strlcpy(propbuf, "none", proplen);
     2255 +                } else {
     2256 +                        zfs_nicenum(val, propbuf, proplen);
     2257 +                }
     2258 +                break;
2219 2259  
2220 2260          case ZFS_PROP_REFRATIO:
2221 2261          case ZFS_PROP_COMPRESSRATIO:
2222 2262                  if (get_numeric_property(zhp, prop, src, &source, &val) != 0)
2223 2263                          return (-1);
2224 2264                  (void) snprintf(propbuf, proplen, "%llu.%02llux",
2225 2265                      (u_longlong_t)(val / 100),
2226 2266                      (u_longlong_t)(val % 100));
2227 2267                  break;
2228 2268  
↓ open down ↓ 2178 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX