Check the dataset type more rigorously when fetching properties.

When fetching property values of snapshots, a check against the head
dataset type must be performed.  Previously, this additional check was
performed only when fetching "version", "normalize", "utf8only" or "case".

This caused the ZPL properties "acltype", "exec", "devices", "nbmand",
"setuid" and "xattr" to be erroneously displayed with meaningless values
for snapshots of volumes.  It also did not allow for the display of
"volsize" of a snapshot of a volume.

This patch adds the headcheck flag paramater to zfs_prop_valid_for_type()
and zprop_valid_for_type() to indicate the check is being done
against a head dataset's type in order that properties valid only for
snapshots are handled correctly.  This allows the the head check in
get_numeric_property() to be performed when fetching a property for
a snapshot.

Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2265
This commit is contained in:
Tim Chase
2014-04-21 13:22:08 -05:00
committed by Brian Behlendorf
parent 1ce0457348
commit 962d524212
10 changed files with 34 additions and 20 deletions
+3 -3
View File
@@ -391,7 +391,7 @@ zfs_prop_init(void)
PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
"<size> | none", "RESERV");
zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,
ZFS_TYPE_VOLUME, "<size>", "VOLSIZE");
ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, "<size>", "VOLSIZE");
zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,
ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA");
zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,
@@ -555,9 +555,9 @@ zfs_prop_random_value(zfs_prop_t prop, uint64_t seed)
* Returns TRUE if the property applies to any of the given dataset types.
*/
boolean_t
zfs_prop_valid_for_type(int prop, zfs_type_t types)
zfs_prop_valid_for_type(int prop, zfs_type_t types, boolean_t headcheck)
{
return (zprop_valid_for_type(prop, types));
return (zprop_valid_for_type(prop, types, headcheck));
}
zprop_type_t
+7 -1
View File
@@ -351,9 +351,13 @@ zprop_values(int prop, zfs_type_t type)
/*
* Returns TRUE if the property applies to any of the given dataset types.
*
* If headcheck is set, the check is being made against the head dataset
* type of a snapshot which requires to return B_TRUE when the property
* is only valid for snapshots.
*/
boolean_t
zprop_valid_for_type(int prop, zfs_type_t type)
zprop_valid_for_type(int prop, zfs_type_t type, boolean_t headcheck)
{
zprop_desc_t *prop_tbl;
@@ -362,6 +366,8 @@ zprop_valid_for_type(int prop, zfs_type_t type)
ASSERT(prop < zprop_get_numprops(type));
prop_tbl = zprop_get_proptable(type);
if (headcheck && prop_tbl[prop].pd_types == ZFS_TYPE_SNAPSHOT)
return (B_TRUE);
return ((prop_tbl[prop].pd_types & type) != 0);
}
+1 -1
View File
@@ -925,7 +925,7 @@ dsl_prop_get_all_impl(objset_t *mos, uint64_t propobj,
/* Skip properties not valid for this type. */
if ((flags & DSL_PROP_GET_SNAPSHOT) && prop != ZPROP_INVAL &&
!zfs_prop_valid_for_type(prop, ZFS_TYPE_SNAPSHOT))
!zfs_prop_valid_for_type(prop, ZFS_TYPE_SNAPSHOT, B_FALSE))
continue;
/* Skip properties already defined. */