Skip to content

Commit

Permalink
Store required feature flags in zio_compress_table
Browse files Browse the repository at this point in the history
Add zio_compress_info_t.ci_feature
  • Loading branch information
vozhyk- committed May 1, 2016
1 parent 73a616e commit 8ac22c6
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 49 deletions.
2 changes: 1 addition & 1 deletion include/sys/zio.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ enum bp_compress {

/*
* The number of "legacy" compression functions which can be set on individual
* objects.
* objects and don't require feature flags.
*/
#define ZIO_COMPRESS_LEGACY_FUNCTIONS ZIO_COMPRESS_LZ4

Expand Down
2 changes: 2 additions & 0 deletions include/sys/zio_compress.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define _SYS_ZIO_COMPRESS_H

#include <sys/zio.h>
#include <zfeature_common.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -51,6 +52,7 @@ typedef const struct zio_compress_info {
zio_compress_func_t *ci_compress; /* compression function */
enum bp_compress ci_bp_compress_value;
/* value stored in BP */
spa_feature_t ci_feature; /* required feature flag */
int ci_level; /* level parameter */
char *ci_name; /* algorithm name */
} zio_compress_info_t;
Expand Down
1 change: 0 additions & 1 deletion module/zfs/dmu_objset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,6 @@ dmu_objset_write_done(zio_t *zio, arc_buf_t *abuf, void *arg)
(void) dsl_dataset_block_kill(ds, bp_orig, tx, B_TRUE);
dsl_dataset_block_born(ds, bp, tx);

/* TODO create zio_compress_to_feature */
if (os->os_compress >= ZIO_COMPRESS_LZ4HC_1 &&
os->os_compress <= ZIO_COMPRESS_LZ4HC_16)
ds->ds_feature_activation_needed[
Expand Down
21 changes: 6 additions & 15 deletions module/zfs/zfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
#include <sys/vdev.h>
#include <sys/priv_impl.h>
#include <sys/dmu.h>
#include <sys/zio_compress.h>
#include <sys/dsl_dir.h>
#include <sys/dsl_dataset.h>
#include <sys/dsl_prop.h>
Expand Down Expand Up @@ -3715,26 +3716,16 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
SPA_VERSION_ZLE_COMPRESSION))
return (SET_ERROR(ENOTSUP));

