From 3549be1d06aeee5f7c8cbfcffdf157256472a389 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 8 Mar 2016 17:56:40 +0000 Subject: [PATCH] 6541 Pool feature-flag check defeated if "verify" is included in the dedup property value Reviewed by: Matthew Ahrens Reviewed by: Richard Laager Approved by: Robert Mustacchi Author: ilovezfs illumos/illumos-gate@971640e6aa954c91b0706543741aa4570299f4d7 --- uts/common/fs/zfs/zfs_ioctl.c | 2 +- uts/common/fs/zfs/zio_checksum.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/uts/common/fs/zfs/zfs_ioctl.c b/uts/common/fs/zfs/zfs_ioctl.c index 43cedca8f3cc..ae66e4261fda 100644 --- a/uts/common/fs/zfs/zfs_ioctl.c +++ b/uts/common/fs/zfs/zfs_ioctl.c @@ -3886,7 +3886,7 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr) return (SET_ERROR(EINVAL)); /* check prop value is enabled in features */ - feature = zio_checksum_to_feature(intval); + feature = zio_checksum_to_feature(intval & ZIO_CHECKSUM_MASK); if (feature == SPA_FEATURE_NONE) break; diff --git a/uts/common/fs/zfs/zio_checksum.c b/uts/common/fs/zfs/zio_checksum.c index 4bef6a3e112d..8bd7e02bef38 100644 --- a/uts/common/fs/zfs/zio_checksum.c +++ b/uts/common/fs/zfs/zio_checksum.c @@ -136,9 +136,15 @@ zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS] = { ZCHECKSUM_FLAG_NOPWRITE, "edonr"}, }; +/* + * The flag corresponding to the "verify" in dedup=[checksum,]verify + * must be cleared first, so callers should use ZIO_CHECKSUM_MASK. + */ spa_feature_t zio_checksum_to_feature(enum zio_checksum cksum) { + VERIFY((cksum & ~ZIO_CHECKSUM_MASK) == 0); + switch (cksum) { case ZIO_CHECKSUM_SHA512: return (SPA_FEATURE_SHA512);