mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-01-13 19:50:25 +03:00
features.kernel layout should match features.pool
The features.kernel layout should match features.pool. Reviewed-by: Sara Hartse <sara.hartse@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Don Brady <don.brady@delphix.com> Closes #8566
This commit is contained in:
parent
a887d653b3
commit
b4ddec7af6
@ -19,7 +19,7 @@
|
|||||||
* CDDL HEADER END
|
* CDDL HEADER END
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018 by Delphix. All rights reserved.
|
* Copyright (c) 2018, 2019 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -351,43 +351,69 @@ pool_property_show(struct kobject *kobj, struct attribute *attr, char *buf)
|
|||||||
*
|
*
|
||||||
* A user processes can easily check if the running zfs kernel module
|
* A user processes can easily check if the running zfs kernel module
|
||||||
* supports the new feature.
|
* supports the new feature.
|
||||||
*
|
|
||||||
* For example, the initial channel_program feature was extended to support
|
|
||||||
* async calls (i.e. a sync flag). If this mechanism were in place at that
|
|
||||||
* time, we could have added a 'channel_program_async' to this list.
|
|
||||||
*/
|
*/
|
||||||
static const char *zfs_features[] = {
|
static const char *zfs_kernel_features[] = {
|
||||||
/* --> Add new kernel features here (post ZoL 0.8.0) */
|
/* --> Add new kernel features here */
|
||||||
"initialize",
|
"com.delphix:vdev_initialize",
|
||||||
"trim",
|
"org.zfsonlinux:vdev_trim",
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ZFS_FEATURE_COUNT ARRAY_SIZE(zfs_features)
|
#define KERNEL_FEATURE_COUNT ARRAY_SIZE(zfs_kernel_features)
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
kernel_feature_show(struct kobject *kobj, struct attribute *attr, char *buf)
|
kernel_feature_show(struct kobject *kobj, struct attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
return (snprintf(buf, PAGE_SIZE, "supported\n"));
|
if (strcmp(attr->name, "supported") == 0)
|
||||||
|
return (snprintf(buf, PAGE_SIZE, "yes\n"));
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
kernel_feature_to_kobj(zfs_mod_kobj_t *parent, int slot, const char *name)
|
||||||
|
{
|
||||||
|
zfs_mod_kobj_t *zfs_kobj = &parent->zko_children[slot];
|
||||||
|
|
||||||
|
ASSERT3U(slot, <, KERNEL_FEATURE_COUNT);
|
||||||
|
ASSERT(name);
|
||||||
|
|
||||||
|
int err = zfs_kobj_init(zfs_kobj, 1, 0, kernel_feature_show);
|
||||||
|
if (err)
|
||||||
|
return;
|
||||||
|
|
||||||
|
zfs_kobj_add_attr(zfs_kobj, 0, "supported");
|
||||||
|
|
||||||
|
err = zfs_kobj_add(zfs_kobj, &parent->zko_kobj, name);
|
||||||
|
if (err)
|
||||||
|
zfs_kobj_release(&zfs_kobj->zko_kobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
zfs_kernel_features_init(zfs_mod_kobj_t *zfs_kobj, struct kobject *parent)
|
zfs_kernel_features_init(zfs_mod_kobj_t *zfs_kobj, struct kobject *parent)
|
||||||
{
|
{
|
||||||
int err;
|
/*
|
||||||
|
* Create a parent kobject to host kernel features.
|
||||||
err = zfs_kobj_init(zfs_kobj, ZFS_FEATURE_COUNT, 0,
|
*
|
||||||
|
* '/sys/module/zfs/features.kernel'
|
||||||
|
*/
|
||||||
|
int err = zfs_kobj_init(zfs_kobj, 0, KERNEL_FEATURE_COUNT,
|
||||||
kernel_feature_show);
|
kernel_feature_show);
|
||||||
if (err)
|
if (err)
|
||||||
return (err);
|
return (err);
|
||||||
|
|
||||||
for (int f = 0; f < ZFS_FEATURE_COUNT; f++)
|
|
||||||
zfs_kobj_add_attr(zfs_kobj, f, zfs_features[f]);
|
|
||||||
|
|
||||||
err = zfs_kobj_add(zfs_kobj, parent, ZFS_SYSFS_KERNEL_FEATURES);
|
err = zfs_kobj_add(zfs_kobj, parent, ZFS_SYSFS_KERNEL_FEATURES);
|
||||||
if (err)
|
if (err) {
|
||||||
zfs_kobj_release(&zfs_kobj->zko_kobj);
|
zfs_kobj_release(&zfs_kobj->zko_kobj);
|
||||||
|
return (err);
|
||||||
|
}
|
||||||
|
|
||||||
return (err);
|
/*
|
||||||
|
* Now create a kobject for each feature.
|
||||||
|
*
|
||||||
|
* '/sys/module/zfs/features.kernel/<feature>'
|
||||||
|
*/
|
||||||
|
for (int f = 0; f < KERNEL_FEATURE_COUNT; f++)
|
||||||
|
kernel_feature_to_kobj(zfs_kobj, f, zfs_kernel_features[f]);
|
||||||
|
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright (c) 2018 by Delphix. All rights reserved.
|
# Copyright (c) 2018, 2019 by Delphix. All rights reserved.
|
||||||
#
|
#
|
||||||
|
|
||||||
. $STF_SUITE/include/libtest.shlib
|
. $STF_SUITE/include/libtest.shlib
|
||||||
@ -39,13 +39,15 @@ fi
|
|||||||
|
|
||||||
claim="Expected '/sys/module/zfs/<dir>/<attr>' attributes are present"
|
claim="Expected '/sys/module/zfs/<dir>/<attr>' attributes are present"
|
||||||
|
|
||||||
feature_attr="/sys/module/zfs/features.pool/org.open-zfs:large_blocks/guid"
|
kernel_feature_attr="/sys/module/zfs/features.kernel/org.zfsonlinux:vdev_trim/supported"
|
||||||
|
pool_feature_attr="/sys/module/zfs/features.pool/org.open-zfs:large_blocks/guid"
|
||||||
pool_prop__attr="/sys/module/zfs/properties.pool/comment/values"
|
pool_prop__attr="/sys/module/zfs/properties.pool/comment/values"
|
||||||
ds_prop__attr="/sys/module/zfs/properties.dataset/recordsize/values"
|
ds_prop__attr="/sys/module/zfs/properties.dataset/recordsize/values"
|
||||||
|
|
||||||
log_assert $claim
|
log_assert $claim
|
||||||
|
|
||||||
log_must cat $feature_attr
|
log_must cat $kernel_feature_attr
|
||||||
|
log_must cat $pool_feature_attr
|
||||||
log_must cat $pool_prop__attr
|
log_must cat $pool_prop__attr
|
||||||
log_must cat $ds_prop__attr
|
log_must cat $ds_prop__attr
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user