Update vendor/illumos/dist and vendor-sys/illumos/dist

to illumos-gate 13921:9d721847e469
(illumos zfs issue #3035 LZ4 compression support in ZFS and GRUB)
This commit is contained in:
Xin LI 2013-01-16 23:11:13 +00:00
parent aa9aae696d
commit cda31c70d5
13 changed files with 1383 additions and 3 deletions

View File

@ -21,6 +21,7 @@
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/
#ifdef _KERNEL
@ -156,4 +157,7 @@ zpool_feature_init(void)
zfeature_register(SPA_FEATURE_EMPTY_BPOBJ,
"com.delphix:empty_bpobj", "empty_bpobj",
"Snapshots use less space.", B_TRUE, B_FALSE, NULL);
zfeature_register(SPA_FEATURE_LZ4_COMPRESS,
"org.illumos:lz4_compress", "lz4_compress",
"LZ4 compression algorithm support.", B_FALSE, B_FALSE, NULL);
}

View File

@ -21,6 +21,7 @@
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/
#ifndef _ZFEATURE_COMMON_H
@ -52,6 +53,7 @@ typedef int (zfeature_func_t)(zfeature_info_t *fi, void *arg);
enum spa_feature {
SPA_FEATURE_ASYNC_DESTROY,
SPA_FEATURE_EMPTY_BPOBJ,
SPA_FEATURE_LZ4_COMPRESS,
SPA_FEATURES
} spa_feature_t;

View 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.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/
/* Portions Copyright 2010 Robert Milkowski */
@ -96,6 +97,7 @@ zfs_prop_init(void)
{ "gzip-8", ZIO_COMPRESS_GZIP_8 },
{ "gzip-9", ZIO_COMPRESS_GZIP_9 },
{ "zle", ZIO_COMPRESS_ZLE },
{ "lz4", ZIO_COMPRESS_LZ4 },
{ NULL }
};
@ -211,8 +213,8 @@ zfs_prop_init(void)
zprop_register_index(ZFS_PROP_COMPRESSION, "compression",
ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
"on | off | lzjb | gzip | gzip-[1-9] | zle", "COMPRESS",
compress_table);
"on | off | lzjb | gzip | gzip-[1-9] | zle | lz4",
"COMPRESS", compress_table);
zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
"hidden | visible", "SNAPDIR", snapdir_table);

View File

@ -25,6 +25,7 @@
.\" Copyright (c) 2012 by Delphix. All rights reserved.
.\" Copyright (c) 2012, Joyent, Inc. All rights reserved.
.\" Copyright 2012 Nexenta Systems, Inc. All Rights Reserved.
.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
.\"
.TH ZFS 1M "Sep 16, 2012"
.SH NAME
@ -912,7 +913,7 @@ Changing this property affects only newly-written data.
.ne 2
.na
\fB\fBcompression\fR=\fBon\fR | \fBoff\fR | \fBlzjb\fR | \fBgzip\fR |
\fBgzip-\fR\fIN\fR | \fBzle\fR\fR
\fBgzip-\fR\fIN\fR | \fBzle\fR\fR | \fBlz4\fR
.ad
.sp .6
.RS 4n
@ -926,6 +927,14 @@ value \fBgzip-\fR\fIN\fR where \fIN\fR is an integer from 1 (fastest) to 9
(which is also the default for \fBgzip\fR(1)). The \fBzle\fR compression
algorithm compresses runs of zeros.
.sp
The \fBlz4\fR compression algorithm is a high-performance replacement
for the \fBlzjb\fR algorithm. It features significantly faster
compression and decompression, as well as a moderately higher
compression ratio than \fBlzjb\fR, but can only be used on pools with
the \fBlz4_compress\fR feature set to \fIenabled\fR. See
\fBzpool-features\fR(5) for details on ZFS feature flags and the
\fBlz4_compress\fR feature.
.sp
This property can also be referred to by its shortened column name
\fBcompress\fR. Changing this property affects only newly-written data.
.RE

View File

