nvme: add diag attribute group under sysfs

Add a new diag attribute group under:
/sys/class/nvme/<ctrl>/
/sys/block/<nvme-path-dev>/
/sys/block/<ns-head-dev>/

This new sysfs attribute group will be used to organize NVMe diagnostic
and telemetry-related counters under it.

Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
This commit is contained in:
Nilay Shroff 2026-05-17 00:06:48 +05:30 committed by Keith Busch
parent 19bdb70c77
commit 37afebc79a
3 changed files with 37 additions and 0 deletions

View File

@ -1014,6 +1014,7 @@ extern const struct attribute_group nvme_ns_mpath_attr_group;
extern const struct pr_ops nvme_pr_ops;
extern const struct block_device_operations nvme_ns_head_ops;
extern const struct attribute_group nvme_dev_attrs_group;
extern const struct attribute_group nvme_dev_diag_attrs_group;
extern const struct attribute_group *nvme_subsys_attrs_groups[];
extern const struct attribute_group *nvme_dev_attr_groups[];
extern const struct block_device_operations nvme_bdev_ops;

View File

@ -2815,6 +2815,7 @@ static const struct attribute_group nvme_pci_dev_attrs_group = {
static const struct attribute_group *nvme_pci_dev_attr_groups[] = {
&nvme_dev_attrs_group,
&nvme_pci_dev_attrs_group,
&nvme_dev_diag_attrs_group,
NULL,
};

View File

@ -344,11 +344,28 @@ const struct attribute_group nvme_ns_mpath_attr_group = {
};
#endif
static struct attribute *nvme_ns_diag_attrs[] = {
NULL,
};
static umode_t nvme_ns_diag_attrs_are_visible(struct kobject *kobj,
struct attribute *a, int n)
{
return a->mode;
}
const struct attribute_group nvme_ns_diag_attr_group = {
.name = "diag",
.attrs = nvme_ns_diag_attrs,
.is_visible = nvme_ns_diag_attrs_are_visible,
};
const struct attribute_group *nvme_ns_attr_groups[] = {
&nvme_ns_attr_group,
#ifdef CONFIG_NVME_MULTIPATH
&nvme_ns_mpath_attr_group,
#endif
&nvme_ns_diag_attr_group,
NULL,
};
@ -1018,11 +1035,29 @@ static const struct attribute_group nvme_tls_attrs_group = {
};
#endif
static struct attribute *nvme_dev_diag_attrs[] = {
NULL,
};
static umode_t nvme_dev_diag_attrs_are_visible(struct kobject *kobj,
struct attribute *a, int n)
{
return a->mode;
}
const struct attribute_group nvme_dev_diag_attrs_group = {
.name = "diag",
.attrs = nvme_dev_diag_attrs,
.is_visible = nvme_dev_diag_attrs_are_visible,
};
EXPORT_SYMBOL_GPL(nvme_dev_diag_attrs_group);
const struct attribute_group *nvme_dev_attr_groups[] = {
&nvme_dev_attrs_group,
#ifdef CONFIG_NVME_TCP_TLS
&nvme_tls_attrs_group,
#endif
&nvme_dev_diag_attrs_group,
NULL,
};