Compare commits

...

No commits in common. "c8" and "imports/c8-beta/ndctl-67-2.el8" have entirely different histories.

27 changed files with 12 additions and 4579 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/ndctl-71.1.tar.gz
SOURCES/ndctl-67.tar.gz

1
.ndctl.metadata Normal file
View File

@ -0,0 +1 @@
6bea3b5d545201ab31c3d90b90204cc90dfa88bd SOURCES/ndctl-67.tar.gz

View File

@ -1,81 +0,0 @@
ndctl/namespace: Suppress -ENXIO when processing all namespaces.
BZ:
Brew:
commit 07011a334fd1e4b641cdbfaf5de7500f7bdc941d
Author: Michal Suchanek <msuchanek@suse.de>
Date: Wed Jan 6 14:17:41 2021 +0100
ndctl/namespace: Suppress -ENXIO when processing all namespaces.
When processing all namespaces and no namespaces exist user gets the
default -ENXIO. Set default rc to 0 when processing all namespaces.
This avoids confusing error message printed in addition to the message
saying 0 namespaces were affected.
Before:
# ndctl check-namespace all
namespace0.0: namespace_check: namespace0.0: check aborted, namespace online
error checking namespaces: Device or resource busy
checked 0 namespaces
# ndctl disable-namespace all
disabled 1 namespace
# ndctl check-namespace all
namespace0.0: namespace_check: Unable to recover any BTT info blocks
error checking namespaces: No such device or address
checked 0 namespaces
# ndctl destroy-namespace all
destroyed 1 namespace
# ndctl check-namespace all
error checking namespaces: No such device or address
checked 0 namespaces
# ndctl destroy-namespace all
error destroying namespaces: No such device or address
destroyed 0 namespaces
After:
# ndctl check-namespace all
namespace0.0: namespace_check: namespace0.0: check aborted, namespace online
error checking namespaces: Device or resource busy
checked 0 namespaces
# ndctl disable-namespace namespace0.0
disabled 1 namespace
# ndctl check-namespace all
namespace0.0: namespace_check: Unable to recover any BTT info blocks
error checking namespaces: No such device or address
checked 0 namespaces
# ndctl destroy-namespace all
destroyed 1 namespace
# ndctl check-namespace all
checked 0 namespaces
# ndctl destroy-namespace all
destroyed 0 namespaces
# ndctl destroy-namespace all
destroyed 0 namespaces
Note: this does change the return value from -ENXIO to 0 in the cases
when no namespaces exist and processing all namespaces was requested.
Link: https://patchwork.kernel.org/patch/11681431/
Link: https://lore.kernel.org/r/32c8cd8d2716f5e52aebea4e4d303eeb4e0550f9.1609938610.git.msuchanek@suse.de
Reviewed-by: Santosh S <santosh@fossix.org>
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index 5e65ed5..cd822b3 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -2151,6 +2151,9 @@ static int do_xaction_namespace(const char *namespace,
if (!namespace && action != ACTION_CREATE)
return rc;
+ if (namespace && (strcmp(namespace, "all") == 0))
+ rc = 0;
+
if (verbose)
ndctl_set_log_priority(ctx, LOG_DEBUG);

View File

@ -1,201 +0,0 @@
test: Don't skip tests if nfit modules are missing
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2141031
commit 1649ad9c3e2c6e9c47870c8d3b54f10b24177bc7
Author: Santosh Sivaraj <santosh@fossix.org>
Date: Thu May 13 11:42:16 2021 +0530
test: Don't skip tests if nfit modules are missing
For NFIT to be available ACPI is a must, so don't fail when nfit modules
are missing on a platform that doesn't support ACPI.
Link: https://lore.kernel.org/r/20210513061218.760322-2-santosh@fossix.org
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/test.h b/test.h
index cba8d41..7de13fe 100644
--- a/test.h
+++ b/test.h
@@ -20,7 +20,7 @@ void builtin_xaction_namespace_reset(void);
struct kmod_ctx;
struct kmod_module;
-int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
+int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
struct ndctl_ctx *nd_ctx, int log_level,
struct ndctl_test *test);
diff --git a/test/ack-shutdown-count-set.c b/test/ack-shutdown-count-set.c
index fb1d82b..c561ff3 100644
--- a/test/ack-shutdown-count-set.c
+++ b/test/ack-shutdown-count-set.c
@@ -99,7 +99,7 @@ static int test_ack_shutdown_count_set(int loglevel, struct ndctl_test *test,
int result = EXIT_FAILURE, err;
ndctl_set_log_priority(ctx, loglevel);
- err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
+ err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
if (err < 0) {
result = 77;
ndctl_test_skip(test);
diff --git a/test/blk_namespaces.c b/test/blk_namespaces.c
index d7f00cb..f076e85 100644
--- a/test/blk_namespaces.c
+++ b/test/blk_namespaces.c
@@ -228,7 +228,7 @@ int test_blk_namespaces(int log_level, struct ndctl_test *test,
if (!bus) {
fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n");
- rc = nfit_test_init(&kmod_ctx, &mod, NULL, log_level, test);
+ rc = ndctl_test_init(&kmod_ctx, &mod, NULL, log_level, test);
ndctl_invalidate(ctx);
bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
if (rc < 0 || !bus) {
diff --git a/test/core.c b/test/core.c
index cc7d8d9..2b03aa9 100644
--- a/test/core.c
+++ b/test/core.c
@@ -11,6 +11,7 @@
#include <util/log.h>
#include <util/sysfs.h>
#include <ndctl/libndctl.h>
+#include <ndctl/ndctl.h>
#include <ccan/array_size/array_size.h>
#define KVER_STRLEN 20
@@ -106,11 +107,11 @@ int ndctl_test_get_skipped(struct ndctl_test *test)
return test->skip;
}
-int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
+int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
struct ndctl_ctx *nd_ctx, int log_level,
struct ndctl_test *test)
{
- int rc;
+ int rc, family = -1;
unsigned int i;
const char *name;
struct ndctl_bus *bus;
@@ -127,10 +128,28 @@ int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
"nd_e820",
"nd_pmem",
};
+ char *test_env;
log_init(&log_ctx, "test/init", "NDCTL_TEST");
log_ctx.log_priority = log_level;
+ /*
+ * The following two checks determine the platform family. For
+ * Intel/platforms which support ACPI, check sysfs; for other platforms
+ * determine from the environment variable NVDIMM_TEST_FAMILY
+ */
+ if (access("/sys/bus/acpi", F_OK) == 0)
+ family = NVDIMM_FAMILY_INTEL;
+
+ test_env = getenv("NDCTL_TEST_FAMILY");
+ if (test_env && strcmp(test_env, "PAPR") == 0)
+ family = NVDIMM_FAMILY_PAPR;
+
+ if (family == -1) {
+ log_err(&log_ctx, "Cannot determine NVDIMM family\n");
+ return -ENOTSUP;
+ }
+
*ctx = kmod_new(NULL, NULL);
if (!*ctx)
return -ENXIO;
@@ -185,6 +204,11 @@ retry:
path = kmod_module_get_path(*mod);
if (!path) {
+ if (family != NVDIMM_FAMILY_INTEL &&
+ (strcmp(name, "nfit") == 0 ||
+ strcmp(name, "nd_e820") == 0))
+ continue;
+
log_err(&log_ctx, "%s.ko: failed to get path\n", name);
break;
}
diff --git a/test/dpa-alloc.c b/test/dpa-alloc.c
index e922009..0b3bb7a 100644
--- a/test/dpa-alloc.c
+++ b/test/dpa-alloc.c
@@ -289,7 +289,7 @@ int test_dpa_alloc(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
return 77;
ndctl_set_log_priority(ctx, loglevel);
- err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
+ err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
if (err < 0) {
ndctl_test_skip(test);
fprintf(stderr, "nfit_test unavailable skipping tests\n");
diff --git a/test/dsm-fail.c b/test/dsm-fail.c
index 9dfd8b0..0a6383d 100644
--- a/test/dsm-fail.c
+++ b/test/dsm-fail.c
@@ -346,7 +346,7 @@ int test_dsm_fail(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
int result = EXIT_FAILURE, err;
ndctl_set_log_priority(ctx, loglevel);
- err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
+ err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
if (err < 0) {
result = 77;
ndctl_test_skip(test);
diff --git a/test/libndctl.c b/test/libndctl.c
index c42f785..d9b50f4 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -2708,7 +2708,7 @@ int test_libndctl(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
daxctl_set_log_priority(daxctl_ctx, loglevel);
ndctl_set_private_data(ctx, test);
- err = nfit_test_init(&kmod_ctx, &mod, ctx, loglevel, test);
+ err = ndctl_test_init(&kmod_ctx, &mod, ctx, loglevel, test);
if (err < 0) {
ndctl_test_skip(test);
fprintf(stderr, "nfit_test unavailable skipping tests\n");
diff --git a/test/multi-pmem.c b/test/multi-pmem.c
index 3d10952..3ea08cc 100644
--- a/test/multi-pmem.c
+++ b/test/multi-pmem.c
@@ -249,7 +249,7 @@ int test_multi_pmem(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx
ndctl_set_log_priority(ctx, loglevel);
- err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
+ err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
if (err < 0) {
result = 77;
ndctl_test_skip(test);
diff --git a/test/parent-uuid.c b/test/parent-uuid.c
index 6424e9f..bded33a 100644
--- a/test/parent-uuid.c
+++ b/test/parent-uuid.c
@@ -218,7 +218,7 @@ int test_parent_uuid(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ct
return 77;
ndctl_set_log_priority(ctx, loglevel);
- err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
+ err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
if (err < 0) {
ndctl_test_skip(test);
fprintf(stderr, "nfit_test unavailable skipping tests\n");
diff --git a/test/pmem_namespaces.c b/test/pmem_namespaces.c
index f0f2edd..a4db1ae 100644
--- a/test/pmem_namespaces.c
+++ b/test/pmem_namespaces.c
@@ -191,7 +191,7 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test,
if (!bus) {
fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n");
- rc = nfit_test_init(&kmod_ctx, &mod, NULL, log_level, test);
+ rc = ndctl_test_init(&kmod_ctx, &mod, NULL, log_level, test);
ndctl_invalidate(ctx);
bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
if (rc < 0 || !bus) {

File diff suppressed because it is too large Load Diff

View File

@ -1,72 +0,0 @@
test/libndctl: Use ndctl_region_set_ro() to change disk read-only state
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=
commit 43e48c0d2f271cba4237f6eefc3e4912a74c102b
Author: Dan Williams <dan.j.williams@intel.com>
Date: Tue Mar 9 22:09:49 2021 -0800
test/libndctl: Use ndctl_region_set_ro() to change disk read-only state
Kernel commit 52f019d43c22 ("block: add a hard-readonly flag to struct
gendisk") broke the read-only management test, by fixing the broken
behavior that BLKROSET could make a block device read-write even when the
disk is read-only. The fix [1] propagates changes of the region
read-only state to the underlying disk. Add ndctl_region_set_ro() ahead of
BLKROSET so that BLKROSET does not conflict the block_device state with the
disk state.
[1]: http://lore.kernel.org/r/161534060720.528671.2341213328968989192.stgit@dwillia2-desk3.amr.corp.intel.com
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Link: https://lore.kernel.org/r/161535658913.530219.12194565167385663385.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
diff --git a/test/libndctl.c b/test/libndctl.c
index fc65149..c42f785 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -1541,6 +1541,7 @@ static int validate_bdev(const char *devname, struct ndctl_btt *btt,
struct ndctl_pfn *pfn, struct ndctl_namespace *ndns,
struct namespace *namespace, void *buf)
{
+ struct ndctl_region *region = ndctl_namespace_get_region(ndns);
char bdevpath[50];
int fd, rc, ro;
@@ -1578,6 +1579,13 @@ static int validate_bdev(const char *devname, struct ndctl_btt *btt,
}
ro = 0;
+ rc = ndctl_region_set_ro(region, ro);
+ if (rc < 0) {
+ fprintf(stderr, "%s: ndctl_region_set_ro failed\n", devname);
+ rc = -errno;
+ goto out;
+ }
+
rc = ioctl(fd, BLKROSET, &ro);
if (rc < 0) {
fprintf(stderr, "%s: BLKROSET failed\n",
@@ -1605,8 +1613,16 @@ static int validate_bdev(const char *devname, struct ndctl_btt *btt,
rc = -ENXIO;
goto out;
}
+
+ rc = ndctl_region_set_ro(region, namespace->ro);
+ if (rc < 0) {
+ fprintf(stderr, "%s: ndctl_region_set_ro reset failed\n", devname);
+ rc = -errno;
+ goto out;
+ }
+
rc = 0;
- out:
+out:
close(fd);
return rc;
}

View File

@ -1,46 +0,0 @@
ndctl/test: make inject-smart.sh more tolerant of decimal fields
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=
commit 4921c0c2040ffbe10facd320f6a718a3d42ad815
Author: Vishal Verma <vishal.l.verma@intel.com>
Date: Thu Feb 17 22:42:29 2022 -0700
ndctl/test: make inject-smart.sh more tolerant of decimal fields
Some combinations of json-c/jq/other libraries seem to produce differing
outputs for the final jq-filtered smart fields, in that some have a
decimal "42.0" numeric field, where as in other combinations it is a
simple "42" (still a numeric field, not string).
This shouldn't matter in practice, but for this contrived test case, we
need to make sure that "42" is treated the same as "42.0"
Normalize all fields before comparing them to "%0.0f" so that the
comparison doesn't result in superfluous failures.
Reported-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
diff --git a/test/inject-smart.sh b/test/inject-smart.sh
index 8b91360..046322b 100755
--- a/test/inject-smart.sh
+++ b/test/inject-smart.sh
@@ -105,13 +105,13 @@ get_field()
json="$($NDCTL list -b $bus -d $dimm -H)"
val="$(jq -r ".[].dimms[].health.$smart_listing" <<< $json)"
val="$(translate_val $val)"
- echo $val
+ printf "%0.0f\n" "$val"
}
verify()
{
local field="$1"
- local val="$2"
+ local val="$(printf "%0.0f\n" "$2")"
[[ "$val" == "$(get_field $field)" ]]
}

View File

@ -1,48 +0,0 @@
ndctl/scrub: Reread scrub-engine status at start
BZ:
Brew:
commit 4e646fa490ba4b782afa188dd8818b94c419924e
Author: Dan Williams <dan.j.williams@intel.com>
Date: Wed May 26 16:33:10 2021 -0700
ndctl/scrub: Reread scrub-engine status at start
Given that the kernel has exponential backoff to cover the lack of
interrupts for scrub completion status there is a reasonable likelihood
that 'ndctl start-scrub' is issued while the hardware/platform scrub-state
is idle, but the kernel engine poll timer has not fired.
Trigger at least one poll cycle for the kernel to re-read the scrub-state
before reporting that ARS is busy.
Link: https://lore.kernel.org/r/162207199057.3715490.2469820075085914776.stgit@dwillia2-desk3.amr.corp.intel.com
Reported-by: Krzysztof Rusocki <krzysztof.rusocki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index e5641fe..536e142 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -1354,8 +1354,18 @@ static int __ndctl_bus_get_scrub_state(struct ndctl_bus *bus,
NDCTL_EXPORT int ndctl_bus_start_scrub(struct ndctl_bus *bus)
{
struct ndctl_ctx *ctx = ndctl_bus_get_ctx(bus);
+ int rc;
+
+ rc = sysfs_write_attr(ctx, bus->scrub_path, "1\n");
- return sysfs_write_attr(ctx, bus->scrub_path, "1\n");
+ /*
+ * Try at least 1 poll cycle before reporting busy in case this
+ * request hits the kernel's exponential backoff while the
+ * hardware/platform scrub state is idle.
+ */
+ if (rc == -EBUSY && ndctl_bus_poll_scrub_completion(bus, 1, 1) == 0)
+ return sysfs_write_attr(ctx, bus->scrub_path, "1\n");
+ return rc;
}
NDCTL_EXPORT int ndctl_bus_get_scrub_state(struct ndctl_bus *bus)

View File

@ -1,409 +0,0 @@
ndctl/test: Move 'reset()' to function in 'common'
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2141031
commit 6538529be5738f06543a0d7178f97e0b0e6b63c2
Author: Dan Williams <dan.j.williams@intel.com>
Date: Wed Jan 5 13:31:55 2022 -0800
ndctl/test: Move 'reset()' to function in 'common'
When BLK mode is removed, tests that expect the nfit_test region to allow
pmem namespace creation will need to 'init' rather than 'zero' labels. In
preparation, take the time opportunity to move reset() to a common
function. So that 'ndctl zero-labels' can be replaced with 'ndctl
init-labels' in one central location.
Link: https://lore.kernel.org/r/164141831509.3990253.14783946910211635678.stgit@dwillia2-desk3.amr.corp.intel.com
Tested-by: Alison Schofield <alison.schofield@intel.com>
Tested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/test/blk-exhaust.sh b/test/blk-exhaust.sh
index 09c4aae..b6d3808 100755
--- a/test/blk-exhaust.sh
+++ b/test/blk-exhaust.sh
@@ -14,9 +14,7 @@ trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
# if the kernel accounting is correct we should be able to create two
# pmem and two blk namespaces on nfit_test.0
diff --git a/test/btt-check.sh b/test/btt-check.sh
index 8e0b489..65b5c58 100755
--- a/test/btt-check.sh
+++ b/test/btt-check.sh
@@ -39,13 +39,6 @@ create()
[ $size -gt 0 ] || err "$LINENO"
}
-reset()
-{
- $NDCTL disable-region -b $NFIT_TEST_BUS0 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
- $NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
# re-enable the BTT namespace, and do IO to it in an attempt to
# verify it still comes up ok, and functions as expected
post_repair_test()
diff --git a/test/btt-errors.sh b/test/btt-errors.sh
index 4e59f57..5a20d26 100755
--- a/test/btt-errors.sh
+++ b/test/btt-errors.sh
@@ -45,9 +45,7 @@ trap 'err $LINENO cleanup' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1
@@ -126,9 +124,7 @@ dd if=$MNT/$FILE of=/dev/null iflag=direct bs=4096 count=1
# reset everything to get a clean log
if grep -q "$MNT" /proc/mounts; then umount $MNT; fi
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
dev="x"
json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m sector)
eval "$(echo "$json" | json2var)"
@@ -148,9 +144,7 @@ force_raw 0
dd if=/dev/$blockdev of=/dev/null iflag=direct bs=4096 count=1 && err $LINENO || true
# done, exit
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
cleanup
_cleanup
exit 0
diff --git a/test/btt-pad-compat.sh b/test/btt-pad-compat.sh
index bf1ea54..be538b7 100755
--- a/test/btt-pad-compat.sh
+++ b/test/btt-pad-compat.sh
@@ -37,13 +37,6 @@ create()
fi
}
-reset()
-{
- $NDCTL disable-region -b $NFIT_TEST_BUS0 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
- $NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
verify_idx()
{
idx0="$1"
diff --git a/test/clear.sh b/test/clear.sh
index fb9d52c..c4d02d5 100755
--- a/test/clear.sh
+++ b/test/clear.sh
@@ -14,9 +14,7 @@ trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1
diff --git a/test/common b/test/common
index 6bcefca..3c54d63 100644
--- a/test/common
+++ b/test/common
@@ -46,6 +46,21 @@ err()
exit $rc
}
+reset()
+{
+ $NDCTL disable-region -b $NFIT_TEST_BUS0 all
+ $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
+ $NDCTL enable-region -b $NFIT_TEST_BUS0 all
+}
+
+reset1()
+{
+ $NDCTL disable-region -b $NFIT_TEST_BUS1 all
+ $NDCTL zero-labels -b $NFIT_TEST_BUS1 all
+ $NDCTL enable-region -b $NFIT_TEST_BUS1 all
+}
+
+
# check_min_kver
# $1: Supported kernel version. format: X.Y
#
diff --git a/test/create.sh b/test/create.sh
index b0fd99f..e9baaa0 100755
--- a/test/create.sh
+++ b/test/create.sh
@@ -15,9 +15,7 @@ trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1
diff --git a/test/daxctl-create.sh b/test/daxctl-create.sh
index 198779a..d319a39 100755
--- a/test/daxctl-create.sh
+++ b/test/daxctl-create.sh
@@ -10,7 +10,7 @@ trap 'cleanup $LINENO' ERR
cleanup()
{
printf "Error at line %d\n" "$1"
- [[ $testdev ]] && reset
+ [[ $testdev ]] && reset_dax
exit $rc
}
@@ -70,7 +70,7 @@ reset_dev()
"$DAXCTL" enable-device "$testdev"
}
-reset()
+reset_dax()
{
test -n "$testdev"
diff --git a/test/daxdev-errors.sh b/test/daxdev-errors.sh
index 9547d78..e13453d 100755
--- a/test/daxdev-errors.sh
+++ b/test/daxdev-errors.sh
@@ -15,9 +15,7 @@ trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1
diff --git a/test/firmware-update.sh b/test/firmware-update.sh
index 8cc9c41..93ce166 100755
--- a/test/firmware-update.sh
+++ b/test/firmware-update.sh
@@ -10,11 +10,9 @@ image="update-fw.img"
trap 'err $LINENO' ERR
-reset()
+fwupd_reset()
{
- $NDCTL disable-region -b $NFIT_TEST_BUS0 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
- $NDCTL enable-region -b $NFIT_TEST_BUS0 all
+ reset
if [ -f $image ]; then
rm -f $image
fi
@@ -73,7 +71,7 @@ do_tests()
check_min_kver "4.16" || do_skip "may lack firmware update test handling"
modprobe nfit_test
-reset
+fwupd_reset
detect
rc=1
do_tests
diff --git a/test/inject-error.sh b/test/inject-error.sh
index 7d0b826..fd823b6 100755
--- a/test/inject-error.sh
+++ b/test/inject-error.sh
@@ -37,13 +37,6 @@ create()
[ $size -gt 0 ] || err "$LINENO"
}
-reset()
-{
- $NDCTL disable-region -b $NFIT_TEST_BUS0 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
- $NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
check_status()
{
local sector="$1"
diff --git a/test/max_available_extent_ns.sh b/test/max_available_extent_ns.sh
index 343f3c9..47a921f 100755
--- a/test/max_available_extent_ns.sh
+++ b/test/max_available_extent_ns.sh
@@ -11,13 +11,6 @@ trap 'err $LINENO' ERR
check_min_kver "4.19" || do_skip "kernel $KVER may not support max_available_size"
check_prereq "jq"
-init()
-{
- $NDCTL disable-region -b $NFIT_TEST_BUS0 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
- $NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
do_test()
{
region=$($NDCTL list -b $NFIT_TEST_BUS0 -R -t pmem | jq -r 'sort_by(-.size) | .[].dev' | head -1)
@@ -40,7 +33,7 @@ do_test()
modprobe nfit_test
rc=1
-init
+reset
do_test
_cleanup
exit 0
diff --git a/test/monitor.sh b/test/monitor.sh
index c015c11..6aa4196 100755
--- a/test/monitor.sh
+++ b/test/monitor.sh
@@ -19,13 +19,6 @@ trap 'err $LINENO' ERR
check_min_kver "4.15" || do_skip "kernel $KVER may not support monitor service"
-init()
-{
- $NDCTL disable-region -b $NFIT_TEST_BUS0 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
- $NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
start_monitor()
{
logfile=$(mktemp)
@@ -112,7 +105,7 @@ test_filter_region()
test_filter_namespace()
{
- init
+ reset
monitor_namespace=$($NDCTL create-namespace -b $smart_supported_bus | jq -r .dev)
monitor_dimms=$(get_monitor_dimm "-n $monitor_namespace")
start_monitor "-n $monitor_namespace"
@@ -170,7 +163,7 @@ do_tests()
modprobe nfit_test
rc=1
-init
+reset
set_smart_supported_bus
do_tests
_cleanup
diff --git a/test/multi-dax.sh b/test/multi-dax.sh
index b343a38..04070ad 100755
--- a/test/multi-dax.sh
+++ b/test/multi-dax.sh
@@ -17,9 +17,7 @@ ALIGN_SIZE=`getconf PAGESIZE`
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1
query=". | sort_by(.available_size) | reverse | .[0].dev"
diff --git a/test/pfn-meta-errors.sh b/test/pfn-meta-errors.sh
index 0ade2e5..6314897 100755
--- a/test/pfn-meta-errors.sh
+++ b/test/pfn-meta-errors.sh
@@ -29,9 +29,7 @@ trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1
diff --git a/test/pmem-errors.sh b/test/pmem-errors.sh
index 4225c3b..2065780 100755
--- a/test/pmem-errors.sh
+++ b/test/pmem-errors.sh
@@ -28,9 +28,7 @@ trap 'err $LINENO cleanup' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1
diff --git a/test/rescan-partitions.sh b/test/rescan-partitions.sh
index 1686de3..51bbd73 100755
--- a/test/rescan-partitions.sh
+++ b/test/rescan-partitions.sh
@@ -25,13 +25,6 @@ check_min_kver "4.16" || do_skip "may not contain fixes for partition rescanning
check_prereq "parted"
check_prereq "blockdev"
-reset()
-{
- $NDCTL disable-region -b $NFIT_TEST_BUS0 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
- $NDCTL enable-region -b $NFIT_TEST_BUS0 all
-}
-
test_mode()
{
local mode="$1"
diff --git a/test/sector-mode.sh b/test/sector-mode.sh
index 7a2faea..439ef33 100755
--- a/test/sector-mode.sh
+++ b/test/sector-mode.sh
@@ -15,13 +15,8 @@ ALIGN_SIZE=`getconf PAGESIZE`
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
-
-$NDCTL disable-region -b $NFIT_TEST_BUS1 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS1 all
-$NDCTL enable-region -b $NFIT_TEST_BUS1 all
+reset
+reset1
rc=1
query=". | sort_by(.size) | reverse | .[0].dev"
diff --git a/test/track-uuid.sh b/test/track-uuid.sh
index be3cf9c..3bacd2c 100755
--- a/test/track-uuid.sh
+++ b/test/track-uuid.sh
@@ -12,9 +12,7 @@ trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
-$NDCTL enable-region -b $NFIT_TEST_BUS0 all
+reset
rc=1

View File

@ -1,41 +0,0 @@
ndtest/ack-shutdown-count: Skip the test on ndtest
BZ:
Brew:
commit 6e85cac1958f920f231b94ff570ac0e434595b7d
Author: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Date: Tue Jan 25 02:34:25 2022 +0530
ndtest/ack-shutdown-count: Skip the test on ndtest
The PAPR has non-latched dirty shutdown implementation.
The test is enabling/disabling the LSS latch which is
irrelavent from PAPR pov. Skip the test.
Link: https://lore.kernel.org/r/20220124210425.1493410-1-vaibhav@linux.ibm.com
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/test/ack-shutdown-count-set.c b/test/ack-shutdown-count-set.c
index a9e95c6..f091a40 100644
--- a/test/ack-shutdown-count-set.c
+++ b/test/ack-shutdown-count-set.c
@@ -117,6 +117,7 @@ static int test_ack_shutdown_count_set(int loglevel, struct ndctl_test *test,
int main(int argc, char *argv[])
{
+ char *test_env = getenv("NDCTL_TEST_FAMILY");
struct ndctl_test *test = ndctl_test_new(0);
struct ndctl_ctx *ctx;
int rc;
@@ -126,6 +127,9 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}
+ if (test_env && strcmp(test_env, "PAPR") == 0)
+ return ndctl_test_result(test, 77);
+
rc = ndctl_new(&ctx);
if (rc)
return ndctl_test_result(test, rc);

View File

@ -1,42 +0,0 @@
ndctl/test: Skip BLK flags checks
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2141031
commit 756a6598a0fa6cebdd0e98564af089ca6b463fb1
Author: Dan Williams <dan.j.williams@intel.com>
Date: Wed Jan 5 13:32:05 2022 -0800
ndctl/test: Skip BLK flags checks
With the removal of BLK-mode support, test/libndctl will fail to detect the
JEDEC format on the nfit_test bus. Report + skip that check rather than
fail the test when that happens.
Link: https://lore.kernel.org/r/164141832529.3990253.16538298357542644310.stgit@dwillia2-desk3.amr.corp.intel.com
Tested-by: Alison Schofield <alison.schofield@intel.com>
Tested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/test/libndctl.c b/test/libndctl.c
index c0e4b4c..1e97926 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -2535,7 +2535,7 @@ static int check_dimms(struct ndctl_bus *bus, struct dimm *dimms, int n,
fprintf(stderr, "dimm%d expected formats: %d got: %d\n",
i, dimms[i].formats,
ndctl_dimm_get_formats(dimm));
- return -ENXIO;
+ fprintf(stderr, "continuing...\n");
}
for (j = 0; j < dimms[i].formats; j++) {
if (ndctl_dimm_get_formatN(dimm, j) != dimms[i].format[j]) {
@@ -2543,7 +2543,7 @@ static int check_dimms(struct ndctl_bus *bus, struct dimm *dimms, int n,
"dimm%d expected format[%d]: %d got: %d\n",
i, j, dimms[i].format[j],
ndctl_dimm_get_formatN(dimm, j));
- return -ENXIO;
+ fprintf(stderr, "continuing...\n");
}
}
}

View File

@ -1,118 +0,0 @@
ndctl/test: add checking the presence of jq command ahead
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2141031
commit 7ce2fddfa3f108036a2d81de4d2e66ac29e4631e
Author: QI Fuli <qi.fuli@fujitsu.com>
Date: Wed Feb 3 22:21:08 2021 +0900
ndctl/test: add checking the presence of jq command ahead
Due to the lack of jq command, the result of the test will be 'fail'.
This patch adds checking the presence of jq commmand ahead.
If there is no jq command in the system, the test will be marked as 'skip'.
Signed-off-by: QI Fuli <qi.fuli@fujitsu.com>
Link: https://github.com/pmem/ndctl/issues/141
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Link: https://lore.kernel.org/r/20210203132108.6246-1-qi.fuli@fujitsu.com
diff --git a/test/daxdev-errors.sh b/test/daxdev-errors.sh
index 6281f32..9547d78 100755
--- a/test/daxdev-errors.sh
+++ b/test/daxdev-errors.sh
@@ -9,6 +9,7 @@ rc=77
. $(dirname $0)/common
check_min_kver "4.12" || do_skip "lacks dax dev error handling"
+check_prereq "jq"
trap 'err $LINENO' ERR
diff --git a/test/inject-error.sh b/test/inject-error.sh
index c636033..7d0b826 100755
--- a/test/inject-error.sh
+++ b/test/inject-error.sh
@@ -11,6 +11,8 @@ err_count=8
. $(dirname $0)/common
+check_prereq "jq"
+
trap 'err $LINENO' ERR
# sample json:
diff --git a/test/inject-smart.sh b/test/inject-smart.sh
index 94705df..4ca83b8 100755
--- a/test/inject-smart.sh
+++ b/test/inject-smart.sh
@@ -166,6 +166,7 @@ do_tests()
}
check_min_kver "4.19" || do_skip "kernel $KVER may not support smart (un)injection"
+check_prereq "jq"
modprobe nfit_test
rc=1
diff --git a/test/label-compat.sh b/test/label-compat.sh
index 340b93d..8ab2858 100755
--- a/test/label-compat.sh
+++ b/test/label-compat.sh
@@ -10,6 +10,7 @@ BASE=$(dirname $0)
. $BASE/common
check_min_kver "4.11" || do_skip "may not provide reliable isetcookie values"
+check_prereq "jq"
trap 'err $LINENO' ERR
diff --git a/test/max_available_extent_ns.sh b/test/max_available_extent_ns.sh
index 14d741d..343f3c9 100755
--- a/test/max_available_extent_ns.sh
+++ b/test/max_available_extent_ns.sh
@@ -9,6 +9,7 @@ rc=77
trap 'err $LINENO' ERR
check_min_kver "4.19" || do_skip "kernel $KVER may not support max_available_size"
+check_prereq "jq"
init()
{
diff --git a/test/monitor.sh b/test/monitor.sh
index cdab5e1..28c5541 100755
--- a/test/monitor.sh
+++ b/test/monitor.sh
@@ -13,6 +13,8 @@ smart_supported_bus=""
. $(dirname $0)/common
+check_prereq "jq"
+
trap 'err $LINENO' ERR
check_min_kver "4.15" || do_skip "kernel $KVER may not support monitor service"
diff --git a/test/multi-dax.sh b/test/multi-dax.sh
index e932569..8496619 100755
--- a/test/multi-dax.sh
+++ b/test/multi-dax.sh
@@ -9,6 +9,7 @@ rc=77
. $(dirname $0)/common
check_min_kver "4.13" || do_skip "may lack multi-dax support"
+check_prereq "jq"
trap 'err $LINENO' ERR
diff --git a/test/sector-mode.sh b/test/sector-mode.sh
index dd7013e..54fa806 100755
--- a/test/sector-mode.sh
+++ b/test/sector-mode.sh
@@ -6,6 +6,8 @@ rc=77
. $(dirname $0)/common
+check_prereq "jq"
+
set -e
trap 'err $LINENO' ERR

View File

@ -1,84 +0,0 @@
namespace-action: Drop zero namespace checks.
BZ:
Brew:
commit 80e0d88c3098bd419e26146a8cb3b693fdd06417
Author: Santosh Sivaraj <santosh@fossix.org>
Date: Wed Jan 6 14:17:42 2021 +0100
namespace-action: Drop zero namespace checks.
With seed namespaces catched early on these checks for sizes in enable
and destroy namespace code path are not needed.
Reverts commit b9cb03f6d5a8 ("ndctl/namespace: Fix enable-namespace
error for seed namespaces")
Reverts commit e01045e58ad5 ("ndctl/namespace: Fix destroy-namespace
accounting relative to seed devices")
Link: https://patchwork.kernel.org/patch/11739975/
Link: https://lore.kernel.org/r/eb4bc7885708fa13e3d37286bc4a4219b1e4e5b6.1609938610.git.msuchanek@suse.de
Fixes: b9cb03f6d5a8 ("ndctl/namespace: Fix enable-namespace error for seed namespaces")
Fixes: e01045e58ad5 ("ndctl/namespace: Fix destroy-namespace accounting relative to seed devices")
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
[rebased on top of the previous patches]
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 536e142..87f60b9 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -4531,16 +4531,11 @@ NDCTL_EXPORT int ndctl_namespace_enable(struct ndctl_namespace *ndns)
const char *devname = ndctl_namespace_get_devname(ndns);
struct ndctl_ctx *ctx = ndctl_namespace_get_ctx(ndns);
struct ndctl_region *region = ndns->region;
- unsigned long long size = ndctl_namespace_get_size(ndns);
int rc;
if (ndctl_namespace_is_enabled(ndns))
return 0;
- /* Don't try to enable idle namespace (no capacity allocated) */
- if (size == 0)
- return -ENXIO;
-
rc = ndctl_bind(ctx, ndns->module, devname);
/*
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index cd822b3..c67c086 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -1164,15 +1164,12 @@ static int namespace_destroy(struct ndctl_region *region,
struct ndctl_namespace *ndns)
{
const char *devname = ndctl_namespace_get_devname(ndns);
- unsigned long long size;
int rc;
rc = namespace_prep_reconfig(region, ndns);
if (rc < 0)
return rc;
- size = ndctl_namespace_get_size(ndns);
-
/* Labeled namespace, destroy label / allocation */
if (rc == 2) {
rc = ndctl_namespace_delete(ndns);
@@ -1180,13 +1177,6 @@ static int namespace_destroy(struct ndctl_region *region,
debug("%s: failed to reclaim\n", devname);
}
- /*
- * Don't report a destroyed namespace when no capacity was
- * allocated.
- */
- if (size == 0 && rc == 0)
- rc = 1;
-
return rc;
}

View File

@ -1,57 +0,0 @@
ndctl/namespace: Skip seed namespaces when processing all namespaces.
BZ:
Brew:
commit 9bd2994f91bb77604521cbe09a76a51d092c2cfd
Author: Michal Suchanek <msuchanek@suse.de>
Date: Wed Jan 6 14:17:40 2021 +0100
ndctl/namespace: Skip seed namespaces when processing all namespaces.
The seed namespaces are exposed by the kernel but most operations are
not valid on seed namespaces.
When processing all namespaces the user gets confusing errors from ndctl
trying to process seed namespaces. The kernel does not provide any way
to tell that a namspace is seed namespace but skipping namespaces with
zero size and UUID is a good heuristic.
The user can still specify the namespace by name directly in case
processing it is desirable.
Link: https://patchwork.kernel.org/patch/11473645/
Link: https://lore.kernel.org/r/e55ae2c17b8b9c3288491efe6214338118e8c5ae.1609938610.git.msuchanek@suse.de
Fixes: #41
Tested-by: Harish Sriram <harish@linux.ibm.com>
Reviewed-by: Santosh S <santosh@fossix.org>
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index 1e8a2cd..5e65ed5 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -2210,9 +2210,19 @@ static int do_xaction_namespace(const char *namespace,
ndctl_namespace_foreach_safe(region, ndns, _n) {
ndns_name = ndctl_namespace_get_devname(ndns);
- if (strcmp(namespace, "all") != 0
- && strcmp(namespace, ndns_name) != 0)
- continue;
+ if (strcmp(namespace, "all") == 0) {
+ static const uuid_t zero_uuid;
+ uuid_t uuid;
+
+ ndctl_namespace_get_uuid(ndns, uuid);
+ if (!ndctl_namespace_get_size(ndns) &&
+ !memcmp(uuid, zero_uuid, sizeof(uuid_t)))
+ continue;
+ } else {
+ if (strcmp(namespace, ndns_name) != 0)
+ continue;
+ }
+
switch (action) {
case ACTION_DISABLE:
rc = ndctl_namespace_disable_safe(ndns);

View File

@ -1,179 +0,0 @@
libndctl/papr: Add limited support for inject-smart
BZ:
Brew:
commit 9ef460eb7fd1b1f286955b18db8c18cd1a640e77
Author: Vaibhav Jain <vaibhav@linux.ibm.com>
Date: Tue Jan 25 02:08:04 2022 +0530
libndctl/papr: Add limited support for inject-smart
Implements support for ndctl inject-smart command by providing an
implementation of 'smart_inject*' dimm-ops callbacks. Presently only
support for injecting unsafe-shutdown and fatal-health states is
available.
The patch also introduce various PAPR PDSM structures that are used to
communicate the inject-smart errors to the papr_scm kernel
module. This is done via SMART_INJECT PDSM which sends a payload of
type 'struct nd_papr_pdsm_smart_inject'.
With the patch following output from ndctl inject-smart command is
expected for PAPR NVDIMMs:
$ sudo ndctl inject-smart -fU nmem0
[
{
"dev":"nmem0",
"flag_failed_flush":true,
"flag_smart_event":true,
"health":{
"health_state":"fatal",
"shutdown_state":"dirty",
"shutdown_count":0
}
}
]
$ sudo ndctl inject-smart -N nmem0
[
{
"dev":"nmem0",
"health":{
"health_state":"ok",
"shutdown_state":"clean",
"shutdown_count":0
}
}
]
The patch depends on the kernel PAPR PDSM implementation for
PDSM_SMART_INJECT posted at [1].
[1] : https://lore.kernel.org/nvdimm/20220124202204.1488346-1-vaibhav@linux.ibm.com/
Link: https://lore.kernel.org/r/20220124203804.1490254-1-vaibhav@linux.ibm.com
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/ndctl/lib/papr.c b/ndctl/lib/papr.c
index 46cf9c1..7a1d559 100644
--- a/ndctl/lib/papr.c
+++ b/ndctl/lib/papr.c
@@ -221,6 +221,41 @@ static unsigned int papr_smart_get_shutdown_state(struct ndctl_cmd *cmd)
return health.dimm_bad_shutdown;
}
+static int papr_smart_inject_supported(struct ndctl_dimm *dimm)
+{
+ if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_CALL))
+ return -EOPNOTSUPP;
+
+ if (!test_dimm_dsm(dimm, PAPR_PDSM_SMART_INJECT))
+ return -EIO;
+
+ return ND_SMART_INJECT_HEALTH_STATE | ND_SMART_INJECT_UNCLEAN_SHUTDOWN;
+}
+
+static int papr_smart_inject_valid(struct ndctl_cmd *cmd)
+{
+ if (cmd->type != ND_CMD_CALL ||
+ to_pdsm(cmd)->cmd_status != 0 ||
+ to_pdsm_cmd(cmd) != PAPR_PDSM_SMART_INJECT)
+ return -EINVAL;
+
+ return 0;
+}
+
+static struct ndctl_cmd *papr_new_smart_inject(struct ndctl_dimm *dimm)
+{
+ struct ndctl_cmd *cmd;
+
+ cmd = allocate_cmd(dimm, PAPR_PDSM_SMART_INJECT,
+ sizeof(struct nd_papr_pdsm_smart_inject));
+ if (!cmd)
+ return NULL;
+ /* Set the input payload size */
+ to_ndcmd(cmd)->nd_size_in = ND_PDSM_HDR_SIZE +
+ sizeof(struct nd_papr_pdsm_smart_inject);
+ return cmd;
+}
+
static unsigned int papr_smart_get_life_used(struct ndctl_cmd *cmd)
{
struct nd_papr_pdsm_health health;
@@ -255,11 +290,37 @@ static unsigned int papr_smart_get_shutdown_count(struct ndctl_cmd *cmd)
return (health.extension_flags & PDSM_DIMM_DSC_VALID) ?
(health.dimm_dsc) : 0;
+}
+
+static int papr_cmd_smart_inject_fatal(struct ndctl_cmd *cmd, bool enable)
+{
+ if (papr_smart_inject_valid(cmd) < 0)
+ return -EINVAL;
+
+ to_payload(cmd)->inject.flags |= PDSM_SMART_INJECT_HEALTH_FATAL;
+ to_payload(cmd)->inject.fatal_enable = enable;
+ return 0;
+}
+
+static int papr_cmd_smart_inject_unsafe_shutdown(struct ndctl_cmd *cmd,
+ bool enable)
+{
+ if (papr_smart_inject_valid(cmd) < 0)
+ return -EINVAL;
+
+ to_payload(cmd)->inject.flags |= PDSM_SMART_INJECT_BAD_SHUTDOWN;
+ to_payload(cmd)->inject.unsafe_shutdown_enable = enable;
+
+ return 0;
}
struct ndctl_dimm_ops * const papr_dimm_ops = &(struct ndctl_dimm_ops) {
.cmd_is_supported = papr_cmd_is_supported,
+ .new_smart_inject = papr_new_smart_inject,
+ .smart_inject_supported = papr_smart_inject_supported,
+ .smart_inject_fatal = papr_cmd_smart_inject_fatal,
+ .smart_inject_unsafe_shutdown = papr_cmd_smart_inject_unsafe_shutdown,
.smart_get_flags = papr_smart_get_flags,
.get_firmware_status = papr_get_firmware_status,
.xlat_firmware_status = papr_xlat_firmware_status,
diff --git a/ndctl/lib/papr_pdsm.h b/ndctl/lib/papr_pdsm.h
index f45b1e4..20ac20f 100644
--- a/ndctl/lib/papr_pdsm.h
+++ b/ndctl/lib/papr_pdsm.h
@@ -121,12 +121,29 @@ struct nd_papr_pdsm_health {
enum papr_pdsm {
PAPR_PDSM_MIN = 0x0,
PAPR_PDSM_HEALTH,
+ PAPR_PDSM_SMART_INJECT,
PAPR_PDSM_MAX,
};
+/* Flags for injecting specific smart errors */
+#define PDSM_SMART_INJECT_HEALTH_FATAL (1 << 0)
+#define PDSM_SMART_INJECT_BAD_SHUTDOWN (1 << 1)
+
+struct nd_papr_pdsm_smart_inject {
+ union {
+ struct {
+ /* One or more of PDSM_SMART_INJECT_ */
+ __u32 flags;
+ __u8 fatal_enable;
+ __u8 unsafe_shutdown_enable;
+ };
+ __u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE];
+ };
+};
/* Maximal union that can hold all possible payload types */
union nd_pdsm_payload {
struct nd_papr_pdsm_health health;
+ struct nd_papr_pdsm_smart_inject inject;
__u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE];
} __attribute__((packed));

View File

@ -1,133 +0,0 @@
libndctl/papr: Add support for reporting shutdown-count
BZ:
Brew:
commit aa990008f48f21121474a411d829f24e832c89a2
Author: Vaibhav Jain <vaibhav@linux.ibm.com>
Date: Tue Jan 25 00:26:05 2022 +0530
libndctl/papr: Add support for reporting shutdown-count
Add support for reporting dirty-shutdown-count (DSC) for PAPR based
NVDIMMs. The sysfs attribute exposing this value is located at
nmemX/papr/dirty_shutdown.
This counter is also returned in payload for PAPR_PDSM_HEALTH as newly
introduced member 'dimm_dsc' in 'struct nd_papr_pdsm_health'. Presence
of 'DSC' is indicated by the PDSM_DIMM_DSC_VALID extension flag.
The patch implements 'ndctl_dimm_ops.smart_get_shutdown_count'
callback in implemented as papr_smart_get_shutdown_count().
Kernel side changes to support reporting DSC have been merged to linux kernel
via patch proposed at [1]. With updated kernel 'ndctl list -DH' reports
following output on PPC64:
$ sudo ndctl list -DH
[
{
"dev":"nmem0",
"health":{
"health_state":"ok",
"life_used_percentage":50,
"shutdown_state":"clean",
"shutdown_count":10
}
}
]
[1] http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20210624080621.252038-1-vaibhav@linux.ibm.com
Link: https://lore.kernel.org/r/20220124185605.1465681-1-vaibhav@linux.ibm.com
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 47a234c..5979a92 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -1819,8 +1819,12 @@ static int add_papr_dimm(struct ndctl_dimm *dimm, const char *dimm_base)
/* Allocate monitor mode fd */
dimm->health_eventfd = open(path, O_RDONLY|O_CLOEXEC);
- rc = 0;
+ /* Get the dirty shutdown counter value */
+ sprintf(path, "%s/papr/dirty_shutdown", dimm_base);
+ if (sysfs_read_attr(ctx, path, buf) == 0)
+ dimm->dirty_shutdown = strtoll(buf, NULL, 0);
+ rc = 0;
} else if (strcmp(buf, "nvdimm_test") == 0) {
/* probe via common populate_dimm_attributes() */
rc = populate_dimm_attributes(dimm, dimm_base, "papr");
diff --git a/ndctl/lib/papr.c b/ndctl/lib/papr.c
index 43b8412..46cf9c1 100644
--- a/ndctl/lib/papr.c
+++ b/ndctl/lib/papr.c
@@ -165,6 +165,9 @@ static unsigned int papr_smart_get_flags(struct ndctl_cmd *cmd)
if (health.extension_flags & PDSM_DIMM_HEALTH_RUN_GAUGE_VALID)
flags |= ND_SMART_USED_VALID;
+ if (health.extension_flags & PDSM_DIMM_DSC_VALID)
+ flags |= ND_SMART_SHUTDOWN_COUNT_VALID;
+
return flags;
}
@@ -236,6 +239,25 @@ static unsigned int papr_smart_get_life_used(struct ndctl_cmd *cmd)
(100 - health.dimm_fuel_gauge) : 0;
}
+static unsigned int papr_smart_get_shutdown_count(struct ndctl_cmd *cmd)
+{
+
+ struct nd_papr_pdsm_health health;
+
+ /* Ignore in case of error or invalid pdsm */
+ if (!cmd_is_valid(cmd) ||
+ to_pdsm(cmd)->cmd_status != 0 ||
+ to_pdsm_cmd(cmd) != PAPR_PDSM_HEALTH)
+ return 0;
+
+ /* get the payload from command */
+ health = to_payload(cmd)->health;
+
+ return (health.extension_flags & PDSM_DIMM_DSC_VALID) ?
+ (health.dimm_dsc) : 0;
+
+}
+
struct ndctl_dimm_ops * const papr_dimm_ops = &(struct ndctl_dimm_ops) {
.cmd_is_supported = papr_cmd_is_supported,
.smart_get_flags = papr_smart_get_flags,
@@ -245,4 +267,5 @@ struct ndctl_dimm_ops * const papr_dimm_ops = &(struct ndctl_dimm_ops) {
.smart_get_health = papr_smart_get_health,
.smart_get_shutdown_state = papr_smart_get_shutdown_state,
.smart_get_life_used = papr_smart_get_life_used,
+ .smart_get_shutdown_count = papr_smart_get_shutdown_count,
};
diff --git a/ndctl/lib/papr_pdsm.h b/ndctl/lib/papr_pdsm.h
index 1bac8a7..f45b1e4 100644
--- a/ndctl/lib/papr_pdsm.h
+++ b/ndctl/lib/papr_pdsm.h
@@ -75,6 +75,9 @@
/* Indicate that the 'dimm_fuel_gauge' field is valid */
#define PDSM_DIMM_HEALTH_RUN_GAUGE_VALID 1
+/* Indicate that the 'dimm_dsc' field is valid */
+#define PDSM_DIMM_DSC_VALID 2
+
/*
* Struct exchanged between kernel & ndctl in for PAPR_PDSM_HEALTH
* Various flags indicate the health status of the dimm.
@@ -103,6 +106,9 @@ struct nd_papr_pdsm_health {
/* Extension flag PDSM_DIMM_HEALTH_RUN_GAUGE_VALID */
__u16 dimm_fuel_gauge;
+
+ /* Extension flag PDSM_DIMM_DSC_VALID */
+ __u64 dimm_dsc;
};
__u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE];
};

View File

@ -1,42 +0,0 @@
ndctl/test: Move sector-mode to a different region
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2143636
commit b787320498508192f1e04ac38d39da4eb3ca26e9
Author: Dan Williams <dan.j.williams@intel.com>
Date: Wed Jan 5 13:32:10 2022 -0800
ndctl/test: Move sector-mode to a different region
Previously the largest region on the nfit_test.1 bus belonged to a BLK-mode
region. With the removal of BLK-mode support update the test to instead
find a suitable PMEM region to perform the checkout.
Link: https://lore.kernel.org/r/164141833068.3990253.15694496866707006837.stgit@dwillia2-desk3.amr.corp.intel.com
Tested-by: Alison Schofield <alison.schofield@intel.com>
Tested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
diff --git a/test/sector-mode.sh b/test/sector-mode.sh
index 439ef33..f70b0f1 100755
--- a/test/sector-mode.sh
+++ b/test/sector-mode.sh
@@ -19,11 +19,11 @@ reset
reset1
rc=1
-query=". | sort_by(.size) | reverse | .[0].dev"
-NAMESPACE=$($NDCTL list -b $NFIT_TEST_BUS1 -N | jq -r "$query")
-REGION=$($NDCTL list -R --namespace=$NAMESPACE | jq -r "(.[]) | .dev")
+query=". | sort_by(.available_size) | reverse | .[0].dev"
+REGION=$($NDCTL list -R -b $NFIT_TEST_BUS1 | jq -r "$query")
echo 0 > /sys/bus/nd/devices/$REGION/read_only
-$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K
+echo $ALIGN_SIZE > /sys/bus/nd/devices/$REGION/align
+NAMESPACE=$($NDCTL create-namespace --no-autolabel -r $REGION -m sector -f -l 4K | jq -r ".dev")
$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m dax -f -a $ALIGN_SIZE
$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K

View File

@ -1,38 +0,0 @@
ndctl/scrub: Stop translating return values
BZ:
Brew:
commit c52109355b715bbe21e284090435bee7563863cc
Author: Dan Williams <dan.j.williams@intel.com>
Date: Wed May 26 16:33:04 2021 -0700
ndctl/scrub: Stop translating return values
In preparation for triggering a poll loop within ndctl_bus_start_scrub(),
stop translating return values into -EOPNOTSUPP.
Link: https://lore.kernel.org/r/162207198482.3715490.5994844104395495686.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index aa36a3c..e5641fe 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -1354,14 +1354,8 @@ static int __ndctl_bus_get_scrub_state(struct ndctl_bus *bus,
NDCTL_EXPORT int ndctl_bus_start_scrub(struct ndctl_bus *bus)
{
struct ndctl_ctx *ctx = ndctl_bus_get_ctx(bus);
- int rc;
- rc = sysfs_write_attr(ctx, bus->scrub_path, "1\n");
- if (rc == -EBUSY)
- return rc;
- else if (rc < 0)
- return -EOPNOTSUPP;
- return 0;
+ return sysfs_write_attr(ctx, bus->scrub_path, "1\n");
}
NDCTL_EXPORT int ndctl_bus_get_scrub_state(struct ndctl_bus *bus)

View File

@ -1,219 +0,0 @@
libndctl: Unify adding dimms for papr and nfit families
BZ:
Brew:
commit daef3a386a9c45105a2c045ddee46600e265939f
Author: Santosh Sivaraj <santosh@fossix.org>
Date: Thu May 13 11:42:15 2021 +0530
libndctl: Unify adding dimms for papr and nfit families
In preparation for enabling tests on non-nfit devices, unify both, already very
similar, functions into one. This will help in adding all attributes needed for
the unit tests. Since the function doesn't fail if some of the dimm attributes
are missing, this will work fine on PAPR platforms though only part of the DIMM
attributes are provided (This doesn't mean that all of the DIMM attributes can
be missing).
Link: https://lore.kernel.org/r/20210513061218.760322-1-santosh@fossix.org
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 2f6d806..e45353f 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -1646,41 +1646,9 @@ static int ndctl_bind(struct ndctl_ctx *ctx, struct kmod_module *module,
static int ndctl_unbind(struct ndctl_ctx *ctx, const char *devpath);
static struct kmod_module *to_module(struct ndctl_ctx *ctx, const char *alias);
-static int add_papr_dimm(struct ndctl_dimm *dimm, const char *dimm_base)
-{
- int rc = -ENODEV;
- char buf[SYSFS_ATTR_SIZE];
- struct ndctl_ctx *ctx = dimm->bus->ctx;
- char *path = calloc(1, strlen(dimm_base) + 100);
- const char * const devname = ndctl_dimm_get_devname(dimm);
-
- dbg(ctx, "%s: Probing of_pmem dimm at %s\n", devname, dimm_base);
-
- if (!path)
- return -ENOMEM;
-
- /* construct path to the papr compatible dimm flags file */
- sprintf(path, "%s/papr/flags", dimm_base);
-
- if (ndctl_bus_is_papr_scm(dimm->bus) &&
- sysfs_read_attr(ctx, path, buf) == 0) {
-
- dbg(ctx, "%s: Adding papr-scm dimm flags:\"%s\"\n", devname, buf);
- dimm->cmd_family = NVDIMM_FAMILY_PAPR;
-
- /* Parse dimm flags */
- parse_papr_flags(dimm, buf);
-
- /* Allocate monitor mode fd */
- dimm->health_eventfd = open(path, O_RDONLY|O_CLOEXEC);
- rc = 0;
- }
-
- free(path);
- return rc;
-}
-
-static int add_nfit_dimm(struct ndctl_dimm *dimm, const char *dimm_base)
+static int populate_dimm_attributes(struct ndctl_dimm *dimm,
+ const char *dimm_base,
+ const char *bus_prefix)
{
int i, rc = -1;
char buf[SYSFS_ATTR_SIZE];
@@ -1694,7 +1662,7 @@ static int add_nfit_dimm(struct ndctl_dimm *dimm, const char *dimm_base)
* 'unique_id' may not be available on older kernels, so don't
* fail if the read fails.
*/
- sprintf(path, "%s/nfit/id", dimm_base);
+ sprintf(path, "%s/%s/id", dimm_base, bus_prefix);
if (sysfs_read_attr(ctx, path, buf) == 0) {
unsigned int b[9];
@@ -1709,68 +1677,74 @@ static int add_nfit_dimm(struct ndctl_dimm *dimm, const char *dimm_base)
}
}
- sprintf(path, "%s/nfit/handle", dimm_base);
+ sprintf(path, "%s/%s/handle", dimm_base, bus_prefix);
if (sysfs_read_attr(ctx, path, buf) < 0)
goto err_read;
dimm->handle = strtoul(buf, NULL, 0);
- sprintf(path, "%s/nfit/phys_id", dimm_base);
+ sprintf(path, "%s/%s/phys_id", dimm_base, bus_prefix);
if (sysfs_read_attr(ctx, path, buf) < 0)
goto err_read;
dimm->phys_id = strtoul(buf, NULL, 0);
- sprintf(path, "%s/nfit/serial", dimm_base);
+ sprintf(path, "%s/%s/serial", dimm_base, bus_prefix);
if (sysfs_read_attr(ctx, path, buf) == 0)
dimm->serial = strtoul(buf, NULL, 0);
- sprintf(path, "%s/nfit/vendor", dimm_base);
+ sprintf(path, "%s/%s/vendor", dimm_base, bus_prefix);
if (sysfs_read_attr(ctx, path, buf) == 0)
dimm->vendor_id = strtoul(buf, NULL, 0);
- sprintf(path, "%s/nfit/device", dimm_base);
+ sprintf(path, "%s/%s/device", dimm_base, bus_prefix);
if (sysfs_read_attr(ctx, path, buf) == 0)
dimm->device_id = strtoul(buf, NULL, 0);
- sprintf(path, "%s/nfit/rev_id", dimm_base);
+ sprintf(path, "%s/%s/rev_id", dimm_base, bus_prefix);
if (sysfs_read_attr(ctx, path, buf) == 0)
dimm->revision_id = strtoul(buf, NULL, 0);
- sprintf(path, "%s/nfit/dirty_shutdown", dimm_base);
+ sprintf(path, "%s/%s/dirty_shutdown", dimm_base, bus_prefix);
if (sysfs_read_attr(ctx, path, buf) == 0)
dimm->dirty_shutdown = strtoll(buf, NULL, 0);
- sprintf(path, "%s/nfit/subsystem_vendor", dimm_base);
+ sprintf(path, "%s/%s/subsystem_vendor", dimm_base, bus_prefix);
if (sysfs_read_attr(ctx, path, buf) == 0)
dimm->subsystem_vendor_id = strtoul(buf, NULL, 0);
- sprintf(path, "%s/nfit/subsystem_device", dimm_base);
+ sprintf(path, "%s/%s/subsystem_device", dimm_base, bus_prefix);
if (sysfs_read_attr(ctx, path, buf) == 0)
dimm->subsystem_device_id = strtoul(buf, NULL, 0);
- sprintf(path, "%s/nfit/subsystem_rev_id", dimm_base);
+ sprintf(path, "%s/%s/subsystem_rev_id", dimm_base, bus_prefix);
if (sysfs_read_attr(ctx, path, buf) == 0)
dimm->subsystem_revision_id = strtoul(buf, NULL, 0);
- sprintf(path, "%s/nfit/family", dimm_base);
+ sprintf(path, "%s/%s/family", dimm_base, bus_prefix);
if (sysfs_read_attr(ctx, path, buf) == 0)
dimm->cmd_family = strtoul(buf, NULL, 0);
- sprintf(path, "%s/nfit/dsm_mask", dimm_base);
+ sprintf(path, "%s/%s/dsm_mask", dimm_base, bus_prefix);
if (sysfs_read_attr(ctx, path, buf) == 0)
dimm->nfit_dsm_mask = strtoul(buf, NULL, 0);
- sprintf(path, "%s/nfit/format", dimm_base);
+ sprintf(path, "%s/%s/format", dimm_base, bus_prefix);
if (sysfs_read_attr(ctx, path, buf) == 0)
dimm->format[0] = strtoul(buf, NULL, 0);
for (i = 1; i < dimm->formats; i++) {
- sprintf(path, "%s/nfit/format%d", dimm_base, i);
+ sprintf(path, "%s/%s/format%d", dimm_base, bus_prefix, i);
if (sysfs_read_attr(ctx, path, buf) == 0)
dimm->format[i] = strtoul(buf, NULL, 0);
}
- sprintf(path, "%s/nfit/flags", dimm_base);
- if (sysfs_read_attr(ctx, path, buf) == 0)
- parse_nfit_mem_flags(dimm, buf);
+ sprintf(path, "%s/%s/flags", dimm_base, bus_prefix);
+ if (sysfs_read_attr(ctx, path, buf) == 0) {
+ if (ndctl_bus_has_nfit(dimm->bus))
+ parse_nfit_mem_flags(dimm, buf);
+ else if (ndctl_bus_is_papr_scm(dimm->bus)) {
+ dimm->cmd_family = NVDIMM_FAMILY_PAPR;
+ parse_papr_flags(dimm, buf);
+ }
+ }
dimm->health_eventfd = open(path, O_RDONLY|O_CLOEXEC);
rc = 0;
@@ -1792,7 +1766,8 @@ static void *add_dimm(void *parent, int id, const char *dimm_base)
if (!path)
return NULL;
- sprintf(path, "%s/nfit/formats", dimm_base);
+ sprintf(path, "%s/%s/formats", dimm_base,
+ ndctl_bus_has_nfit(bus) ? "nfit" : "papr");
if (sysfs_read_attr(ctx, path, buf) < 0)
formats = 1;
else
@@ -1866,13 +1841,12 @@ static void *add_dimm(void *parent, int id, const char *dimm_base)
else
dimm->fwa_result = fwa_result_to_result(buf);
+ dimm->formats = formats;
/* Check if the given dimm supports nfit */
if (ndctl_bus_has_nfit(bus)) {
- dimm->formats = formats;
- rc = add_nfit_dimm(dimm, dimm_base);
- } else if (ndctl_bus_has_of_node(bus)) {
- rc = add_papr_dimm(dimm, dimm_base);
- }
+ rc = populate_dimm_attributes(dimm, dimm_base, "nfit");
+ } else if (ndctl_bus_has_of_node(bus))
+ rc = populate_dimm_attributes(dimm, dimm_base, "papr");
if (rc == -ENODEV) {
/* Unprobed dimm with no family */
@@ -2531,13 +2505,12 @@ static void *add_region(void *parent, int id, const char *region_base)
goto err_read;
region->num_mappings = strtoul(buf, NULL, 0);
- sprintf(path, "%s/nfit/range_index", region_base);
- if (ndctl_bus_has_nfit(bus)) {
- if (sysfs_read_attr(ctx, path, buf) < 0)
- goto err_read;
- region->range_index = strtoul(buf, NULL, 0);
- } else
+ sprintf(path, "%s/%s/range_index", region_base,
+ ndctl_bus_has_nfit(bus) ? "nfit": "papr");
+ if (sysfs_read_attr(ctx, path, buf) < 0)
region->range_index = -1;
+ else
+ region->range_index = strtoul(buf, NULL, 0);
sprintf(path, "%s/read_only", region_base);
if (sysfs_read_attr(ctx, path, buf) < 0)

View File

@ -1,120 +0,0 @@
libndctl/papr: Fix probe for papr-scm compatible nvdimms
BZ:
Brew:
commit e086106b4d81a2079141c848db7695451c04e877
Author: Vaibhav Jain <vaibhav@linux.ibm.com>
Date: Mon May 17 21:18:24 2021 +0530
libndctl/papr: Fix probe for papr-scm compatible nvdimms
With recent changes introduced for unification of PAPR and NFIT
families the probe for papr-scm nvdimms is broken since they don't
expose 'handle' or 'phys_id' sysfs attributes. These attributes are
only exposed by NFIT and 'nvdimm_test' nvdimms. Since 'unable to read'
these sysfs attributes is a non-recoverable error hence this prevents
probing of 'PAPR-SCM' nvdimms and ndctl reports following error:
$ sudo NDCTL_LOG=debug ndctl list -DH
libndctl: ndctl_new: ctx 0x10015342c70 created
libndctl: add_dimm: nmem1: probe failed: Operation not permitted
libndctl: __sysfs_device_parse: nmem1: add_dev() failed
libndctl: add_dimm: nmem0: probe failed: Operation not permitted
libndctl: __sysfs_device_parse: nmem0: add_dev() failed
Fixing this bug is complicated by the fact these attributes are needed
for by the 'nvdimm_test' nvdimms which also uses the
NVDIMM_FAMILY_PAPR. Adding a two way comparison for these two
attributes in populate_dimm_attributes() to distinguish between
'nvdimm_test' and papr-scm nvdimms will be clunky and make future
updates to populate_dimm_attributes() error prone.
So, this patch proposes to fix the issue by re-introducing
add_papr_dimm() to probe both papr-scm and 'nvdimm_test' nvdimms. The
'compatible' sysfs attribute associated with the PAPR device is used
to distinguish between the two nvdimm types and in case an
'nvdimm_test' device is detected then forward its probe to
populate_dimm_attributes().
families")
Link: https://lore.kernel.org/r/20210517154824.142237-1-vaibhav@linux.ibm.com
Fixes: daef3a386a9c("libndctl: Unify adding dimms for papr and nfit
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff -up ndctl-71.1/ndctl/lib/libndctl.c.orig ndctl-71.1/ndctl/lib/libndctl.c
--- ndctl-71.1/ndctl/lib/libndctl.c.orig 2022-06-06 17:16:20.703762581 -0400
+++ ndctl-71.1/ndctl/lib/libndctl.c 2022-06-06 17:17:34.932019990 -0400
@@ -1757,6 +1757,58 @@ static int populate_dimm_attributes(stru
return rc;
}
+static int add_papr_dimm(struct ndctl_dimm *dimm, const char *dimm_base)
+{
+ int rc = -ENODEV;
+ char buf[SYSFS_ATTR_SIZE];
+ struct ndctl_ctx *ctx = dimm->bus->ctx;
+ char *path = calloc(1, strlen(dimm_base) + 100);
+ const char * const devname = ndctl_dimm_get_devname(dimm);
+
+ dbg(ctx, "%s: Probing of_pmem dimm at %s\n", devname, dimm_base);
+
+ if (!path)
+ return -ENOMEM;
+
+ /* Check the compatibility of the probed nvdimm */
+ sprintf(path, "%s/../of_node/compatible", dimm_base);
+ if (sysfs_read_attr(ctx, path, buf) < 0) {
+ dbg(ctx, "%s: Unable to read compatible field\n", devname);
+ rc = -ENODEV;
+ goto out;
+ }
+
+ dbg(ctx, "%s:Compatible of_pmem = '%s'\n", devname, buf);
+
+ /* Probe for papr-scm memory */
+ if (strcmp(buf, "ibm,pmemory") == 0) {
+ /* Read the dimm flags file */
+ sprintf(path, "%s/papr/flags", dimm_base);
+ if (sysfs_read_attr(ctx, path, buf) < 0) {
+ rc = -errno;
+ err(ctx, "%s: Unable to read dimm-flags\n", devname);
+ goto out;
+ }
+
+ dbg(ctx, "%s: Adding papr-scm dimm flags:\"%s\"\n", devname, buf);
+ dimm->cmd_family = NVDIMM_FAMILY_PAPR;
+
+ /* Parse dimm flags */
+ parse_papr_flags(dimm, buf);
+
+ /* Allocate monitor mode fd */
+ dimm->health_eventfd = open(path, O_RDONLY|O_CLOEXEC);
+ rc = 0;
+
+ } else if (strcmp(buf, "nvdimm_test") == 0) {
+ /* probe via common populate_dimm_attributes() */
+ rc = populate_dimm_attributes(dimm, dimm_base, "papr");
+ }
+out:
+ free(path);
+ return rc;
+}
+
static void *add_dimm(void *parent, int id, const char *dimm_base)
{
int formats, i, rc = -ENODEV;
@@ -1848,8 +1900,9 @@ static void *add_dimm(void *parent, int
/* Check if the given dimm supports nfit */
if (ndctl_bus_has_nfit(bus)) {
rc = populate_dimm_attributes(dimm, dimm_base, "nfit");
- } else if (ndctl_bus_has_of_node(bus))
- rc = populate_dimm_attributes(dimm, dimm_base, "papr");
+ } else if (ndctl_bus_has_of_node(bus)) {
+ rc = add_papr_dimm(dimm, dimm_base);
+ }
if (rc == -ENODEV) {
/* Unprobed dimm with no family */

View File

@ -1,169 +0,0 @@
ndctl/test: Prepare for BLK-aperture support removal
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2141031
commit e423b467e10e3405e6e09260b7669e7022b5f5f7
Author: Dan Williams <dan.j.williams@intel.com>
Date: Wed Jan 5 13:31:50 2022 -0800
ndctl/test: Prepare for BLK-aperture support removal
The kernel is dropping its support for the BLK-aperture access method. The
primary side effect of this for nfit_test is that NVDIMM namespace labeling
will not be enabled by default. Update the unit tests to initialize the
label index area in this scenario.
Link: https://lore.kernel.org/r/164141830999.3990253.5021445352398348657.stgit@dwillia2-desk3.amr.corp.intel.com
Tested-by: Alison Schofield <alison.schofield@intel.com>
Tested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/test/core.c b/test/core.c
index 2b03aa9..93e1dae 100644
--- a/test/core.c
+++ b/test/core.c
@@ -261,8 +261,8 @@ retry:
ndctl_bus_foreach(nd_ctx, bus) {
struct ndctl_region *region;
- if (strncmp(ndctl_bus_get_provider(bus),
- "nfit_test", 9) != 0)
+ if (strcmp(ndctl_bus_get_provider(bus),
+ "nfit_test.0") != 0)
continue;
ndctl_region_foreach(bus, region)
ndctl_region_disable_invalidate(region);
@@ -280,5 +280,30 @@ retry:
NULL, NULL, NULL, NULL);
if (rc)
kmod_unref(*ctx);
- return rc;
+
+ if (!nd_ctx)
+ return rc;
+
+ ndctl_bus_foreach (nd_ctx, bus) {
+ struct ndctl_region *region;
+ struct ndctl_dimm *dimm;
+
+ if (strcmp(ndctl_bus_get_provider(bus), "nfit_test.0") != 0)
+ continue;
+
+ ndctl_region_foreach (bus, region)
+ ndctl_region_disable_invalidate(region);
+
+ ndctl_dimm_foreach (bus, dimm) {
+ ndctl_dimm_read_label_index(dimm);
+ ndctl_dimm_init_labels(dimm, NDCTL_NS_VERSION_1_2);
+ ndctl_dimm_disable(dimm);
+ ndctl_dimm_enable(dimm);
+ }
+
+ ndctl_region_foreach (bus, region)
+ ndctl_region_enable(region);
+ }
+
+ return 0;
}
diff --git a/test/libndctl.c b/test/libndctl.c
index d9b50f4..c0e4b4c 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -2587,17 +2587,41 @@ static int check_dimms(struct ndctl_bus *bus, struct dimm *dimms, int n,
return 0;
}
-static void reset_bus(struct ndctl_bus *bus)
+enum dimm_reset {
+ DIMM_INIT,
+ DIMM_ZERO,
+};
+
+static int reset_dimms(struct ndctl_bus *bus, enum dimm_reset reset)
{
- struct ndctl_region *region;
struct ndctl_dimm *dimm;
+ int rc = 0;
+
+ ndctl_dimm_foreach(bus, dimm) {
+ if (reset == DIMM_ZERO)
+ ndctl_dimm_zero_labels(dimm);
+ else {
+ ndctl_dimm_read_label_index(dimm);
+ ndctl_dimm_init_labels(dimm, NDCTL_NS_VERSION_1_2);
+ }
+ ndctl_dimm_disable(dimm);
+ rc = ndctl_dimm_enable(dimm);
+ if (rc)
+ break;
+ }
+
+ return rc;
+}
+
+static void reset_bus(struct ndctl_bus *bus, enum dimm_reset reset)
+{
+ struct ndctl_region *region;
/* disable all regions so that set_config_data commands are permitted */
ndctl_region_foreach(bus, region)
ndctl_region_disable_invalidate(region);
- ndctl_dimm_foreach(bus, dimm)
- ndctl_dimm_zero_labels(dimm);
+ reset_dimms(bus, reset);
/* set regions back to their default state */
ndctl_region_foreach(bus, region)
@@ -2608,7 +2632,6 @@ static int do_test0(struct ndctl_ctx *ctx, struct ndctl_test *test)
{
struct ndctl_bus *bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER0);
struct ndctl_region *region;
- struct ndctl_dimm *dimm;
int rc;
if (!bus)
@@ -2625,13 +2648,10 @@ static int do_test0(struct ndctl_ctx *ctx, struct ndctl_test *test)
if (rc)
return rc;
- ndctl_dimm_foreach(bus, dimm) {
- rc = ndctl_dimm_zero_labels(dimm);
- if (rc < 0) {
- fprintf(stderr, "failed to zero %s\n",
- ndctl_dimm_get_devname(dimm));
- return rc;
- }
+ rc = reset_dimms(bus, DIMM_INIT);
+ if (rc < 0) {
+ fprintf(stderr, "failed to reset dimms\n");
+ return rc;
}
/*
@@ -2649,14 +2669,14 @@ static int do_test0(struct ndctl_ctx *ctx, struct ndctl_test *test)
rc = check_regions(bus, regions0, ARRAY_SIZE(regions0), DAX);
if (rc)
return rc;
- reset_bus(bus);
+ reset_bus(bus, DIMM_INIT);
}
if (ndctl_test_attempt(test, KERNEL_VERSION(4, 8, 0))) {
rc = check_regions(bus, regions0, ARRAY_SIZE(regions0), PFN);
if (rc)
return rc;
- reset_bus(bus);
+ reset_bus(bus, DIMM_INIT);
}
return check_regions(bus, regions0, ARRAY_SIZE(regions0), BTT);
@@ -2671,6 +2691,7 @@ static int do_test1(struct ndctl_ctx *ctx, struct ndctl_test *test)
return -ENXIO;
ndctl_bus_wait_probe(bus);
+ reset_bus(bus, DIMM_ZERO);
/*
* Starting with v4.10 the dimm on nfit_test.1 gets a unique

View File

@ -1,158 +0,0 @@
libndctl, intel: Indicate supported smart-inject types
BZ:
Brew:
commit edcd9b7e10b3b33a9660e412a2db1beab30936d3
Author: Vaibhav Jain <vaibhav@linux.ibm.com>
Date: Tue Jan 25 02:07:35 2022 +0530
libndctl, intel: Indicate supported smart-inject types
Presently the inject-smart code assumes support for injecting all
smart-errors namely media-temperature, controller-temperature,
spares-remaining, fatal-health and unsafe-shutdown. This assumption
may break in case of other non-Intel NVDIMM types namely PAPR NVDIMMs
which presently only have support for injecting unsafe-shutdown and
fatal health events.
Trying to inject-smart errors on PAPR NVDIMMs causes problems as
smart_inject() prematurely exits when trying to inject
media-temperature smart-error errors out.
To fix this issue the patch proposes extending the definition of
dimm_op 'smart_inject_supported' to return bitmap of flags indicating
the type of smart-error injections supported by an NVDIMM. These types
are indicated by the newly introduced defines ND_SMART_INJECT_* . A
dimm-ops provide can return an bitmap composed of these flags back
from its implementation of 'smart_inject_supported' to indicate to
dimm_inject_smart() which type of smart-error injection it
supports. In case of an error the dimm-op is still expected to return
a negative error code back to the caller.
The patch updates intel_dimm_smart_inject_supported() to return a
bitmap composed of all ND_SMART_INJECT_* flags to indicate support for
all smart-error types.
Finally the patch also updates smart_inject() to test for specific
ND_START_INJECT_* flags before sending a smart-inject command via
dimm-provider.
Link: https://lore.kernel.org/r/20220124203735.1490186-1-vaibhav@linux.ibm.com
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/ndctl/inject-smart.c b/ndctl/inject-smart.c
index 2b9d7e8..bd8c01e 100644
--- a/ndctl/inject-smart.c
+++ b/ndctl/inject-smart.c
@@ -395,18 +395,26 @@ out:
} \
}
-static int smart_inject(struct ndctl_dimm *dimm)
+static int smart_inject(struct ndctl_dimm *dimm, unsigned int inject_types)
{
const char *name = ndctl_dimm_get_devname(dimm);
struct ndctl_cmd *si_cmd = NULL;
int rc = -EOPNOTSUPP;
- send_inject_val(media_temperature)
- send_inject_val(ctrl_temperature)
- send_inject_val(spares)
- send_inject_bool(fatal)
- send_inject_bool(unsafe_shutdown)
+ if (inject_types & ND_SMART_INJECT_MEDIA_TEMPERATURE)
+ send_inject_val(media_temperature);
+ if (inject_types & ND_SMART_INJECT_CTRL_TEMPERATURE)
+ send_inject_val(ctrl_temperature);
+
+ if (inject_types & ND_SMART_INJECT_SPARES_REMAINING)
+ send_inject_val(spares);
+
+ if (inject_types & ND_SMART_INJECT_HEALTH_STATE)
+ send_inject_bool(fatal);
+
+ if (inject_types & ND_SMART_INJECT_UNCLEAN_SHUTDOWN)
+ send_inject_bool(unsafe_shutdown);
out:
ndctl_cmd_unref(si_cmd);
return rc;
@@ -417,6 +425,7 @@ static int dimm_inject_smart(struct ndctl_dimm *dimm)
struct json_object *jhealth;
struct json_object *jdimms;
struct json_object *jdimm;
+ unsigned int supported_types;
int rc;
rc = ndctl_dimm_smart_inject_supported(dimm);
@@ -433,6 +442,14 @@ static int dimm_inject_smart(struct ndctl_dimm *dimm)
error("%s: smart injection not supported by either platform firmware or the kernel.",
ndctl_dimm_get_devname(dimm));
return rc;
+ default:
+ if (rc < 0) {
+ error("%s: Unknown error %d while checking for smart injection support",
+ ndctl_dimm_get_devname(dimm), rc);
+ return rc;
+ }
+ supported_types = rc;
+ break;
}
if (sctx.op_mask & (1 << OP_SET)) {
@@ -441,7 +458,7 @@ static int dimm_inject_smart(struct ndctl_dimm *dimm)
goto out;
}
if (sctx.op_mask & (1 << OP_INJECT)) {
- rc = smart_inject(dimm);
+ rc = smart_inject(dimm, supported_types);
if (rc)
goto out;
}
diff --git a/ndctl/lib/intel.c b/ndctl/lib/intel.c
index a3df26e..1314854 100644
--- a/ndctl/lib/intel.c
+++ b/ndctl/lib/intel.c
@@ -455,7 +455,12 @@ static int intel_dimm_smart_inject_supported(struct ndctl_dimm *dimm)
return -EIO;
}
- return 0;
+ /* Indicate all smart injection types are supported */
+ return ND_SMART_INJECT_SPARES_REMAINING |
+ ND_SMART_INJECT_MEDIA_TEMPERATURE |
+ ND_SMART_INJECT_CTRL_TEMPERATURE |
+ ND_SMART_INJECT_HEALTH_STATE |
+ ND_SMART_INJECT_UNCLEAN_SHUTDOWN;
}
static const char *intel_cmd_desc(int fn)
diff --git a/ndctl/libndctl.h b/ndctl/libndctl.h
index b59026c..4d5cdbf 100644
--- a/ndctl/libndctl.h
+++ b/ndctl/libndctl.h
@@ -69,6 +69,13 @@ extern "C" {
#define ND_EVENT_HEALTH_STATE (1 << 3)
#define ND_EVENT_UNCLEAN_SHUTDOWN (1 << 4)
+/* Flags indicating support for various smart injection types */
+#define ND_SMART_INJECT_SPARES_REMAINING (1 << 0)
+#define ND_SMART_INJECT_MEDIA_TEMPERATURE (1 << 1)
+#define ND_SMART_INJECT_CTRL_TEMPERATURE (1 << 2)
+#define ND_SMART_INJECT_HEALTH_STATE (1 << 3)
+#define ND_SMART_INJECT_UNCLEAN_SHUTDOWN (1 << 4)
+
size_t ndctl_min_namespace_size(void);
size_t ndctl_sizeof_namespace_index(void);
size_t ndctl_sizeof_namespace_label(void);
@@ -311,6 +318,7 @@ int ndctl_cmd_smart_inject_spares(struct ndctl_cmd *cmd, bool enable,
unsigned int spares);
int ndctl_cmd_smart_inject_fatal(struct ndctl_cmd *cmd, bool enable);
int ndctl_cmd_smart_inject_unsafe_shutdown(struct ndctl_cmd *cmd, bool enable);
+/* Returns a bitmap of ND_SMART_INJECT_* supported */
int ndctl_dimm_smart_inject_supported(struct ndctl_dimm *dimm);
struct ndctl_cmd *ndctl_dimm_cmd_new_vendor_specific(struct ndctl_dimm *dimm,

View File

@ -1,41 +0,0 @@
papr: Add support to parse save_fail flag for dimm
BZ:
Brew:
commit f081f302505209430df46908775a3cffb875a5c7
Author: Santosh Sivaraj <santosh@fossix.org>
Date: Thu May 13 11:42:17 2021 +0530
papr: Add support to parse save_fail flag for dimm
This will help in getting the dimm fail tests to run on papr family too.
Also add nvdimm_test compatibility string for recognizing the test module.
Link: https://lore.kernel.org/r/20210513061218.760322-3-santosh@fossix.org
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index e45353f..a8b99ea 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -805,6 +805,8 @@ static void parse_papr_flags(struct ndctl_dimm *dimm, char *flags)
dimm->flags.f_restore = 1;
else if (strcmp(start, "smart_notify") == 0)
dimm->flags.f_smart = 1;
+ else if (strcmp(start, "save_fail") == 0)
+ dimm->flags.f_save = 1;
start = end + 1;
}
if (end != start)
@@ -1035,7 +1037,8 @@ NDCTL_EXPORT int ndctl_bus_is_papr_scm(struct ndctl_bus *bus)
if (sysfs_read_attr(bus->ctx, bus->bus_buf, buf) < 0)
return 0;
- return (strcmp(buf, "ibm,pmemory") == 0);
+ return (strcmp(buf, "ibm,pmemory") == 0 ||
+ strcmp(buf, "nvdimm_test") == 0);
}
/**

View File

@ -1,50 +0,0 @@
zero_info_block: skip seed devices
BZ:
Brew:
commit fb13dfb8d84c4f0a749665c8f07179450b199f3e
Author: Jeff Moyer <jmoyer@redhat.com>
Date: Tue Feb 9 16:51:53 2021 -0500
zero_info_block: skip seed devices
Currently, ndctl destroy-namespace -f all will output errors of the
form:
Error: destroy namespace: namespace0.0 failed to enable for zeroing, continuing
for any zero-sized namespace. That particular namespace looks like this:
{
"dev":"namespace0.0",
"mode":"raw",
"size":0,
"uuid":"00000000-0000-0000-0000-000000000000",
"sector_size":512,
"state":"disabled"
}
This patch skips over namespaces with size=0 when zeroing out info
blocks.
Fixes: 46654c2d60b70 ("ndctl/namespace: Always zero info-blocks")
Reported-by: Zhang Yi <yizhan@redhat.com>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Link: https://lore.kernel.org/r/x49r1lohpty.fsf@segfault.boston.devel.redhat.com
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index 1feb74d..1e8a2cd 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -1052,6 +1052,9 @@ static int zero_info_block(struct ndctl_namespace *ndns)
void *buf = NULL, *read_buf = NULL;
char path[50];
+ if (ndctl_namespace_get_size(ndns) == 0)
+ return 1;
+
ndctl_namespace_set_raw_mode(ndns, 1);
rc = ndctl_namespace_enable(ndns);
if (rc < 0) {

View File

@ -1,102 +0,0 @@
ndctl/test: Initialize the label area by default
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2143636
commit fe37c85f1ffb0b2d04ef60e8ece6a9a44a145cc5
Author: Dan Williams <dan.j.williams@intel.com>
Date: Wed Jan 5 13:32:00 2022 -0800
ndctl/test: Initialize the label area by default
The removal of BLK-mode support causes nfit_test regions to not be
'aliased' by default, which means that the only way to enable labels is to
initialize the namespace label index block. In support of that the common
'reset()' helper is updated to initialize v1.1 labels instead of zero them.
Additionally, it highlighted that some btt tests have silent assumptions of
v1.1 vs v1.2 label support. Add a 'resetV()' alternative to the common
'reset()' function that initializes the label area to v1.2.
Link: https://lore.kernel.org/r/164141832017.3990253.10383328274835531066.stgit@dwillia2-desk3.amr.corp.intel.com
Tested-by: Alison Schofield <alison.schofield@intel.com>
Tested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
diff --git a/test/btt-errors.sh b/test/btt-errors.sh
index 5a20d26..6e69178 100755
--- a/test/btt-errors.sh
+++ b/test/btt-errors.sh
@@ -45,7 +45,7 @@ trap 'err $LINENO cleanup' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
-reset
+resetV
rc=1
@@ -124,7 +124,7 @@ dd if=$MNT/$FILE of=/dev/null iflag=direct bs=4096 count=1
# reset everything to get a clean log
if grep -q "$MNT" /proc/mounts; then umount $MNT; fi
-reset
+resetV
dev="x"
json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m sector)
eval "$(echo "$json" | json2var)"
diff --git a/test/btt-pad-compat.sh b/test/btt-pad-compat.sh
index be538b7..005316a 100755
--- a/test/btt-pad-compat.sh
+++ b/test/btt-pad-compat.sh
@@ -148,7 +148,7 @@ do_tests()
verify_idx 0 1
# do the same with an old format namespace
- reset
+ resetV
create_oldfmt_ns
verify_idx 0 2
diff --git a/test/common b/test/common
index 3c54d63..b6d4712 100644
--- a/test/common
+++ b/test/common
@@ -49,14 +49,21 @@ err()
reset()
{
$NDCTL disable-region -b $NFIT_TEST_BUS0 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
+ $NDCTL init-labels -f -b $NFIT_TEST_BUS0 all
+ $NDCTL enable-region -b $NFIT_TEST_BUS0 all
+}
+
+resetV()
+{
+ $NDCTL disable-region -b $NFIT_TEST_BUS0 all
+ $NDCTL init-labels -f -V 1.2 -b $NFIT_TEST_BUS0 all
$NDCTL enable-region -b $NFIT_TEST_BUS0 all
}
reset1()
{
$NDCTL disable-region -b $NFIT_TEST_BUS1 all
- $NDCTL zero-labels -b $NFIT_TEST_BUS1 all
+ $NDCTL init-labels -f -b $NFIT_TEST_BUS1 all
$NDCTL enable-region -b $NFIT_TEST_BUS1 all
}
diff --git a/test/label-compat.sh b/test/label-compat.sh
index 8ab2858..7ae4d5e 100755
--- a/test/label-compat.sh
+++ b/test/label-compat.sh
@@ -17,7 +17,7 @@ trap 'err $LINENO' ERR
# setup (reset nfit_test dimms)
modprobe nfit_test
$NDCTL disable-region -b $NFIT_TEST_BUS0 all
-$NDCTL zero-labels -b $NFIT_TEST_BUS0 all
+$NDCTL init-labels -f -b $NFIT_TEST_BUS0 all
# grab the largest pmem region on -b $NFIT_TEST_BUS0
query=". | sort_by(.available_size) | reverse | .[0].dev"

View File

@ -1,124 +0,0 @@
Use page size as alignment value
BZ:
Brew:
commit fe831b526b88f6ca7a27fdb149b8a7d2ecddbc55
Author: Santosh Sivaraj <santosh@fossix.org>
Date: Thu May 13 11:42:18 2021 +0530
Use page size as alignment value
The alignment sizes passed to ndctl in the tests are all hardcoded to 4k,
the default page size on x86. Change those to the default page size on that
architecture (sysconf/getconf). No functional changes otherwise.
Link: https://lore.kernel.org/r/20210513061218.760322-4-santosh@fossix.org
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff -up ndctl-71.1/test/dpa-alloc.c.orig ndctl-71.1/test/dpa-alloc.c
--- ndctl-71.1/test/dpa-alloc.c.orig 2020-12-22 16:44:57.000000000 -0500
+++ ndctl-71.1/test/dpa-alloc.c 2022-06-06 17:13:12.045108349 -0400
@@ -38,12 +38,13 @@ static int do_test(struct ndctl_ctx *ctx
struct ndctl_region *region, *blk_region = NULL;
struct ndctl_namespace *ndns;
struct ndctl_dimm *dimm;
- unsigned long size;
+ unsigned long size, page_size;
struct ndctl_bus *bus;
char uuid_str[40];
int round;
int rc;
+ page_size = sysconf(_SC_PAGESIZE);
/* disable nfit_test.1, not used in this test */
bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER1);
if (!bus)
@@ -124,11 +125,11 @@ static int do_test(struct ndctl_ctx *ctx
return rc;
}
ndctl_namespace_disable_invalidate(ndns);
- rc = ndctl_namespace_set_size(ndns, SZ_4K);
+ rc = ndctl_namespace_set_size(ndns, page_size);
if (rc) {
- fprintf(stderr, "failed to init %s to size: %d\n",
+ fprintf(stderr, "failed to init %s to size: %lu\n",
ndctl_namespace_get_devname(ndns),
- SZ_4K);
+ page_size);
return rc;
}
namespaces[i].ndns = ndns;
@@ -150,7 +151,7 @@ static int do_test(struct ndctl_ctx *ctx
ndns = namespaces[i % ARRAY_SIZE(namespaces)].ndns;
if (i % ARRAY_SIZE(namespaces) == 0)
round++;
- size = SZ_4K * round;
+ size = page_size * round;
rc = ndctl_namespace_set_size(ndns, size);
if (rc) {
fprintf(stderr, "%s: set_size: %lx failed: %d\n",
@@ -166,7 +167,7 @@ static int do_test(struct ndctl_ctx *ctx
i--;
round++;
ndns = namespaces[i % ARRAY_SIZE(namespaces)].ndns;
- size = SZ_4K * round;
+ size = page_size * round;
rc = ndctl_namespace_set_size(ndns, size);
if (rc) {
fprintf(stderr, "%s failed to update while labels full\n",
@@ -175,7 +176,7 @@ static int do_test(struct ndctl_ctx *ctx
}
round--;
- size = SZ_4K * round;
+ size = page_size * round;
rc = ndctl_namespace_set_size(ndns, size);
if (rc) {
fprintf(stderr, "%s failed to reduce size while labels full\n",
diff -up ndctl-71.1/test/multi-dax.sh.orig ndctl-71.1/test/multi-dax.sh
--- ndctl-71.1/test/multi-dax.sh.orig 2020-12-22 16:44:57.000000000 -0500
+++ ndctl-71.1/test/multi-dax.sh 2022-06-06 17:13:12.046108353 -0400
@@ -12,6 +12,8 @@ check_min_kver "4.13" || do_skip "may la
trap 'err $LINENO' ERR
+ALIGN_SIZE=`getconf PAGESIZE`
+
# setup (reset nfit_test dimms)
modprobe nfit_test
$NDCTL disable-region -b $NFIT_TEST_BUS0 all
@@ -22,9 +24,9 @@ rc=1
query=". | sort_by(.available_size) | reverse | .[0].dev"
region=$($NDCTL list -b $NFIT_TEST_BUS0 -t pmem -Ri | jq -r "$query")
-json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a 4096 -s 16M)
+json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a $ALIGN_SIZE -s 16M)
chardev1=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices[0].chardev")
-json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a 4096 -s 16M)
+json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a $ALIGN_SIZE -s 16M)
chardev2=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices[0].chardev")
_cleanup
diff -up ndctl-71.1/test/sector-mode.sh.orig ndctl-71.1/test/sector-mode.sh
--- ndctl-71.1/test/sector-mode.sh.orig 2020-12-22 16:44:57.000000000 -0500
+++ ndctl-71.1/test/sector-mode.sh 2022-06-06 17:13:12.046108353 -0400
@@ -9,6 +9,8 @@ rc=77
set -e
trap 'err $LINENO' ERR
+ALIGN_SIZE=`getconf PAGESIZE`
+
# setup (reset nfit_test dimms)
modprobe nfit_test
$NDCTL disable-region -b $NFIT_TEST_BUS0 all
@@ -25,7 +27,7 @@ NAMESPACE=$($NDCTL list -b $NFIT_TEST_BU
REGION=$($NDCTL list -R --namespace=$NAMESPACE | jq -r "(.[]) | .dev")
echo 0 > /sys/bus/nd/devices/$REGION/read_only
$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K
-$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m dax -f -a 4K
+$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m dax -f -a $ALIGN_SIZE
$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K
_cleanup

View File

@ -1,37 +1,12 @@
Name: ndctl
Version: 71.1
Release: 7%{?dist}
Version: 67
Release: 2%{?dist}
Summary: Manage "libnvdimm" subsystem devices (Non-volatile Memory)
License: GPLv2
Group: System Environment/Base
Url: https://github.com/pmem/ndctl
Source0: https://github.com/pmem/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Patch0: modprobe-link-user-keyring-before-loadkeys.patch
Patch1: fb13dfb-zero_info_block-skip-seed-devices.patch
Patch2: daef3a3-libndctl-Unify-adding-dimms-for-papr-and-nfit-families.patch
Patch3: f081f30-papr-Add-support-to-parse-save_fail-flag-for-dimm.patch
Patch4: fe831b5-Use-page-size-as-alignment-value.patch
Patch5: e086106-libndctl-papr-Fix-probe-for-papr-scm-compatible-nvdimms.patch
Patch6: c521093-ndctl-scrub-Stop-translating-return-values.patch
Patch7: 4e646fa-ndctl-scrub-Reread-scrub-engine-status-at-start.patch
Patch8: 9bd2994-ndctl-namespace-Skip-seed-namespaces-when-processing-all-namespaces.patch
Patch9: 07011a3-ndctl-namespace-Suppress-ENXIO-when-processing-all-namespaces.patch
Patch10: 80e0d88-namespace-action-Drop-zero-namespace-checks.patch
Patch11: aa99000-libndctl-papr-Add-support-for-reporting-shutdown-count.patch
Patch12: edcd9b7-libndctl-intel-Indicate-supported-smart-inject-types.patch
Patch13: 9ef460e-libndctl-papr-Add-limited-support-for-inject-smart.patch
Patch14: 6e85cac-ndtest-ack-shutdown-count-Skip-the-test-on-ndtest.patch
Patch15: 7ce2fdd-ndctl-test-add-checking-the-presence-of-jq-command-ahead.patch
Patch16: 43e48c0-test-libndctl-Use-ndctl_region_set_ro-to-change-disk-read-only-state.patch
Patch17: 1649ad9-test-Don-t-skip-tests-if-nfit-modules-are-missing.patch
Patch18: e423b46-ndctl-test-Prepare-for-BLK-aperture-support-removal.patch
Patch19: 6538529-ndctl-test-Move-reset-to-function-in-common.patch
Patch20: fe37c85-ndctl-test-Initialize-the-label-area-by-default.patch
Patch21: 756a659-ndctl-test-Skip-BLK-flags-checks.patch
Patch22: b787320-ndctl-test-Move-sector-mode-to-a-different-region.patch
Patch23: 2e05cd6-ndctl-Deprecate-BLK-aperture-support.patch
Patch24: 4921c0c-ndctl-test-make-inject-smart.sh-more-tolerant-of-decimal-fields.patch
Requires: ndctl-libs%{?_isa} = %{version}-%{release}
Requires: daxctl-libs%{?_isa} = %{version}-%{release}
@ -113,7 +88,8 @@ control API for these devices.
%prep
%autosetup -p1 ndctl-%{version}
%setup -q ndctl-%{version}
%patch0 -p1
%build
echo %{version} > version
@ -139,7 +115,7 @@ make check
%define bashcompdir %(pkg-config --variable=completionsdir bash-completion)
%files
%license LICENSES/preferred/GPL-2.0 LICENSES/other/MIT LICENSES/other/CC0-1.0
%license util/COPYING licenses/BSD-MIT licenses/CC0
%{_bindir}/ndctl
%{_mandir}/man1/ndctl*
%{bashcompdir}/
@ -150,65 +126,35 @@ make check
%config(noreplace) %{_sysconfdir}/ndctl/monitor.conf
%files -n daxctl
%license LICENSES/preferred/GPL-2.0 LICENSES/other/MIT LICENSES/other/CC0-1.0
%license util/COPYING licenses/BSD-MIT licenses/CC0
%{_bindir}/daxctl
%{_mandir}/man1/daxctl*
%{_datadir}/daxctl/daxctl.conf
%files -n ndctl-libs
%doc README.md
%license LICENSES/preferred/LGPL-2.1 LICENSES/other/MIT LICENSES/other/CC0-1.0
%license COPYING licenses/BSD-MIT licenses/CC0
%{_libdir}/libndctl.so.*
%files -n daxctl-libs
%doc README.md
%license LICENSES/preferred/LGPL-2.1 LICENSES/other/MIT LICENSES/other/CC0-1.0
%license COPYING licenses/BSD-MIT licenses/CC0
%{_libdir}/libdaxctl.so.*
%files -n ndctl-devel
%license LICENSES/preferred/LGPL-2.1
%license COPYING
%{_includedir}/ndctl/
%{_libdir}/libndctl.so
%{_libdir}/pkgconfig/libndctl.pc
%files -n daxctl-devel
%license LICENSES/preferred/LGPL-2.1
%license COPYING
%{_includedir}/daxctl/
%{_libdir}/libdaxctl.so
%{_libdir}/pkgconfig/libdaxctl.pc
%changelog
* Mon Jun 05 2023 Jeff Moyer <jmoyer@redhat.com> - 71.1-7.el8
- Another bump to fix gating tests
- Resolves: rhbz#2141031
* Mon Jun 05 2023 Jeff Moyer <jmoyer@redhat.com> - 71.1-6.el8
- Bump release for a rebuild
- Resolves: rhbz#2141031
* Fri Jun 02 2023 Jeff Moyer <jmoyer@redhat.com> - 71.1-5.el8
- Sync test harness with kernel updates. (Jeff Moyer)
- Resolves: rhbz#2141031
* Tue Jun 14 2022 Jeff Moyer <jmoyer@redhat.com> - 71.1-4.el8
- Pull in fixes from upstream v72 and v73 (Jeff Moyer)
- Fix enable-namespace all reporting errors incorrectly
- Add support for inject-smart on papr scm
- Related: bz#2090190 bz#1986185 bz#2040074
* Mon Nov 29 2021 Bryan Gurney <bgurney@redhat.com> - 71.1-3.el8
- Rebuild with latest json-c version
- Related: bz#2021816
* Thu Feb 11 2021 Jeff Moyer <jmoyer@redhat.com> - 71.1-2.el8
- Get rid of confusing message when deleting all namespaces
- Related: bz#1782182
* Fri Feb 5 2021 Jeff Moyer <jmoyer@redhat.com> - 71.1-1.el8
- Update to v71.1 to pull in ppc support.
- Related: bz#1782182
* Fri Nov 1 2019 Jeff Moyer <jmoyer@redhat.com> - 67-2.el8
- Fix up botched change to nvdimm-security.conf (Jeff Moyer)
- Related: bz#1724531