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 <mahrens@delphix.com> Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net> Reviewed by: Xin LI <delphij@freebsd.org> Approved by: Robert Mustacchi <rm@joyent.com> References: https://github.com/illumos/illumos-gate/commit/db1741f https://www.illumos.org/issues/5661 Ported-by: kernelOfTruth kerneloftruth@gmail.com Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #3571
This commit is contained in:
parent
15cfbb38fd
commit
99197f034e
|
@ -123,14 +123,19 @@ enum zio_compress {
|
||||||
*/
|
*/
|
||||||
#define ZIO_COMPRESS_LEGACY_FUNCTIONS ZIO_COMPRESS_LZ4
|
#define ZIO_COMPRESS_LEGACY_FUNCTIONS ZIO_COMPRESS_LZ4
|
||||||
|
|
||||||
#define ZIO_COMPRESS_ON_VALUE ZIO_COMPRESS_LZJB
|
/*
|
||||||
#define ZIO_COMPRESS_DEFAULT ZIO_COMPRESS_OFF
|
* The meaning of "compress = on" selected by the compression features enabled
|
||||||
|
* on a given pool.
|
||||||
|
*/
|
||||||
|
#define ZIO_COMPRESS_LEGACY_ON_VALUE ZIO_COMPRESS_LZJB
|
||||||
|
#define ZIO_COMPRESS_LZ4_ON_VALUE ZIO_COMPRESS_LZ4
|
||||||
|
|
||||||
|
#define ZIO_COMPRESS_DEFAULT ZIO_COMPRESS_OFF
|
||||||
|
|
||||||
#define BOOTFS_COMPRESS_VALID(compress) \
|
#define BOOTFS_COMPRESS_VALID(compress) \
|
||||||
((compress) == ZIO_COMPRESS_LZJB || \
|
((compress) == ZIO_COMPRESS_LZJB || \
|
||||||
(compress) == ZIO_COMPRESS_LZ4 || \
|
(compress) == ZIO_COMPRESS_LZ4 || \
|
||||||
((compress) == ZIO_COMPRESS_ON && \
|
(compress) == ZIO_COMPRESS_ON || \
|
||||||
ZIO_COMPRESS_ON_VALUE == ZIO_COMPRESS_LZJB) || \
|
|
||||||
(compress) == ZIO_COMPRESS_OFF)
|
(compress) == ZIO_COMPRESS_OFF)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -543,8 +548,8 @@ extern enum zio_checksum zio_checksum_select(enum zio_checksum child,
|
||||||
enum zio_checksum parent);
|
enum zio_checksum parent);
|
||||||
extern enum zio_checksum zio_checksum_dedup_select(spa_t *spa,
|
extern enum zio_checksum zio_checksum_dedup_select(spa_t *spa,
|
||||||
enum zio_checksum child, enum zio_checksum parent);
|
enum zio_checksum child, enum zio_checksum parent);
|
||||||
extern enum zio_compress zio_compress_select(enum zio_compress child,
|
extern enum zio_compress zio_compress_select(spa_t *spa,
|
||||||
enum zio_compress parent);
|
enum zio_compress child, enum zio_compress parent);
|
||||||
|
|
||||||
extern void zio_suspend(spa_t *spa, zio_t *zio);
|
extern void zio_suspend(spa_t *spa, zio_t *zio);
|
||||||
extern int zio_resume(spa_t *spa);
|
extern int zio_resume(spa_t *spa);
|
||||||
|
|
|
@ -840,15 +840,25 @@ Changing this property affects only newly-written data.
|
||||||
.ne 2
|
.ne 2
|
||||||
.mk
|
.mk
|
||||||
.na
|
.na
|
||||||
\fBcompression\fR=\fBon\fR | \fBoff\fR | \fBlzjb\fR | \fBgzip\fR | \fBgzip-\fR\fIN\fR | \fBzle\fR | \fBlz4\fR
|
\fB\fBcompression\fR=\fBon\fR | \fBoff\fR | \fBlzjb\fR | \fBlz4\fR |
|
||||||
|
\fBgzip\fR | \fBgzip-\fR\fIN\fR | \fBzle\fR\fR
|
||||||
.ad
|
.ad
|
||||||
.sp .6
|
.sp .6
|
||||||
.RS 4n
|
.RS 4n
|
||||||
Controls the compression algorithm used for this dataset. The \fBlzjb\fR compression algorithm is optimized for performance while providing decent data compression. Setting compression to \fBon\fR uses the \fBlzjb\fR compression algorithm.
|
Controls the compression algorithm used for this dataset.
|
||||||
.sp
|
.sp
|
||||||
The \fBgzip\fR compression algorithm uses the same compression as the \fBgzip\fR(1) command. You can specify the \fBgzip\fR level by using the value \fBgzip-\fR\fIN\fR where \fIN\fR is an integer from 1 (fastest) to 9 (best compression ratio). Currently, \fBgzip\fR is equivalent to \fBgzip-6\fR (which is also the default for \fBgzip\fR(1)).
|
Setting compression to \fBon\fR indicates that the current default
|
||||||
|
compression algorithm should be used. The default balances compression
|
||||||
|
and decompression speed, with compression ratio and is expected to
|
||||||
|
work well on a wide variety of workloads. Unlike all other settings for
|
||||||
|
this property, \fBon\fR does not select a fixed compression type. As
|
||||||
|
new compression algorithms are added to ZFS and enabled on a pool, the
|
||||||
|
default compression algorithm may change. The current default compression
|
||||||
|
algorthm is either \fBlzjb\fR or, if the \fBlz4_compress\fR feature is
|
||||||
|
enabled, \fBlz4\fR.
|
||||||
.sp
|
.sp
|
||||||
The \fBzle\fR (zero-length encoding) compression algorithm is a fast and simple algorithm to eliminate runs of zeroes.
|
The \fBlzjb\fR compression algorithm is optimized for performance while
|
||||||
|
providing decent data compression.
|
||||||
.sp
|
.sp
|
||||||
The \fBlz4\fR compression algorithm is a high-performance replacement
|
The \fBlz4\fR compression algorithm is a high-performance replacement
|
||||||
for the \fBlzjb\fR algorithm. It features significantly faster
|
for the \fBlzjb\fR algorithm. It features significantly faster
|
||||||
|
@ -858,7 +868,15 @@ the \fBlz4_compress\fR feature set to \fIenabled\fR. See
|
||||||
\fBzpool-features\fR(5) for details on ZFS feature flags and the
|
\fBzpool-features\fR(5) for details on ZFS feature flags and the
|
||||||
\fBlz4_compress\fR feature.
|
\fBlz4_compress\fR feature.
|
||||||
.sp
|
.sp
|
||||||
This property can also be referred to by its shortened column name \fBcompress\fR. Changing this property affects only newly-written data.
|
The \fBgzip\fR compression algorithm uses the same compression as
|
||||||
|
the \fBgzip\fR(1) command. You can specify the \fBgzip\fR level by using the
|
||||||
|
value \fBgzip-\fR\fIN\fR where \fIN\fR is an integer from 1 (fastest) to 9
|
||||||
|
(best compression ratio). Currently, \fBgzip\fR is equivalent to \fBgzip-6\fR
|
||||||
|
(which is also the default for \fBgzip\fR(1)). The \fBzle\fR compression
|
||||||
|
algorithm compresses runs of zeros.
|
||||||
|
.sp
|
||||||
|
This property can also be referred to by its shortened column name
|
||||||
|
\fBcompress\fR. Changing this property affects only newly-written data.
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
.sp
|
.sp
|
||||||
|
|
|
@ -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
|
* 3. all other level 0 blocks
|
||||||
*/
|
*/
|
||||||
if (ismd) {
|
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) {
|
if (zfs_mdcomp_disable) {
|
||||||
compress = ZIO_COMPRESS_EMPTY;
|
compress = ZIO_COMPRESS_EMPTY;
|
||||||
} else if (lz4_ac) {
|
|
||||||
compress = ZIO_COMPRESS_LZ4;
|
|
||||||
} else {
|
} 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;
|
compress = ZIO_COMPRESS_OFF;
|
||||||
checksum = ZIO_CHECKSUM_OFF;
|
checksum = ZIO_CHECKSUM_OFF;
|
||||||
} else {
|
} 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) ?
|
checksum = (dedup_checksum == ZIO_CHECKSUM_OFF) ?
|
||||||
zio_checksum_select(dn->dn_checksum, checksum) :
|
zio_checksum_select(dn->dn_checksum, checksum) :
|
||||||
|
|
|
@ -163,7 +163,8 @@ compression_changed_cb(void *arg, uint64_t newval)
|
||||||
*/
|
*/
|
||||||
ASSERT(newval != ZIO_COMPRESS_INHERIT);
|
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
|
static void
|
||||||
|
@ -420,7 +421,7 @@ dmu_objset_open_impl(spa_t *spa, dsl_dataset_t *ds, blkptr_t *bp,
|
||||||
} else {
|
} else {
|
||||||
/* It's the meta-objset. */
|
/* It's the meta-objset. */
|
||||||
os->os_checksum = ZIO_CHECKSUM_FLETCHER_4;
|
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_copies = spa_max_replication(spa);
|
||||||
os->os_dedup_checksum = ZIO_CHECKSUM_OFF;
|
os->os_dedup_checksum = ZIO_CHECKSUM_OFF;
|
||||||
os->os_dedup_verify = B_FALSE;
|
os->os_dedup_verify = B_FALSE;
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <sys/zfs_context.h>
|
#include <sys/zfs_context.h>
|
||||||
#include <sys/compress.h>
|
#include <sys/compress.h>
|
||||||
#include <sys/spa.h>
|
#include <sys/spa.h>
|
||||||
|
#include <sys/zfeature.h>
|
||||||
#include <sys/zio.h>
|
#include <sys/zio.h>
|
||||||
#include <sys/zio_compress.h>
|
#include <sys/zio_compress.h>
|
||||||
|
|
||||||
|
@ -61,19 +62,27 @@ zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum zio_compress
|
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(child < ZIO_COMPRESS_FUNCTIONS);
|
||||||
ASSERT(parent < 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)
|
result = child;
|
||||||
return (parent);
|
if (result == ZIO_COMPRESS_INHERIT)
|
||||||
|
result = parent;
|
||||||
|
|
||||||
if (child == ZIO_COMPRESS_ON)
|
if (result == ZIO_COMPRESS_ON) {
|
||||||
return (ZIO_COMPRESS_ON_VALUE);
|
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
|
size_t
|
||||||
|
|
Loading…
Reference in New Issue