summaryrefslogtreecommitdiffstats
path: root/cddl/contrib
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2014-05-09 07:12:31 +0000
committerdelphij <delphij@FreeBSD.org>2014-05-09 07:12:31 +0000
commit7cb0f49ed2f136dd32fc5ce108ef3e244742098c (patch)
treef95691e1512ec1038738e6864508fb9da70312ea /cddl/contrib
parent1b18a5ca9893b654bc9a4eaecc7a79c02c93d3ef (diff)
downloadFreeBSD-src-7cb0f49ed2f136dd32fc5ce108ef3e244742098c.zip
FreeBSD-src-7cb0f49ed2f136dd32fc5ce108ef3e244742098c.tar.gz
MFC r264835 (MFV r264829):
3897 zfs filesystem and snapshot limits
Diffstat (limited to 'cddl/contrib')
-rw-r--r--cddl/contrib/opensolaris/cmd/zfs/zfs.859
-rw-r--r--cddl/contrib/opensolaris/cmd/zpool/zpool-features.719
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c29
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c11
4 files changed, 115 insertions, 3 deletions
diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 b/cddl/contrib/opensolaris/cmd/zfs/zfs.8
index d14ce13..b9760c4 100644
--- a/cddl/contrib/opensolaris/cmd/zfs/zfs.8
+++ b/cddl/contrib/opensolaris/cmd/zfs/zfs.8
@@ -24,13 +24,13 @@
.\" Copyright (c) 2012, Bryan Drewery <bdrewery@FreeBSD.org>
.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
.\" Copyright (c) 2013 Nexenta Systems, Inc. All Rights Reserved.
-.\" Copyright (c) 2013, Joyent, Inc. All rights reserved.
+.\" Copyright (c) 2014, Joyent, Inc. All rights reserved.
.\" Copyright (c) 2013, Steven Hartland <smh@FreeBSD.org>
.\" Copyright (c) 2014, Xin LI <delphij@FreeBSD.org>
.\"
.\" $FreeBSD$
.\"
-.Dd April 5, 2014
+.Dd April 23, 2014
.Dt ZFS 8
.Os
.Sh NAME
@@ -542,6 +542,13 @@ if the snapshot has been marked for deferred destroy by using the
.Qq Nm Cm destroy -d
command. Otherwise, the property is
.Cm off .
+.It Sy filesystem_count
+The total number of filesystems and volumes that exist under this location in the
+dataset tree.
+This value is only available when a
+.Sy filesystem_limit
+has
+been set somewhere in the tree under which the dataset resides.
.It Sy logicalreferenced
The amount of space that is
.Qq logically
@@ -600,6 +607,12 @@ The compression ratio achieved for the
space of this dataset, expressed as a multiplier. See also the
.Sy compressratio
property.
+.It Sy snapshot_count
+The total number of snapshots that exist under this location in the dataset tree.
+This value is only available when a
+.Sy snapshot_limit
+has been set somewhere
+in the tree under which the dataset resides.
.It Sy type
The type of dataset:
.Sy filesystem , volume , No or Sy snapshot .
@@ -1020,6 +1033,23 @@ The
.Sy mlslabel
property is currently not supported on
.Fx .
+.It Sy filesystem_limit Ns = Ns Ar count | Cm none
+Limits the number of filesystems and volumes that can exist under this point in
+the dataset tree.
+The limit is not enforced if the user is allowed to change
+the limit.
+Setting a
+.Sy filesystem_limit
+on a descendent of a filesystem that
+already has a
+.Sy filesystem_limit
+does not override the ancestor's
+.Sy filesystem_limit ,
+but rather imposes an additional limit.
+This feature must be enabled to be used
+.Po see
+.Xr zpool-features 7
+.Pc .
.It Sy mountpoint Ns = Ns Ar path | Cm none | legacy
Controls the mount point used for this file system. See the
.Qq Sx Mount Points
@@ -1061,6 +1091,27 @@ the ancestor's quota, but rather imposes an additional limit.
Quotas cannot be set on volumes, as the
.Sy volsize
property acts as an implicit quota.
+.It Sy snapshot_limit Ns = Ns Ar count | Cm none
+Limits the number of snapshots that can be created on a dataset and its
+descendents.
+Setting a
+.Sy snapshot_limit
+on a descendent of a dataset that already
+has a
+.Sy snapshot_limit
+does not override the ancestor's
+.Sy snapshot_limit ,
+but
+rather imposes an additional limit.
+The limit is not enforced if the user is
+allowed to change the limit.
+For example, this means that recursive snapshots
+taken from the global zone are counted against each delegated dataset within
+a jail.
+This feature must be enabled to be used
+.Po see
+.Xr zpool-features 7
+.Pc .
.It Sy userquota@ Ns Ar user Ns = Ns Ar size | Cm none
Limits the amount of space consumed by the specified user.
Similar to the
@@ -2738,6 +2789,7 @@ protocol
.It dedup Ta property
.It devices Ta property
.It exec Ta property
+.It filesystem_limit Ta property
.It logbias Ta property
.It jailed Ta property
.It mlslabel Ta property
@@ -2756,6 +2808,7 @@ protocol
.It sharenfs Ta property
.It sharesmb Ta property
.It snapdir Ta property
+.It snapshot_limit Ta property
.It sync Ta property
.It utf8only Ta property
.It version Ta property
@@ -3102,10 +3155,12 @@ pool/home/bob compression on local
pool/home/bob atime on default
pool/home/bob devices on default
pool/home/bob exec on default
+pool/home/bob filesystem_limit none default
pool/home/bob setuid on default
pool/home/bob readonly off default
pool/home/bob jailed off default
pool/home/bob snapdir hidden default
+pool/home/bob snapshot_limit none default
pool/home/bob aclmode discard default
pool/home/bob aclinherit restricted default
pool/home/bob canmount on default
diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 b/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7
index 5c6c47a..f9d866b 100644
--- a/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7
+++ b/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7
@@ -23,7 +23,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 2, 2014
+.Dd April 23, 2014
.Dt ZPOOL-FEATURES 7
.Os
.Sh NAME
@@ -187,6 +187,23 @@ This feature is
.Sy active
while there are any filesystems, volumes, or snapshots which were created
after enabling this feature.
+.It Sy filesystem_limits
+.Bl -column "READ\-ONLY COMPATIBLE" "com.joyent:filesystem_limits"
+.It GUID Ta com.joyent:filesystem_limits
+.It READ\-ONLY COMPATIBLE Ta yes
+.It DEPENDENCIES Ta extensible_dataset
+.El
+.Pp
+This feature enables filesystem and snapshot limits.
+These limits can be used
+to control how many filesystems and/or snapshots can be created at the point in
+the tree on which the limits are set.
+.Pp
+This feature is
+.Sy active
+once either of the limit properties has been
+set on a dataset.
+Once activated the feature is never deactivated.
.It Sy lz4_compress
.Bl -column "READ\-ONLY COMPATIBLE" "org.illumos:lz4_compress"
.It GUID Ta org.illumos:lz4_compress
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
index abde59b..5377cbd 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved.
* Copyright (c) 2011-2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
@@ -1910,6 +1911,10 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
case ZFS_PROP_REFQUOTA:
case ZFS_PROP_RESERVATION:
case ZFS_PROP_REFRESERVATION:
+ case ZFS_PROP_FILESYSTEM_LIMIT:
+ case ZFS_PROP_SNAPSHOT_LIMIT:
+ case ZFS_PROP_FILESYSTEM_COUNT:
+ case ZFS_PROP_SNAPSHOT_COUNT:
*val = getprop_uint64(zhp, prop, source);
if (*source == NULL) {
@@ -2315,6 +2320,30 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
}
break;
+ case ZFS_PROP_FILESYSTEM_LIMIT:
+ case ZFS_PROP_SNAPSHOT_LIMIT:
+ case ZFS_PROP_FILESYSTEM_COUNT:
+ case ZFS_PROP_SNAPSHOT_COUNT:
+
+ if (get_numeric_property(zhp, prop, src, &source, &val) != 0)
+ return (-1);
+
+ /*
+ * If limit is UINT64_MAX, 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 it's
+ * set locally.
+ */
+ if (literal) {
+ (void) snprintf(propbuf, proplen, "%llu",
+ (u_longlong_t)val);
+ } else if (val == UINT64_MAX) {
+ (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)
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
index 6823c07..3b59914 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
@@ -1268,6 +1269,16 @@ zprop_parse_value(libzfs_handle_t *hdl, nvpair_t *elem, int prop,
"use 'none' to disable quota/refquota"));
goto error;
}
+
+ /*
+ * Special handling for "*_limit=none". In this case it's not
+ * 0 but UINT64_MAX.
+ */
+ if ((type & ZFS_TYPE_DATASET) && isnone &&
+ (prop == ZFS_PROP_FILESYSTEM_LIMIT ||
+ prop == ZFS_PROP_SNAPSHOT_LIMIT)) {
+ *ivalp = UINT64_MAX;
+ }
break;
case PROP_TYPE_INDEX:
OpenPOWER on IntegriCloud