ndctl: Fix reporting of region capabilities

Resolves: RHEL-80436

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
This commit is contained in:
Jeff Moyer 2025-07-22 08:35:14 -04:00
parent e5b3feec00
commit 0c40b4e27a
3 changed files with 102 additions and 78 deletions

View File

@ -1,76 +0,0 @@
From 0b35822caa1b8468e1a0349ccf971b600be3c03e Mon Sep 17 00:00:00 2001
From: Vishal Verma <vishal.l.verma@intel.com>
Date: Thu, 30 Jan 2020 11:51:14 -0700
Subject: [ndctl PATCH v3] ndctl/lib: fix symbol redefinitions reported by
GCC10
A toolchain update in Fedora 32 caused new compile errors due to
multiple definitions of dimm_ops structures. The declarations in
'private.h' for the various NFIT families are present so that libndctl
can find all the per-family dimm-ops. However they need to be declared
as extern because the actual definitions are in <family>.c.
Additionally, 'param' instances in list.c and monitor.c need to be
marked as static.
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Eric Sandeen <sandeen@redhat.com>
Suggested-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
v3: Remove unrelated changes to Makefile.am from this patch (Eric).
ndctl/lib/private.h | 8 ++++----
ndctl/list.c | 2 +-
ndctl/monitor.c | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/ndctl/lib/private.h b/ndctl/lib/private.h
index e445301..16bf8f9 100644
--- a/ndctl/lib/private.h
+++ b/ndctl/lib/private.h
@@ -343,10 +343,10 @@ struct ndctl_dimm_ops {
int (*xlat_firmware_status)(struct ndctl_cmd *);
};
-struct ndctl_dimm_ops * const intel_dimm_ops;
-struct ndctl_dimm_ops * const hpe1_dimm_ops;
-struct ndctl_dimm_ops * const msft_dimm_ops;
-struct ndctl_dimm_ops * const hyperv_dimm_ops;
+extern struct ndctl_dimm_ops * const intel_dimm_ops;
+extern struct ndctl_dimm_ops * const hpe1_dimm_ops;
+extern struct ndctl_dimm_ops * const msft_dimm_ops;
+extern struct ndctl_dimm_ops * const hyperv_dimm_ops;
static inline struct ndctl_bus *cmd_to_bus(struct ndctl_cmd *cmd)
{
diff --git a/ndctl/list.c b/ndctl/list.c
index 125a9fe..12d78d8 100644
--- a/ndctl/list.c
+++ b/ndctl/list.c
@@ -59,7 +59,7 @@ static unsigned long listopts_to_flags(void)
return flags;
}
-struct util_filter_params param;
+static struct util_filter_params param;
static int did_fail;
diff --git a/ndctl/monitor.c b/ndctl/monitor.c
index b8ee27f..1755b87 100644
--- a/ndctl/monitor.c
+++ b/ndctl/monitor.c
@@ -45,7 +45,7 @@ struct monitor_dimm {
struct list_node list;
};
-struct util_filter_params param;
+static struct util_filter_params param;
static int did_fail;
--
2.21.1

View File

@ -0,0 +1,94 @@
ndctl/list: display region caps for any of BTT, PFN, DAX
JIRA: https://issues.redhat.com/browse/RHEL-80436
commit def79df43e763dd89973e0732dd49ee5f38416ac
Author: Donet Tom <donettom@linux.vnet.ibm.com>
Date: Thu Feb 20 00:20:29 2025 -0600
ndctl/list: display region caps for any of BTT, PFN, DAX
If any one of BTT, PFN, or DAX is not present, but the other two
are, then the region capabilities are not displayed in the
ndctl list -R -C command.
This is because util_region_capabilities_to_json() returns NULL
if any one of BTT, PFN, or DAX is not present.
In this patch, we have changed the logic to display all the region
capabilities that are present.
Test Results with CONFIG_BTT disabled
=====================================
Without this patch
------------------
# ./ndctl list -R -C
[
{
"dev":"region1",
"size":12884901888,
"align":16777216,
"available_size":11257511936,
"max_available_extent":9630121984,
"type":"pmem",
"iset_id":14748366918514061582,
"persistence_domain":"unknown"
},
With this patch
---------------
# ./ndctl list -R -C
[
{
"dev":"region1",
"size":12884901888,
"align":16777216,
"available_size":11257511936,
"max_available_extent":9630121984,
"type":"pmem",
"iset_id":14748366918514061582,
"capabilities":[
{
"mode":"fsdax",
"alignments":[
65536,
2097152,
1073741824
]
},
{
"mode":"devdax",
"alignments":[
65536,
2097152,
1073741824
]
}
],
"persistence_domain":"unknown"
},
Fixes: 965fa02e372f ("util: Distribute 'filter' and 'json' helpers to per-tool objects")
Signed-off-by: Donet Tom <donettom@linux.vnet.ibm.com>
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
Tested-by: Li Zhijian <lizhijian@fujitsu.com>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Link: https://lore.kernel.org/r/20250220062029.9789-1-donettom@linux.vnet.ibm.com
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
diff --git a/ndctl/json.c b/ndctl/json.c
index 23bad7f..7646882 100644
--- a/ndctl/json.c
+++ b/ndctl/json.c
@@ -381,7 +381,7 @@ struct json_object *util_region_capabilities_to_json(struct ndctl_region *region
struct ndctl_pfn *pfn = ndctl_region_get_pfn_seed(region);
struct ndctl_dax *dax = ndctl_region_get_dax_seed(region);
- if (!btt || !pfn || !dax)
+ if (!btt && !pfn && !dax)
return NULL;
jcaps = json_object_new_array();

View File

@ -1,10 +1,11 @@
Name: ndctl
Version: 80
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Manage "libnvdimm" subsystem devices (Non-volatile Memory)
License: GPL-2.0-only and LGPL-2.1-only and CC0-1.0 and MIT
Url: https://github.com/pmem/ndctl
Source0: https://github.com/pmem/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Patch0: def79df-ndctl-list-display-region-caps-for-any-of-BTT-PFN-DAX.patch
Requires: ndctl-libs%{?_isa} = %{version}-%{release}
Requires: daxctl-libs%{?_isa} = %{version}-%{release}
@ -126,7 +127,7 @@ libcxl is a library for enumerating and communicating with CXL devices.
%prep
%setup -q ndctl-%{version}
%autosetup -p1 ndctl-%{version}
%build
%meson %{?asciidoctor} %{?libtracefs} -Dversion-tag=%{version}
@ -243,6 +244,11 @@ fi
%changelog
* Tue Jul 22 2025 Jeff Moyer <jmoyer@redhat.com> - 80-4
- Fix listing of region capabilities (Jeff Moyer)
- Remove orphaned patch file (Jeff Moyer)
- Resolves: RHEL-80436
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 80-3
- Bump release for October 2024 mass rebuild:
Resolves: RHEL-64018