summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorJustin T. Gibbs <[email protected]>2015-07-06 03:55:32 +0200
committerBrian Behlendorf <[email protected]>2015-07-10 12:11:45 -0700
commit99197f034ea0a7e227116e0cec00fe55061bffa7 (patch)
treed2394aefc5b53962c03542d763c6950b5ad36484 /module
parent15cfbb38fd6248529bf16f0cdc4ebb7adf38ab98 (diff)
Illumos 5661 - ZFS: "compression = on" should use lz4 if feature is enabled
5661 ZFS: "compression = on" should use lz4 if feature is enabled Reviewed by: Matthew Ahrens <[email protected]> Reviewed by: Josef 'Jeff' Sipek <[email protected]> Reviewed by: Xin LI <[email protected]> Approved by: Robert Mustacchi <[email protected]> References: https://github.com/illumos/illumos-gate/commit/db1741f https://www.illumos.org/issues/5661 Ported-by: kernelOfTruth [email protected] Signed-off-by: Brian Behlendorf <[email protected]> Closes #3571
Diffstat (limited to 'module')
-rw-r--r--module/zfs/dmu.c19
-rw-r--r--module/zfs/dmu_objset.c5
-rw-r--r--module/zfs/zio_compress.c23
3 files changed, 27 insertions, 20 deletions
diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c
index 7e8328e77..7d3945433 100644
--- a/module/zfs/dmu.c
+++ b/module/zfs/dmu.c
@@ -1864,19 +1864,15 @@ dmu_write_policy(objset_t *os, dnode_t *dn, int level, int wp, zio_prop_t *zp)
* 3. all other level 0 blocks
*/
if (ismd) {
- /*
- * XXX -- we should design a compression algorithm
- * that specializes in arrays of bps.
- */
- boolean_t lz4_ac = spa_feature_is_active(os->os_spa,
- SPA_FEATURE_LZ4_COMPRESS);
-
if (zfs_mdcomp_disable) {
compress = ZIO_COMPRESS_EMPTY;
- } else if (lz4_ac) {
- compress = ZIO_COMPRESS_LZ4;
} else {
- compress = ZIO_COMPRESS_LZJB;
+ /*
+ * XXX -- we should design a compression algorithm
+ * that specializes in arrays of bps.
+ */
+ compress = zio_compress_select(os->os_spa,
+ ZIO_COMPRESS_ON, ZIO_COMPRESS_ON);
}
/*
@@ -1909,7 +1905,8 @@ dmu_write_policy(objset_t *os, dnode_t *dn, int level, int wp, zio_prop_t *zp)
compress = ZIO_COMPRESS_OFF;
checksum = ZIO_CHECKSUM_OFF;
} else {
- compress = zio_compress_select(dn->dn_compress, compress);
+ compress = zio_compress_select(os->os_spa, dn->dn_compress,
+ compress);
checksum = (dedup_checksum == ZIO_CHECKSUM_OFF) ?
zio_checksum_select(dn->dn_checksum, checksum) :
diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c
index 823a15677..bd953dc36 100644
--- a/module/zfs/dmu_objset.c
+++ b/module/zfs/dmu_objset.c
@@ -163,7 +163,8 @@ compression_changed_cb(void *arg, uint64_t newval)
*/
ASSERT(newval != ZIO_COMPRESS_INHERIT);
- os->os_compress = zio_compress_select(newval, ZIO_COMPRESS_ON_VALUE);
+ os->os_compress = zio_compress_select(os->os_spa, newval,
+ ZIO_COMPRESS_ON);
}
static void
@@ -420,7 +421,7 @@ dmu_objset_open_impl(spa_t *spa, dsl_dataset_t *ds, blkptr_t *bp,
} else {
/* It's the meta-objset. */
os->os_checksum = ZIO_CHECKSUM_FLETCHER_4;
- os->os_compress = ZIO_COMPRESS_LZJB;
+ os->os_compress = ZIO_COMPRESS_ON;
os->os_copies = spa_max_replication(spa);
os->os_dedup_checksum = ZIO_CHECKSUM_OFF;
os->os_dedup_verify = B_FALSE;
diff --git a/module/zfs/zio_compress.c b/module/zfs/zio_compress.c
index 074462349..6b8d6c39b 100644
--- a/module/zfs/zio_compress.c
+++ b/module/zfs/zio_compress.c
@@ -34,6 +34,7 @@
#include <sys/zfs_context.h>
#include <sys/compress.h>
#include <sys/spa.h>
+#include <sys/zfeature.h>
#include <sys/zio.h>
#include <sys/zio_compress.h>
@@ -61,19 +62,27 @@ zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS] = {
};
enum zio_compress
-zio_compress_select(enum zio_compress child, enum zio_compress parent)
+zio_compress_select(spa_t *spa, enum zio_compress child,
+ enum zio_compress parent)
{
+ enum zio_compress result;
+
ASSERT(child < ZIO_COMPRESS_FUNCTIONS);
ASSERT(parent < ZIO_COMPRESS_FUNCTIONS);
- ASSERT(parent != ZIO_COMPRESS_INHERIT && parent != ZIO_COMPRESS_ON);
+ ASSERT(parent != ZIO_COMPRESS_INHERIT);
- if (child == ZIO_COMPRESS_INHERIT)
- return (parent);
+ result = child;
+ if (result == ZIO_COMPRESS_INHERIT)
+ result = parent;
- if (child == ZIO_COMPRESS_ON)
- return (ZIO_COMPRESS_ON_VALUE);
+ if (result == ZIO_COMPRESS_ON) {
+ if (spa_feature_is_active(spa, SPA_FEATURE_LZ4_COMPRESS))
+ result = ZIO_COMPRESS_LZ4_ON_VALUE;
+ else
+ result = ZIO_COMPRESS_LEGACY_ON_VALUE;
+ }
- return (child);
+ return (result);
}
size_t