Skip to content

Commit

Permalink
Add lz4hc_compress per-dataset feature flag
Browse files Browse the repository at this point in the history
Require it being enabled for compression=lz4hc* .
Activate LZ4HC feature if needed when syncing objset.
  • Loading branch information
vozhyk- committed Apr 30, 2016
1 parent d0e8f1f commit 78fd130
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/zfeature_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ typedef enum spa_feature {
SPA_FEATURE_BOOKMARKS,
SPA_FEATURE_FS_SS_LIMIT,
SPA_FEATURE_LARGE_BLOCKS,
SPA_FEATURE_LZ4HC_COMPRESS,
SPA_FEATURES
} spa_feature_t;

Expand Down
29 changes: 29 additions & 0 deletions man/man5/zpool-features.5
Original file line number Diff line number Diff line change
Expand Up @@ -432,5 +432,34 @@ set larger than 128KB, and will return to being \fBenabled\fR once all
filesystems that have ever had their recordsize larger than 128KB are destroyed.
.RE

.sp
.ne 2
.na
\fB\fBlz4hc_compress\fR\fR
.ad
.RS 4n
.TS
l l .
GUID org.zfsonlinux:lz4hc_compress
READ\-ONLY COMPATIBLE yes
DEPENDENCIES lz4_compress
.TE

\fBlz4hc\fR is the high-compression variant of \fBlz4\fR. It has
slower compression, but uses \fBlz4\fR for decompression, so
decompression is as fast as \fBlz4\fR's.

When the \fBlz4hc_compress\fR feature is set to \fBenabled\fR, the
administrator can turn on \fBlz4hc\fR compression on any dataset on
the pool using the \fBzfs\fR(8) command. Doing so will immediately
activate the \fBlz4hc_compress\fR feature on the underlying
pool. Booting off of \fBlz4hc\fR-compressed root pools is supported.

This feature becomes \fBactive\fR once a \fBcompression\fR property
has been set to \fBlz4hc\fR and will return to being \fBenabled\fB
once all filesystems that have ever had their compression set to
\fBlz4hc\fR are destroyed.
.RE

.SH "SEE ALSO"
\fBzpool\fR(8)
6 changes: 6 additions & 0 deletions module/zfs/dmu_objset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,12 @@ 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[
SPA_FEATURE_LZ4HC_COMPRESS] = B_TRUE;
}
}

Expand Down
12 changes: 12 additions & 0 deletions module/zfs/zfeature_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,16 @@ zpool_feature_init(void)
"Support for blocks larger than 128KB.",
ZFEATURE_FLAG_PER_DATASET, large_blocks_deps);
}

{
static const spa_feature_t lz4hc_compress_deps[] = {
SPA_FEATURE_LZ4_COMPRESS,
SPA_FEATURE_NONE
};
zfeature_register(SPA_FEATURE_LZ4HC_COMPRESS,
"org.zfsonlinux:lz4hc_compress", "lz4hc_compress",
"LZ4HC compression algorithm support.",
ZFEATURE_FLAG_PER_DATASET | ZFEATURE_FLAG_READONLY_COMPAT,
lz4hc_compress_deps);
}
}
13 changes: 12 additions & 1 deletion module/zfs/zfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3723,11 +3723,22 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
if ((err = spa_open(dsname, &spa, FTAG)) != 0)
return (err);

if (!spa_feature_is_enabled(spa,
/* 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)) {
spa_close(spa, FTAG);
return (SET_ERROR(ENOTSUP));
}

spa_close(spa, FTAG);
}

Expand Down

0 comments on commit 78fd130

Please sign in to comment.