@ -1,5 +1,6 @@
'\" te
.\" Copyright (c) 2012 by Delphix. All rights reserved.
.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
.\" The contents of this file are subject to the terms of the Common Development
.\" and Distribution License (the "License"). You may not use this file except
.\" in compliance with the License. You can obtain a copy of the license at
@ -197,5 +198,38 @@ This feature is \fBactive\fR while there are any filesystems, volumes,
or snapshots which were created after enabling this feature.
.RE
.sp
.ne 2
.na
\fB\fBlz4_compress\fR\fR
.ad
.RS 4n
.TS
l l .
GUID org.illumos:lz4_compress
READ\-ONLY COMPATIBLE no
DEPENDENCIES none
.TE
\fBlz4\fR is a high-performance real-time compression algorithm that
features significantly faster compression and decompression as well as a
higher compression ratio than the older \fBlzjb\fR compression.
Typically, \fBlz4\fR compression is approximately 50% faster on
compressible data and 200% faster on incompressible data than
\fBlzjb\fR. It is also approximately 80% faster on decompression, while
giving approximately 10% better compression ratio.
When the \fBlz4_compress\fR feature is set to \fBenabled\fR, the
administrator can turn on \fBlz4\fR compression on any dataset on the
pool using the \fBzfs\fR(1M) command. Please note that doing so will
immediately activate the \fBlz4_compress\fR feature on the underlying
pool (even before any data is written). Since this feature is not
read-only compatible, this operation will render the pool unimportable
on systems without support for the \fBlz4_compress\fR feature. At the
moment, this operation cannot be reversed. Booting off of
\fBlz4\fR-compressed root pools is supported.
.RE
.SH "SEE ALSO"
\fBzpool\fR(1M)

View File

@ -23,6 +23,7 @@
# Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012 Nexenta Systems, Inc. All rights reserved.
# Copyright (c) 2012 by Delphix. All rights reserved.
# Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
#
#
@ -1353,6 +1354,7 @@ ZFS_COMMON_OBJS += \
dsl_scan.o \
zfeature.o \
gzip.o \
lz4.o \
lzjb.o \
metaslab.o \
refcount.o \

View File

@ -0,0 +1,30 @@
LZ4 - Fast LZ compression algorithm
Copyright (C) 2011-2013, Yann Collet.
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
You can contact the author at :
- LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
- LZ4 source repository : http://code.google.com/p/lz4/

View File

@ -0,0 +1 @@
LZ4 COMPRESSION FUNCTIONALITY IN ZFS

1173
uts/common/fs/zfs/lz4.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,7 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/
#ifndef _ZIO_H
@ -106,14 +107,17 @@ enum zio_compress {
ZIO_COMPRESS_GZIP_8,
ZIO_COMPRESS_GZIP_9,
ZIO_COMPRESS_ZLE,
ZIO_COMPRESS_LZ4,
ZIO_COMPRESS_FUNCTIONS
};
/* N.B. when altering this value, also change BOOTFS_COMPRESS_VALID below */
#define ZIO_COMPRESS_ON_VALUE ZIO_COMPRESS_LZJB
#define ZIO_COMPRESS_DEFAULT ZIO_COMPRESS_OFF
#define BOOTFS_COMPRESS_VALID(compress) \
((compress) == ZIO_COMPRESS_LZJB || \
(compress) == ZIO_COMPRESS_LZ4 || \
((compress) == ZIO_COMPRESS_ON && \
ZIO_COMPRESS_ON_VALUE == ZIO_COMPRESS_LZJB) || \
(compress) == ZIO_COMPRESS_OFF)

View File

