ndctl/test: fully reset nfit_test in pmem-ns unit test
Alison Schofield
maintainerPATCH v2 1/1 ndctl/test: fully reset nfit_test in pmem-ns unit test
The pmem_ns unit test is designed to fallback to using the nfit_test bus resource when an ACPI resource is not available. That fallback is not as solid as it could be, causing intermittent failures of the unit test.
That nfit_test fallback fails with errors such as:
path: /sys/devices/platform/nfit_test.0/ndbus2/region7/namespace7.0/uuid
libndctl: write_attr: failed to open /sys/devices/platform/nfit_test.0/ndbus2/region7/namespace7.0/uuid: No such file or directory /root/ndctl/build/test/pmem-ns: failed to create PMEM namespace
This occurs because calling ndctl_test_init() with a NULL context only unloads and reloads the nfit_test module, but does not invalidate and reinitialize the libndctl context or its sysfs view from previous runs. The resulting stale state prevents the test from creating a new namespace cleanly.
Replace the NULL context parameter when calling ndctl_test_init() with the available ndctl_ctx to ensure pmem_ns can find usable PMEM regions.
Add more debug messaging to describe why the nfit_test fallback path is taken, ie NULL bus or NULL region.
---
Changes in v2:
- Clarify which ACPI resource was not found, bus or region (MarcH)
- Update commit message and log
- Remove Closes tag (MarcH)
test/pmem_namespaces.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
test/pmem_namespaces.c +9 -5
@@ -178,20 +178,24 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test,ndctl_set_log_priority (ctx, log_level); +/* Try to use ACPI resource first, then nfit_test */ bus =ndctl_bus_get_by_provider (ctx,"ACPI.NFIT" ); -if (bus) { -/* skip this bus if no label-enabled PMEM regions */ +if (bus) ndctl_region_foreach(bus, region)if (ndctl_region_get_nstype (region) ==ND_DEVICE_NAMESPACE_PMEM )break ; -if (!region) - bus =NULL ; + +if (!bus) +fprintf (stderr,"ACPI.NFIT: bus not found\n" ); +else if (!region) { +fprintf (stderr,"ACPI.NFIT: no PMEM region found\n" ); + bus =NULL ; }if (!bus) {fprintf (stderr,"ACPI.NFIT unavailable falling back to nfit_test\n" ); - rc =ndctl_test_init (&kmod_ctx, &mod,NULL , log_level, test); + rc =ndctl_test_init (&kmod_ctx, &mod, ctx, log_level, test);ndctl_invalidate (ctx); bus =ndctl_bus_get_by_provider (ctx,"nfit_test.0" );if (rc <0 || !bus) {
Signature · 1 line
2.37.3
Quoted 20 lines · Alison Schofield
The
pmem_nsunit test is designed to fallback to using thenfit_testbus resource when an ACPI resource is not available. That fallback is not as solid as it could be, causing intermittent failures of the unit test.That
nfit_testfallback fails with errors such as:
path:/sys/devices/platform/nfit_test.0/ndbus2/region7/namespace7.0/uuid
libndctl:write_attr: failed to open/sys/devices/platform/nfit_test.0/ndbus2/region7/namespace7.0/uuid: No such file or directory/root/ndctl/build/test/pmem-ns: failed to create PMEM namespaceThis occurs because calling
ndctl_test_init()with a NULL context only unloads and reloads thenfit_testmodule, but does not invalidate and reinitialize the libndctl context or its sysfs view from previous runs. The resulting stale state prevents the test from creating a new namespace cleanly.Replace the NULL context parameter when calling
ndctl_test_init()with the availablendctl_ctxto ensurepmem_nscan find usable PMEM regions.
Quoted 6 lines
Add more debug messaging to describe why the
nfit_testfallback path is taken, ie NULL bus or NULL region.Reported-by Marc Herbert <[email protected]>Reviewed-by Dave Jiang <[email protected]>
[snip]
Alison Schofield
maintainerQuoted 28 lines · Alison Schofield
The
pmem_nsunit test is designed to fallback to using thenfit_testbus resource when an ACPI resource is not available. That fallback is not as solid as it could be, causing intermittent failures of the unit test.That
nfit_testfallback fails with errors such as:
path:/sys/devices/platform/nfit_test.0/ndbus2/region7/namespace7.0/uuid
libndctl:write_attr: failed to open/sys/devices/platform/nfit_test.0/ndbus2/region7/namespace7.0/uuid: No such file or directory/root/ndctl/build/test/pmem-ns: failed to create PMEM namespaceThis occurs because calling
ndctl_test_init()with a NULL context only unloads and reloads thenfit_testmodule, but does not invalidate and reinitialize the libndctl context or its sysfs view from previous runs. The resulting stale state prevents the test from creating a new namespace cleanly.Replace the NULL context parameter when calling
ndctl_test_init()with the availablendctl_ctxto ensurepmem_nscan find usable PMEM regions.Add more debug messaging to describe why the
nfit_testfallback path is taken, ie NULL bus or NULL region.Reported-by Marc Herbert <[email protected]>Reviewed-by Dave Jiang <[email protected]>Tested-by Marc Herbert <[email protected]>Signed-off-by Alison Schofield <[email protected]>
Quoted 6 lines
---
Changes in v2:
- Clarify which ACPI resource was not found, bus or region (MarcH)
- Update commit message and log
- Remove Closes tag (MarcH)
Thanks for the reviews and testing.
Applied to : https://github.com/pmem/ndctl/commits/pending/
Added note to github issue https://github.com/pmem/ndctl/issues/290
"This fixes up the failure of the pmem-ns unit test for nfit_test users. It also adds debug messaging to help debug of ACPI.NFIT users. Patches welcome."
Quoted 42 lines
test/pmem_namespaces.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)test/pmem_namespaces.c +9
-5@@ -178,20 +178,24 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test,ndctl_set_log_priority (ctx, log_level); +/* Try to use ACPI resource first, then nfit_test */ bus =ndctl_bus_get_by_provider (ctx,"ACPI.NFIT" ); -if (bus) { -/* skip this bus if no label-enabled PMEM regions */ +if (bus) ndctl_region_foreach(bus, region)if (ndctl_region_get_nstype (region) ==ND_DEVICE_NAMESPACE_PMEM )break ; -if (!region) - bus =NULL ; + +if (!bus) +fprintf (stderr,"ACPI.NFIT: bus not found\n" ); +else if (!region) { +fprintf (stderr,"ACPI.NFIT: no PMEM region found\n" ); + bus =NULL ; }if (!bus) {fprintf (stderr,"ACPI.NFIT unavailable falling back to nfit_test\n" ); - rc =ndctl_test_init (&kmod_ctx, &mod,NULL , log_level, test); + rc =ndctl_test_init (&kmod_ctx, &mod, ctx, log_level, test);ndctl_invalidate (ctx); bus =ndctl_bus_get_by_provider (ctx,"nfit_test.0" );if (rc <0 || !bus) {Signature · 1 line
2.37.3