Skip to content

Commit

Permalink
Activate per-dataset feature flags when the property is set
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
allanjude committed Jul 30, 2020
1 parent 8f37c1a commit 0ffd80e
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion module/zfs/dsl_prop.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include <sys/dsl_synctask.h>
#include <sys/spa.h>
#include <sys/zap.h>
#include <sys/zio_checksum.h>
#include <sys/zio_compress.h>
#include <sys/fs/zfs.h>

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

isint = (dodefault(zfs_name_to_prop(propname), 8, 1, &intval) == 0);
prop = zfs_name_to_prop(propname);
isint = (dodefault(prop, 8, 1, &intval) == 0);

if (ds->ds_is_snapshot) {
ASSERT(version >= SPA_VERSION_SNAP_PROPS);
Expand Down Expand Up @@ -813,6 +818,29 @@ dsl_prop_set_sync_impl(dsl_dataset_t *ds, const char *propname,
}
}

switch (prop) {
case ZFS_PROP_COMPRESSION:
f = zio_compress_to_feature(ZIO_COMPRESS_ALGO(intval));
if (f != SPA_FEATURE_NONE) {
ASSERT3S(spa_feature_table[f].fi_type, ==,
ZFEATURE_TYPE_BOOLEAN);
ds->ds_feature_activation[f] = (void *)B_TRUE;
dsl_dataset_dirty(ds, tx);
}
break;
case ZFS_PROP_CHECKSUM:
f = zio_checksum_to_feature(intval);
if (f != SPA_FEATURE_NONE) {
ASSERT3S(spa_feature_table[f].fi_type, ==,
ZFEATURE_TYPE_BOOLEAN);
ds->ds_feature_activation[f] = (void *)B_TRUE;
dsl_dataset_dirty(ds, tx);
}
break;
default:
break;
}

spa_history_log_internal_ds(ds, (source == ZPROP_SRC_NONE ||
source == ZPROP_SRC_INHERITED) ? "inherit" : "set", tx,
"%s=%s", propname, (valstr == NULL ? "" : valstr));
Expand Down

0 comments on commit 0ffd80e

Please sign in to comment.