@ -23,6 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/
#ifndef _SYS_ZIO_COMPRESS_H
#define _SYS_ZIO_COMPRESS_H
@ -68,6 +71,10 @@ extern size_t zle_compress(void *src, void *dst, size_t s_len, size_t d_len,
int level);
extern int zle_decompress(void *src, void *dst, size_t s_len, size_t d_len,
int level);
extern size_t lz4_compress(void *src, void *dst, size_t s_len, size_t d_len,
int level);
extern int lz4_decompress(void *src, void *dst, size_t s_len, size_t d_len,
int level);
/*
* Compress and decompress data if necessary.

View File

@ -25,6 +25,7 @@
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/
/*
@ -172,6 +173,7 @@
#include <sys/dsl_scan.h>
#include <sharefs/share.h>
#include <sys/dmu_objset.h>
#include <sys/zfeature.h>
#include "zfs_namecheck.h"
#include "zfs_prop.h"
@ -235,6 +237,12 @@ 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(dsl_pool_t *dp, zfeature_info_t *feature);
static int zfs_prop_activate_feature_check(void *arg1, void *arg2,
dmu_tx_t *tx);
static void zfs_prop_activate_feature_sync(void *arg1, void *arg2,
dmu_tx_t *tx);
/* _NOTE(PRINTFLIKE(4)) - this is printf-like, but lint is too whiney */
void
__dprintf(const char *file, const char *func, int line, const char *fmt, ...)
@ -2383,6 +2391,40 @@ zfs_prop_set_special(const char *dsname, zprop_source_t source,
}
break;
}
case ZFS_PROP_COMPRESSION:
{
if (intval == ZIO_COMPRESS_LZ4) {
zfeature_info_t *feature =
&spa_feature_table[SPA_FEATURE_LZ4_COMPRESS];
spa_t *spa;
dsl_pool_t *dp;
if ((err = spa_open(dsname, &spa, FTAG)) != 0)
return (err);
dp = spa->spa_dsl_pool;
/*
* Setting the LZ4 compression algorithm activates
* the feature.
*/
if (!spa_feature_is_active(spa, feature)) {
if ((err = zfs_prop_activate_feature(dp,
feature)) != 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;
@ -3627,6 +3669,22 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
SPA_VERSION_ZLE_COMPRESSION))
return (ENOTSUP);
if (intval == ZIO_COMPRESS_LZ4) {
zfeature_info_t *feature =
&spa_feature_table[
SPA_FEATURE_LZ4_COMPRESS];
spa_t *spa;
if ((err = spa_open(dsname, &spa, FTAG)) != 0)
return (err);
if (!spa_feature_is_enabled(spa, feature)) {
spa_close(spa, FTAG);
return (ENOTSUP);
}
spa_close(spa, FTAG);
}
/*
* If this is a bootable dataset then
* verify that the compression algorithm
@ -3670,6 +3728,56 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
return (zfs_secpolicy_setprop(dsname, prop, pair, CRED()));
}
/*
* 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(dsl_pool_t *dp, zfeature_info_t *feature)
{
int err;
/* EBUSY here indicates that the feature is already active */
err = dsl_sync_task_do(dp, zfs_prop_activate_feature_check,
zfs_prop_activate_feature_sync, dp->dp_spa, feature, 2);
if (err != 0 && err != EBUSY)
return (err);
else
return (0);
}
/*
* Checks for a race condition to make sure we don't increment a feature flag
* multiple times.
*/
/*ARGSUSED*/
static int
zfs_prop_activate_feature_check(void *arg1, void *arg2, dmu_tx_t *tx)
{
spa_t *spa = arg1;
zfeature_info_t *feature = arg2;
if (!spa_feature_is_active(spa, feature))
return (0);
else
return (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 *arg1, void *arg2, dmu_tx_t *tx)
{
spa_t *spa = arg1;
zfeature_info_t *feature = arg2;
spa_feature_incr(spa, feature, tx);
}
/*
* 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

View File

@ -23,6 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
*/
#include <sys/zfs_context.h>
#include <sys/compress.h>
@ -50,6 +53,7 @@ zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS] = {
{gzip_compress, gzip_decompress, 8, "gzip-8"},
{gzip_compress, gzip_decompress, 9, "gzip-9"},
{zle_compress, zle_decompress, 64, "zle"},
{lz4_compress, lz4_decompress, 0, "lz4"},
};
enum zio_compress