if (intval == ZIO_COMPRESS_LZ4 ||
(intval >= ZIO_COMPRESS_LZ4HC_1 &&
intval <= ZIO_COMPRESS_LZ4HC_16)) {
if (intval >= ZIO_COMPRESS_LEGACY_FUNCTIONS) {
spa_feature_t feature =
zio_compress_table[intval].ci_feature;
spa_t *spa;

if ((err = spa_open(dsname, &spa, FTAG)) != 0)
return (err);

/* TODO create zio_compress_to_feature */
if (intval == ZIO_COMPRESS_LZ4 &&
!spa_feature_is_enabled(spa,
SPA_FEATURE_LZ4_COMPRESS)) {
spa_close(spa, FTAG);
return (SET_ERROR(ENOTSUP));
}

if (intval >= ZIO_COMPRESS_LZ4HC_1 &&
intval <= ZIO_COMPRESS_LZ4HC_16 &&
!spa_feature_is_enabled(spa,
SPA_FEATURE_LZ4HC_COMPRESS)) {
if (feature != SPA_FEATURE_NONE &&
!spa_feature_is_enabled(spa, feature)) {
spa_close(spa, FTAG);
return (SET_ERROR(ENOTSUP));
}
Expand Down
96 changes: 64 additions & 32 deletions module/zfs/zio_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,70 @@
*/

zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS] = {
{NULL, BP_COMPRESS_INHERIT, 0, "inherit"},
{NULL, BP_COMPRESS_ON, 0, "on"},
{NULL, BP_COMPRESS_OFF, 0, "uncompressed"},
{lzjb_compress, BP_COMPRESS_LZJB, 0, "lzjb"},
{NULL, BP_COMPRESS_EMPTY, 0, "empty"},
{gzip_compress, BP_COMPRESS_GZIP_1, 1, "gzip-1"},
{gzip_compress, BP_COMPRESS_GZIP_2, 2, "gzip-2"},
{gzip_compress, BP_COMPRESS_GZIP_3, 3, "gzip-3"},
{gzip_compress, BP_COMPRESS_GZIP_4, 4, "gzip-4"},
{gzip_compress, BP_COMPRESS_GZIP_5, 5, "gzip-5"},
{gzip_compress, BP_COMPRESS_GZIP_6, 6, "gzip-6"},
{gzip_compress, BP_COMPRESS_GZIP_7, 7, "gzip-7"},
{gzip_compress, BP_COMPRESS_GZIP_8, 8, "gzip-8"},
{gzip_compress, BP_COMPRESS_GZIP_9, 9, "gzip-9"},
{zle_compress, BP_COMPRESS_ZLE, 64, "zle"},
{lz4_compress_zfs, BP_COMPRESS_LZ4, 0, "lz4"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 1, "lz4hc-1"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 2, "lz4hc-2"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 3, "lz4hc-3"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 4, "lz4hc-4"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 5, "lz4hc-5"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 6, "lz4hc-6"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 7, "lz4hc-7"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 8, "lz4hc-8"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 9, "lz4hc-9"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 10, "lz4hc-10"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 11, "lz4hc-11"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 12, "lz4hc-12"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 13, "lz4hc-13"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 14, "lz4hc-14"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 15, "lz4hc-15"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4, 16, "lz4hc-16"},
{NULL, BP_COMPRESS_INHERIT, SPA_FEATURE_NONE,
0, "inherit"},
{NULL, BP_COMPRESS_ON, SPA_FEATURE_NONE,
0, "on"},
{NULL, BP_COMPRESS_OFF, SPA_FEATURE_NONE,
0, "uncompressed"},
{lzjb_compress, BP_COMPRESS_LZJB, SPA_FEATURE_NONE,
0, "lzjb"},
{NULL, BP_COMPRESS_EMPTY, SPA_FEATURE_NONE,
0, "empty"},
{gzip_compress, BP_COMPRESS_GZIP_1, SPA_FEATURE_NONE,
1, "gzip-1"},
{gzip_compress, BP_COMPRESS_GZIP_2, SPA_FEATURE_NONE,
2, "gzip-2"},
{gzip_compress, BP_COMPRESS_GZIP_3, SPA_FEATURE_NONE,
3, "gzip-3"},
{gzip_compress, BP_COMPRESS_GZIP_4, SPA_FEATURE_NONE,
4, "gzip-4"},
{gzip_compress, BP_COMPRESS_GZIP_5, SPA_FEATURE_NONE,
5, "gzip-5"},
{gzip_compress, BP_COMPRESS_GZIP_6, SPA_FEATURE_NONE,
6, "gzip-6"},
{gzip_compress, BP_COMPRESS_GZIP_7, SPA_FEATURE_NONE,
7, "gzip-7"},
{gzip_compress, BP_COMPRESS_GZIP_8, SPA_FEATURE_NONE,
8, "gzip-8"},
{gzip_compress, BP_COMPRESS_GZIP_9, SPA_FEATURE_NONE,
9, "gzip-9"},
{zle_compress, BP_COMPRESS_ZLE, SPA_FEATURE_NONE,
64, "zle"},
{lz4_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4_COMPRESS, 0, "lz4"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 1, "lz4hc-1"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 2, "lz4hc-2"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 3, "lz4hc-3"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 4, "lz4hc-4"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 5, "lz4hc-5"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 6, "lz4hc-6"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 7, "lz4hc-7"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 8, "lz4hc-8"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 9, "lz4hc-9"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 10, "lz4hc-10"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 11, "lz4hc-11"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 12, "lz4hc-12"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 13, "lz4hc-13"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 14, "lz4hc-14"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 15, "lz4hc-15"},
{lz4hc_compress_zfs, BP_COMPRESS_LZ4,
SPA_FEATURE_LZ4HC_COMPRESS, 16, "lz4hc-16"},
};

zio_decompress_info_t zio_decompress_table[BP_COMPRESS_VALUES] = {
Expand Down

0 comments on commit 8ac22c6

Please sign in to comment.