aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorDaniil Lunev <[email protected]>2014-10-18 11:58:11 -0400
committerBrian Behlendorf <[email protected]>2014-10-20 16:17:49 -0700
commit62bdd5eb7a35288cc25c5ae968bcd0f08889f986 (patch)
tree35760de9fb45f308b375401b99a919aeb1ccaeb3 /module
parentba232d8aead62e2af9c195c2802b89dbc891d5ef (diff)
Illumos 4924 - LZ4 Compression for metadata
Reviewed by Matthew Ahrens <[email protected]> Reviewed by Saso Kiselkov <[email protected]> Approved by: Christopher Siden <[email protected]> References: https://github.com/illumos/illumos-gate/commit/b8289d2 https://www.illumos.org/issues/3756 Porting notes: The static function zfs_prop_activate_feature() was removed because this change removes the only caller. The function was not removed from Illumos but instead left as dead code. However, to keep gcc happy it was removed from Linux and may be easily restored if needed. Ported by: DHE <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #1540
Diffstat (limited to 'module')
-rw-r--r--module/zfs/dmu.c14
-rw-r--r--module/zfs/spa.c18
-rw-r--r--module/zfs/zfeature_common.c3
-rw-r--r--module/zfs/zfs_ioctl.c84
4 files changed, 32 insertions, 87 deletions
diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c
index b2def0d80..a8e6ae1fd 100644
--- a/module/zfs/dmu.c
+++ b/module/zfs/dmu.c
@@ -22,6 +22,7 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
+ * Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/dmu.h>
@@ -43,6 +44,7 @@
#include <sys/zio_checksum.h>
#include <sys/zio_compress.h>
#include <sys/sa.h>
+#include <sys/zfeature.h>
#ifdef _KERNEL
#include <sys/vmsystm.h>
#include <sys/zfs_znode.h>
@@ -1765,8 +1767,16 @@ dmu_write_policy(objset_t *os, dnode_t *dn, int level, int wp, zio_prop_t *zp)
* XXX -- we should design a compression algorithm
* that specializes in arrays of bps.
*/
- compress = zfs_mdcomp_disable ? ZIO_COMPRESS_EMPTY :
- ZIO_COMPRESS_LZJB;
+ 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;
+ }
/*
* Metadata always gets checksummed. If the data
diff --git a/module/zfs/spa.c b/module/zfs/spa.c
index 1b1bf7a5c..776beda11 100644
--- a/module/zfs/spa.c
+++ b/module/zfs/spa.c
@@ -22,7 +22,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
- * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2013, 2014, Nexenta Systems, Inc. All rights reserved.
*/
/*
@@ -6209,6 +6209,22 @@ spa_sync_upgrades(spa_t *spa, dmu_tx_t *tx)
spa->spa_uberblock.ub_version >= SPA_VERSION_FEATURES) {
spa_feature_create_zap_objects(spa, tx);
}
+
+ /*
+ * LZ4_COMPRESS feature's behaviour was changed to activate_on_enable
+ * when possibility to use lz4 compression for metadata was added
+ * Old pools that have this feature enabled must be upgraded to have
+ * this feature active
+ */
+ if (spa->spa_uberblock.ub_version >= SPA_VERSION_FEATURES) {
+ boolean_t lz4_en = spa_feature_is_enabled(spa,
+ SPA_FEATURE_LZ4_COMPRESS);
+ boolean_t lz4_ac = spa_feature_is_active(spa,
+ SPA_FEATURE_LZ4_COMPRESS);
+
+ if (lz4_en && !lz4_ac)
+ spa_feature_incr(spa, SPA_FEATURE_LZ4_COMPRESS, tx);
+ }
rrw_exit(&dp->dp_config_rwlock, FTAG);
}
diff --git a/module/zfs/zfeature_common.c b/module/zfs/zfeature_common.c
index f99e5349e..a90144822 100644
--- a/module/zfs/zfeature_common.c
+++ b/module/zfs/zfeature_common.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
+ * Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved.
*/
#ifdef _KERNEL
@@ -174,7 +175,7 @@ zpool_feature_init(void)
zfeature_register(SPA_FEATURE_LZ4_COMPRESS,
"org.illumos:lz4_compress", "lz4_compress",
"LZ4 compression algorithm support.", B_FALSE, B_FALSE,
- B_FALSE, NULL);
+ B_TRUE, NULL);
zfeature_register(SPA_FEATURE_SPACEMAP_HISTOGRAM,
"com.delphix:spacemap_histogram", "spacemap_histogram",
diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c
index 491ba492c..37a893c47 100644
--- a/module/zfs/zfs_ioctl.c
+++ b/module/zfs/zfs_ioctl.c
@@ -29,6 +29,7 @@
* Copyright (c) 201i3 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
+ * Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved.
*/
/*
@@ -246,8 +247,6 @@ static int zfs_fill_zplprops_root(uint64_t, nvlist_t *, nvlist_t *,
int zfs_set_prop_nvlist(const char *, zprop_source_t, nvlist_t *, nvlist_t *);
static int get_nvlist(uint64_t nvl, uint64_t size, int iflag, nvlist_t **nvp);
-static int zfs_prop_activate_feature(spa_t *spa, spa_feature_t feature);
-
static void
history_str_free(char *buf)
{
@@ -2402,37 +2401,6 @@ zfs_prop_set_special(const char *dsname, zprop_source_t source,
}
break;
}
- case ZFS_PROP_COMPRESSION:
- {
- if (intval == ZIO_COMPRESS_LZ4) {
- spa_t *spa;
-
- if ((err = spa_open(dsname, &spa, FTAG)) != 0)
- return (err);
-
- /*
- * Setting the LZ4 compression algorithm activates
- * the feature.
- */
- if (!spa_feature_is_active(spa,
- SPA_FEATURE_LZ4_COMPRESS)) {
- if ((err = zfs_prop_activate_feature(spa,
- SPA_FEATURE_LZ4_COMPRESS)) != 0) {
- spa_close(spa, FTAG);
- return (err);
- }
- }
-
- spa_close(spa, FTAG);
- }
- /*
- * We still want the default set action to be performed in the
- * caller, we only performed zfeature settings here.
- */
- err = -1;
- break;
- }
-
default:
err = -1;
}
@@ -3831,56 +3799,6 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
}
/*
- * Checks for a race condition to make sure we don't increment a feature flag
- * multiple times.
- */
-static int
-zfs_prop_activate_feature_check(void *arg, dmu_tx_t *tx)
-{
- spa_t *spa = dmu_tx_pool(tx)->dp_spa;
- spa_feature_t *featurep = arg;
-
- if (!spa_feature_is_active(spa, *featurep))
- return (0);
- else
- return (SET_ERROR(EBUSY));
-}
-
-/*
- * The callback invoked on feature activation in the sync task caused by
- * zfs_prop_activate_feature.
- */
-static void
-zfs_prop_activate_feature_sync(void *arg, dmu_tx_t *tx)
-{
- spa_t *spa = dmu_tx_pool(tx)->dp_spa;
- spa_feature_t *featurep = arg;
-
- spa_feature_incr(spa, *featurep, tx);
-}
-
-/*
- * Activates a feature on a pool in response to a property setting. This
- * creates a new sync task which modifies the pool to reflect the feature
- * as being active.
- */
-static int
-zfs_prop_activate_feature(spa_t *spa, spa_feature_t feature)
-{
- int err;
-
- /* EBUSY here indicates that the feature is already active */
- err = dsl_sync_task(spa_name(spa),
- zfs_prop_activate_feature_check, zfs_prop_activate_feature_sync,
- &feature, 2);
-
- if (err != 0 && err != EBUSY)
- return (err);
- else
- return (0);
-}
-
-/*
* Removes properties from the given props list that fail permission checks
* needed to clear them and to restore them in case of a receive error. For each
* property, make sure we have both set and inherit permissions.