From 0bc63d83f62374f688366caed69946a93e29f57d Mon Sep 17 00:00:00 2001 From: George Melikov Date: Thu, 12 Jan 2017 22:58:04 +0300 Subject: [PATCH] OpenZFS 6603 - zfeature_register() should verify ZFEATURE_FLAG_PER_DATASET implies SPA_FEATURE_EXTENSIBLE_DATASET Authored by: ilovezfs Reviewed by: Matthew Ahrens Reviewed by: Richard Laager Approved by: Robert Mustacchi Reviewed-by: Brian Behlendorf Ported-by: George Melikov OpenZFS-issue: https://www.illumos.org/issues/6603 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/0803e91 Closes #5573 --- module/zfs/zfeature_common.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/module/zfs/zfeature_common.c b/module/zfs/zfeature_common.c index 0459d45219..06e15bfd3c 100644 --- a/module/zfs/zfeature_common.c +++ b/module/zfs/zfeature_common.c @@ -134,6 +134,18 @@ zfeature_depends_on(spa_feature_t fid, spa_feature_t check) return (B_FALSE); } +static boolean_t +deps_contains_feature(const spa_feature_t *deps, const spa_feature_t feature) +{ + int i; + + for (i = 0; deps[i] != SPA_FEATURE_NONE; i++) + if (deps[i] == feature) + return (B_TRUE); + + return (B_FALSE); +} + static void zfeature_register(spa_feature_t fid, const char *guid, const char *name, const char *desc, zfeature_flags_t flags, const spa_feature_t *deps) @@ -151,6 +163,9 @@ zfeature_register(spa_feature_t fid, const char *guid, const char *name, if (deps == NULL) deps = nodeps; + VERIFY(((flags & ZFEATURE_FLAG_PER_DATASET) == 0) || + (deps_contains_feature(deps, SPA_FEATURE_EXTENSIBLE_DATASET))); + feature->fi_feature = fid; feature->fi_guid = guid; feature->fi_uname = name;