Skip to content

Commit 0ffd80e

Browse files
committed
Activate per-dataset feature flags when the property is set
If a compression or checksum algorithm requires a feature flag, activate the feature as soon as the property is set, rather than waiting for the first block to be born. Signed-off-by: Allan Jude <allan@klarasystems.com>
1 parent 8f37c1a commit 0ffd80e

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

module/zfs/dsl_prop.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#include <sys/dsl_synctask.h>
3636
#include <sys/spa.h>
3737
#include <sys/zap.h>
38+
#include <sys/zio_checksum.h>
39+
#include <sys/zio_compress.h>
3840
#include <sys/fs/zfs.h>
3941

4042
#include "zfs_prop.h"
@@ -662,8 +664,11 @@ dsl_prop_set_sync_impl(dsl_dataset_t *ds, const char *propname,
662664
char *tbuf = NULL;
663665
int err;
664666
uint64_t version = spa_version(ds->ds_dir->dd_pool->dp_spa);
667+
spa_feature_t f;
668+
zfs_prop_t prop;
665669

666-
isint = (dodefault(zfs_name_to_prop(propname), 8, 1, &intval) == 0);
670+
prop = zfs_name_to_prop(propname);
671+
isint = (dodefault(prop, 8, 1, &intval) == 0);
667672

668673
if (ds->ds_is_snapshot) {
669674
ASSERT(version >= SPA_VERSION_SNAP_PROPS);
@@ -813,6 +818,29 @@ dsl_prop_set_sync_impl(dsl_dataset_t *ds, const char *propname,
813818
}
814819
}
815820

821+
switch (prop) {
822+
case ZFS_PROP_COMPRESSION:
823+
f = zio_compress_to_feature(ZIO_COMPRESS_ALGO(intval));
824+
if (f != SPA_FEATURE_NONE) {
825+
ASSERT3S(spa_feature_table[f].fi_type, ==,
826+
ZFEATURE_TYPE_BOOLEAN);
827+
ds->ds_feature_activation[f] = (void *)B_TRUE;
828+
dsl_dataset_dirty(ds, tx);
829+
}
830+
break;
831+
case ZFS_PROP_CHECKSUM:
832+
f = zio_checksum_to_feature(intval);
833+
if (f != SPA_FEATURE_NONE) {
834+
ASSERT3S(spa_feature_table[f].fi_type, ==,
835+
ZFEATURE_TYPE_BOOLEAN);
836+
ds->ds_feature_activation[f] = (void *)B_TRUE;
837+
dsl_dataset_dirty(ds, tx);
838+
}
839+
break;
840+
default:
841+
break;
842+
}
843+
816844
spa_history_log_internal_ds(ds, (source == ZPROP_SRC_NONE ||
817845
source == ZPROP_SRC_INHERITED) ? "inherit" : "set", tx,
818846
"%s=%s", propname, (valstr == NULL ? "" : valstr));

0 commit comments

Comments
 (0)