Skip to content

Commit

Permalink
6603 zfeature_register() should verify ZFEATURE_FLAG_PER_DATASET impl…
Browse files Browse the repository at this point in the history
…ies SPA_FEATURE_EXTENSIBLE_DATASET

Reviewed by: Matthew Ahrens <[email protected]>
Reviewed by: Richard Laager <[email protected]>
Approved by: Robert Mustacchi <[email protected]>
  • Loading branch information
ilovezfs authored and ahrens committed Feb 11, 2016
1 parent 22b6687 commit 0803e91
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions usr/src/common/zfs/zfeature_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ 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)
{
for (int 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)
Expand All @@ -147,6 +157,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;
Expand Down

0 comments on commit 0803e91

Please sign in to comment.