Print this page
OS-1566 filesystem limits for ZFS datasets

@@ -959,10 +959,28 @@
                             propname);
                         (void) zfs_error(hdl, EZFS_PROPREADONLY, errbuf);
                         goto error;
                 }
 
+                /*
+                 * Special handling for "xxx_limit=none". In this case its not
+                 * 0 but MAXLIMIT.
+                 */
+                if ((prop == ZFS_PROP_FILESYSTEM_LIMIT ||
+                    prop == ZFS_PROP_SNAPSHOT_LIMIT) &&
+                    nvpair_type(elem) == DATA_TYPE_STRING) {
+                        (void) nvpair_value_string(elem, &strval);
+                        if (strcmp(strval, "none") == 0) {
+                                if (nvlist_add_uint64(ret, propname,
+                                    MAXLIMIT) != 0) {
+                                        (void) no_memory(hdl);
+                                        goto error;
+                                }
+                                continue;
+                        }
+                }
+
                 if (zprop_parse_value(hdl, elem, prop, type, ret,
                     &strval, &intval, errbuf) != 0)
                         goto error;
 
                 /*

@@ -2213,10 +2231,32 @@
                                 (void) snprintf(propbuf, proplen, "%llu",
                                     (u_longlong_t)val);
                         else
                                 zfs_nicenum(val, propbuf, proplen);
                 }
+                break;
+
+        case ZFS_PROP_FILESYSTEM_LIMIT:
+        case ZFS_PROP_SNAPSHOT_LIMIT:
+
+                if (get_numeric_property(zhp, prop, src, &source, &val) != 0)
+                        return (-1);
+
+                /*
+                 * If limit is MAXLIMIT, we translate this into 'none' (unless
+                 * literal is set), and indicate that it's the default value.
+                 * Otherwise, we print the number nicely and indicate that its
+                 * set locally.
+                 */
+                if (literal) {
+                        (void) snprintf(propbuf, proplen, "%llu",
+                            (u_longlong_t)val);
+                } else if (val == MAXLIMIT) {
+                        (void) strlcpy(propbuf, "none", proplen);
+                } else {
+                        zfs_nicenum(val, propbuf, proplen);
+                }
                 break;
 
         case ZFS_PROP_REFRATIO:
         case ZFS_PROP_COMPRESSRATIO:
                 if (get_numeric_property(zhp, prop, src, &source, &val) != 0)