]> granicus.if.org Git - zfs/commitdiff
OpenZFS 6603 - zfeature_register() should verify ZFEATURE_FLAG_PER_DATASET implies...
authorGeorge Melikov <mail@gmelikov.ru>
Thu, 12 Jan 2017 19:58:04 +0000 (22:58 +0300)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 12 Jan 2017 19:58:04 +0000 (11:58 -0800)
Authored by: ilovezfs <ilovezfs@icloud.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Richard Laager <rlaager@wiktel.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: George Melikov <mail@gmelikov.ru>
OpenZFS-issue: https://www.illumos.org/issues/6603
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/0803e91
Closes #5573

module/zfs/zfeature_common.c

index 0459d45219e4adaa5ca2b8998f3d279267b9da0d..06e15bfd3cc300e54d98b9473a648b7a9c76b145 100644 (file)
@@ -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;