]> git.proxmox.com Git - mirror_zfs-debian.git/commitdiff
Illumos #1092: zfs refratio property
authorMatt Ahrens <Matt.Ahrens@delphix.com>
Tue, 26 Jul 2011 19:23:00 +0000 (12:23 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 1 Aug 2011 19:09:11 +0000 (12:09 -0700)
Add a "REFRATIO" property, which is the compression ratio based on
data referenced. For snapshots, this is the same as COMPRESSRATIO,
but for filesystems/volumes, the COMPRESSRATIO is based on the
data "USED" (ie, includes blocks in children, but not blocks
shared with the origin).

This is needed to figure out how much space a filesystem would
use if it were not compressed (ignoring snapshots).

Reviewed by: George Wilson <George.Wilson@delphix.com>
Reviewed by: Adam Leventhal <Adam.Leventhal@delphix.com>
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Reviewed by: Richard Elling <richard.elling@richardelling.com>
Reviewed by: Mark Musante <Mark.Musante@oracle.com>
Reviewed by: Garrett D'Amore <garrett@nexenta.com>
Approved by: Garrett D'Amore <garrett@nexenta.com>

References to Illumos issue and patch:
- https://www.illumos.org/issues/1092
- https://github.com/illumos/illumos-gate/commit/187d6ac08a

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #340

include/sys/fs/zfs.h
lib/libzfs/libzfs_dataset.c
man/man8/zfs.8
module/zcommon/zfs_prop.c
module/zfs/dsl_dataset.c

index a2b68eddfb340b150b73caa9c3d1072334a2bc16..2ac84f64502521fb483505ff31c8a96d59272dd5 100644 (file)
@@ -21,6 +21,7 @@
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011 by Delphix. All rights reserved.
  */
 
 /* Portions Copyright 2010 Robert Milkowski */
@@ -122,6 +123,7 @@ typedef enum {
        ZFS_PROP_DEDUP,
        ZFS_PROP_MLSLABEL,
        ZFS_PROP_SYNC,
+       ZFS_PROP_REFRATIO,
        ZFS_NUM_PROPS
 } zfs_prop_t;
 
index 5f8847a931052f28da8cb9773f392a54429afe4d..996bae2d7de7eeda3f167c888392f8fd69ba329a 100644 (file)
@@ -21,6 +21,7 @@
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011 by Delphix. All rights reserved.
  */
 
 #include <ctype.h>
@@ -2025,6 +2026,7 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
                }
                break;
 
+       case ZFS_PROP_REFRATIO:
        case ZFS_PROP_COMPRESSRATIO:
                if (get_numeric_property(zhp, prop, src, &source, &val) != 0)
                        return (-1);
index 3da2e44a7af927f6ebad0655acbb10c52ae58530..26dc6cadc122c68d67b2ed94d201b8f29a101f1f 100644 (file)
@@ -360,7 +360,7 @@ This property can also be referred to by its shortened column name, \fBavail\fR.
 .ad
 .sp .6
 .RS 4n
-The compression ratio achieved for this dataset, expressed as a multiplier. Compression can be turned on by running: \fBzfs set compression=on \fIdataset\fR\fR. The default value is \fBoff\fR.
+For non-snapshots, the compression ratio achieved for the \fBused\fR space of this dataset, expressed as a multiplier.  The \fBused\fR property includes descendant datasets, and, for clones, does not include the space shared with the origin snapshot.  For snapshots, the \fBcompressratio\fR is the same as the \fBrefcompressratio\fR property.  Compression can be turned on by running: \fBzfs set compression=on \fIdataset\fR\fR. The default value is \fBoff\fR.
 .RE
 
 .sp
@@ -420,6 +420,19 @@ The amount of data that is accessible by this dataset, which may or may not be s
 This property can also be referred to by its shortened column name, \fBrefer\fR.
 .RE
 
+.sp
+.ne 2
+.mk
+.na
+\fB\fBrefcompressratio\fR\fR
+.ad
+.sp .6
+.RS 4n
+The compression ratio achieved for the \fBreferenced\fR space of this
+dataset, expressed as a multiplier.  See also the \fBcompressratio\fR
+property.
+.RE
+
 .sp
 .ne 2
 .mk
@@ -1235,7 +1248,7 @@ Recursively destroy all dependents, including cloned file systems outside the ta
 Force an unmount of any file systems using the \fBunmount -f\fR command. This option has no effect on non-file systems or unmounted file systems.
 .RE
 
-Extreme care should be taken when applying either the \fB-r\fR or the \fB-f\fR options, as they can destroy large portions of a pool and cause unexpected behavior for mounted file systems in use. 
+Extreme care should be taken when applying either the \fB-r\fR or the \fB-R\fR options, as they can destroy large portions of a pool and cause unexpected behavior for mounted file systems in use.
 .RE
 
 .sp
index ce03a498c701f6b0b4c4c9d4eb3fc60d21c41792..9d65e35dea2cb9282c0030de705aaa9c27c44796 100644 (file)
@@ -20,6 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011 by Delphix. All rights reserved.
  */
 
 /* Portions Copyright 2010 Robert Milkowski */
@@ -311,6 +312,9 @@ zfs_prop_init(void)
        zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
            PROP_READONLY, ZFS_TYPE_DATASET,
            "<1.00x or higher if compressed>", "RATIO");
+       zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0,
+           PROP_READONLY, ZFS_TYPE_DATASET,
+           "<1.00x or higher if compressed>", "REFRATIO");
        zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize",
            ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME,
            ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK");
index c34ac2a76fbd802fa0a8f437eadfbc94f6bf9aeb..26362c95c1b6447ad5b0e9739eb3d46176bd515d 100644 (file)
@@ -20,6 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011 by Delphix. All rights reserved.
  */
 
 #include <sys/dmu_objset.h>
@@ -2153,7 +2154,7 @@ dsl_dataset_sync(dsl_dataset_t *ds, zio_t *zio, dmu_tx_t *tx)
 void
 dsl_dataset_stats(dsl_dataset_t *ds, nvlist_t *nv)
 {
-       uint64_t refd, avail, uobjs, aobjs;
+       uint64_t refd, avail, uobjs, aobjs, ratio;
 
        dsl_dir_stats(ds->ds_dir, nv);
 
@@ -2180,6 +2181,11 @@ dsl_dataset_stats(dsl_dataset_t *ds, nvlist_t *nv)
        dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_DEFER_DESTROY,
            DS_IS_DEFER_DESTROY(ds) ? 1 : 0);
 
+       ratio = ds->ds_phys->ds_compressed_bytes == 0 ? 100 :
+           (ds->ds_phys->ds_uncompressed_bytes * 100 /
+           ds->ds_phys->ds_compressed_bytes);
+       dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_REFRATIO, ratio);
+
        if (ds->ds_phys->ds_next_snap_obj) {
                /*
                 * This is a snapshot; override the dd's space used with
@@ -2187,10 +2193,7 @@ dsl_dataset_stats(dsl_dataset_t *ds, nvlist_t *nv)
                 */
                dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USED,
                    ds->ds_phys->ds_unique_bytes);
-               dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_COMPRESSRATIO,
-                   ds->ds_phys->ds_compressed_bytes == 0 ? 100 :
-                   (ds->ds_phys->ds_uncompressed_bytes * 100 /
-                   ds->ds_phys->ds_compressed_bytes));
+               dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_COMPRESSRATIO, ratio);
        }
 }