add an inject-error command to ndctl
Subsystems (2)
Vishal Verma
maintainerv3 cover add an inject-error command to ndctl
v3:
patch 2:
- Don't export ndctl_namespace_get_injection_bounds (Dan).
v2:
patch 1:
- use poll() instead of a sleep loop when waiting for a scrub. (Dan)
patch 2 (new):
- move the acpi nfit specific routines into generic wrappers exported by the library. (Dan)
patch 3:
- rename 'clear' to 'uninject' use 'block' instead of 'sector' (Dan)
- cleanup the manpage to remove ACPI/NFIT references.
patch 4:
- Add the actual inject-error unit test instead of just test boilerplate
These patches add a new command to ndctl for error injection. They are implemented such that the interface provided to a user is consistent with the kernel - i.e. all media errors are expected/displayed in terms of 512 byte sectors. The underlying ACPI DSMs need and provide byte relative offsets/lengths, but these are converted to 512B sectors for consistency.
These also update unit tests to use the new error injection commands, and add two new unit tests - first, to test the error injection commands themselves, and second, to test BTT error clearing.
Vishal Verma (6):
libndctl: add APIs to get scrub count and to wait for a scrub
libndctl: add error injection related interfaces
ndctl: add an inject-error command
ndctl/test: add a new unit test for inject-error ndctl/test: update existing unit tests to use inject-error ndctl/test: add a new unit test for BTT error clearing
Documentation/ndctl/Makefile.am | 1 + Documentation/ndctl/ndctl-inject-error.txt | 108 ++++++++ Documentation/ndctl/ndctl.txt | 1 + builtin.h | 1 + contrib/ndctl | 5 +- ndctl/Makefile.am | 3 +- ndctl/inject-error.c | 373 +++++++++++++++++++++++++++ ndctl/lib/Makefile.am | 1 + ndctl/lib/inject.c | 391 +++++++++++++++++++++++++++++ ndctl/lib/libndctl.c | 147 +++++++---- ndctl/lib/libndctl.sym | 10 + ndctl/lib/nfit.c | 89 +++++++ ndctl/lib/private.h | 54 ++++ ndctl/libndctl-nfit.h | 10 + ndctl/libndctl.h.in | 22 ++ ndctl/ndctl.c | 1 + test/Makefile.am | 4 +- test/btt-errors.sh | 149 +++++++++++ test/clear.sh | 5 +- test/dax-errors.sh | 5 +- test/daxdev-errors.sh | 17 +- test/inject-error.sh | 120 +++++++++ util/json.c | 26 ++ util/json.h | 3 + util/list.h | 50 ++++ util/size.h | 1 + 26 files changed, 1547 insertions(+), 50 deletions(-) create mode 100644 Documentation/ndctl/ndctl-inject-error.txt create mode 100644 ndctl/inject-error.c create mode 100644 ndctl/lib/inject.c create mode 100755 test/btt-errors.sh create mode 100755 test/inject-error.sh create mode 100644 util/list.h
Signature · 6 lines
2.9.5 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Vishal Verma
maintainerPATCH v3 1/6 libndctl: add APIs to get scrub count and to wait for a scrub
The kernel uses sysfs to notify userspace of the number of completed Address Range Scrubs, as well as any ongoing scrubs. Add libndctl helpers to get the scrub count, and to wait for an in-progress scrub to complete.
--- ndctl/lib/libndctl.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ ndctl/lib/libndctl.sym | 2 + ndctl/lib/private.h | 1 + ndctl/libndctl.h.in | 2 + 4 files changed, 105 insertions(+)
ndctl/lib/libndctl.c +100 -0
@@ -10,7 +10,9 @@* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for * more details. */ +#include <poll.h> #include <stdio.h> +#include <signal.h> #include <stdlib.h> #include <stddef.h> #include <stdarg.h>
@@ -555,6 +557,7 @@ static void free_bus(struct ndctl_bus *bus, struct list_head *head)free (bus->bus_path);free (bus->bus_buf);free (bus->wait_probe_path); +free (bus->scrub_path);free (bus); }
@@ -785,6 +788,11 @@ static void *add_bus(void *parent, int id, const char *ctl_base)if (!bus->wait_probe_path) goto err_read; +sprintf (path,"%s/device/nfit/scrub" , ctl_base); + bus->scrub_path =strdup (path); +if (!bus->scrub_path) + goto err_read; + bus->bus_path =parent_dev_path ("char" , bus->major, bus->minor);if (!bus->bus_path) goto err_dev_path;
@@ -810,6 +818,7 @@ static void *add_bus(void *parent, int id, const char *ctl_base) err_dev_path: err_read:free (bus->wait_probe_path); +free (bus->scrub_path);free (bus->provider);free (bus->bus_buf);free (bus);
@@ -1082,6 +1091,97 @@ NDCTL_EXPORT int ndctl_bus_wait_probe(struct ndctl_bus *bus)return rc <0 ? -ENXIO :0 ; } +NDCTL_EXPORT unsigned int ndctl_bus_get_scrub_count(struct ndctl_bus *bus) +{ +struct ndctl_ctx *ctx =ndctl_bus_get_ctx (bus); +char buf[SYSFS_ATTR_SIZE ]; +unsigned int scrub_count; +char in_progress ='\0' ; +int rc; + + rc =sysfs_read_attr (ctx, bus->scrub_path, buf); +if (rc <0 ) +return UINT_MAX ; + + rc =sscanf (buf,"%u%c" , &scrub_count, &in_progress); +if (rc <0 ) +return UINT_MAX ; +if (rc ==0 ) { +/* unable to read scrub count */ +return UINT_MAX ; + } +if (rc >=1 ) +return scrub_count; + +return UINT_MAX ; +} + +/** +* ndctl_bus_wait_for_scrub - wait for a scrub to complete +* @bus: bus for which to check whether a scrub is in progress +* +* Upon return this bus has completed any in-progress scrubs. This is +* different from ndctl_cmd_ars_in_progress in that the latter checks +* the output of an ars_status command to see if the in-progress flag +* is set, i.e. provides the firmware's view of whether a scrub is in +* progress. ndctl_bus_wait_for_scrub instead checks the kernel's view +* of whether a scrub is in progress by looking at the 'scrub' file in +* sysfs. +*/ +NDCTL_EXPORT int ndctl_bus_wait_for_scrub_completion(struct ndctl_bus *bus) +{ +struct ndctl_ctx *ctx =ndctl_bus_get_ctx (bus); +unsigned int tmo =120 , scrub_count; +char buf[SYSFS_ATTR_SIZE ]; +char in_progress ='\0' ; +struct pollfd fds; +int fd =0 , rc; + + fd =open (bus->scrub_path,O_RDONLY |O_CLOEXEC ); + fds.fd = fd; + fds.events =POLLPRI |POLLIN ; +do { + rc =sysfs_read_attr (ctx, bus->scrub_path, buf); +if (rc <0 ) +break ; + + rc =sscanf (buf,"%u%c" , &scrub_count, &in_progress); +if (rc <0 ) +break ; +else if (rc <=1 ) { +/* scrub complete, break successfully */ + rc =0 ; +break ; + }else if (rc ==2 && in_progress =='+' ) { +/* scrub in progress, wait */ + rc =poll (&fds,1 , tmo); +if (rc <0 ) { +dbg (ctx,"poll error: %d\n" , errno); +break ; + }else if (rc ==0 ) { +dbg (ctx,"poll timeout after: %d seconds" , tmo); + rc = -ENXIO ; +break ; + } +if (fds.revents & (POLLERR |POLLHUP |POLLNVAL )) { +dbg (ctx,"poll error, revents: %d\n" , + fds.revents); + rc = -ENXIO ; +break ; + } + }else { +/* unknown condition */ + rc = -ENXIO ; +break ; + } + }while (in_progress); + +dbg (ctx,"bus%d: scrub complete\n" ,ndctl_bus_get_id (bus)); +if (fd) +close (fd); +return rc <0 ? -ENXIO :0 ; +} +static int ndctl_bind (struct ndctl_ctx *ctx,struct kmod_module *module,const char *devname);static int ndctl_unbind (struct ndctl_ctx *ctx,const char *devpath);
ndctl/lib/libndctl.sym +2 -0
@@ -286,6 +286,8 @@ global: ndctl_bus_get_region_by_physical_address; ndctl_bus_get_dimm_by_physical_address; ndctl_bus_is_nfit_cmd_supported; + ndctl_bus_wait_for_scrub_completion; + ndctl_bus_get_scrub_count; ndctl_dimm_read_labels; ndctl_dimm_validate_labels; ndctl_dimm_init_labels;
ndctl/lib/private.h +1 -0
@@ -152,6 +152,7 @@ struct ndctl_bus {char *bus_buf;size_t buf_len;char *wait_probe_path; +char *scrub_path;unsigned long dsm_mask;unsigned long nfit_dsm_mask; };
ndctl/libndctl.h.in +2 -0
@@ -113,6 +113,8 @@ unsigned int ndctl_bus_get_revision(struct ndctl_bus *bus); unsigned int ndctl_bus_get_id(struct ndctl_bus *bus); const char *ndctl_bus_get_provider(struct ndctl_bus *bus); int ndctl_bus_wait_probe(struct ndctl_bus *bus); +int ndctl_bus_wait_for_scrub_completion(struct ndctl_bus *bus); +unsigned int ndctl_bus_get_scrub_count(struct ndctl_bus *bus); struct ndctl_dimm; struct ndctl_dimm *ndctl_dimm_get_first(struct ndctl_bus *bus);
Signature · 6 lines
2.9.5 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Vishal Verma
maintainerPATCH v3 2/6 libndctl: add error injection related interfaces
In reply to Vishal VermaAdd interfaces to enable error injection commands. Add nfit specific error injection helpers in ndctl/lib/nfit.c, and generic wrappers for them in libndctl.
--- ndctl/lib/Makefile.am | 1 + ndctl/lib/inject.c | 391 +++++++++++++++++++++++++++++++++++++++++++++++++ ndctl/lib/libndctl.c | 47 +----- ndctl/lib/libndctl.sym | 8 + ndctl/lib/nfit.c | 89 +++++++++++ ndctl/lib/private.h | 53 +++++++ ndctl/libndctl-nfit.h | 2 + ndctl/libndctl.h.in | 20 +++ 8 files changed, 569 insertions(+), 42 deletions(-) create mode 100644 ndctl/lib/inject.c
ndctl/lib/Makefile.am +1 -0
@@ -18,6 +18,7 @@ libndctl_la_SOURCES =\ ../../util/sysfs.c \ ../../util/sysfs.h \ dimm.c \ + inject.c \ libndctl.c libndctl_la_LIBADD =\
ndctl/lib/inject.c new file +391 -0
391 lines not on this page · raw message
ndctl/lib/libndctl.c +5 -42
67 lines not on this page · raw message
ndctl/lib/libndctl.sym +8 -0
@@ -288,6 +288,7 @@ global: ndctl_bus_is_nfit_cmd_supported; ndctl_bus_wait_for_scrub_completion; ndctl_bus_get_scrub_count; + ndctl_bus_has_error_injection; ndctl_dimm_read_labels; ndctl_dimm_validate_labels; ndctl_dimm_init_labels;
@@ -295,4 +296,11 @@ global: ndctl_mapping_get_position; ndctl_namespace_set_enforce_mode; ndctl_namespace_get_enforce_mode; + ndctl_namespace_inject_error; + ndctl_namespace_uninject_error; + ndctl_namespace_injection_status; + ndctl_namespace_injection_get_first_bb; + ndctl_namespace_injection_get_next_bb; + ndctl_bb_get_block; + ndctl_bb_get_count; } LIBNDCTL_3;
ndctl/lib/nfit.c +89 -0
92 lines not on this page · raw message
ndctl/lib/private.h +53 -0
70 lines not on this page · raw message
ndctl/libndctl-nfit.h +2 -0
@@ -16,6 +16,8 @@#ifndef __LIBNDCTL_NFIT_H__#define __LIBNDCTL_NFIT_H__ +#include <linux/types.h> +/* * libndctl-nfit.h : definitions for NFIT related commands/functions. */
ndctl/libndctl.h.in +20 -0
@@ -115,6 +115,7 @@ const char *ndctl_bus_get_provider(struct ndctl_bus *bus); int ndctl_bus_wait_probe(struct ndctl_bus *bus); int ndctl_bus_wait_for_scrub_completion(struct ndctl_bus *bus); unsigned int ndctl_bus_get_scrub_count(struct ndctl_bus *bus); +int ndctl_bus_has_error_injection(struct ndctl_bus *bus); struct ndctl_dimm; struct ndctl_dimm *ndctl_dimm_get_first(struct ndctl_bus *bus);
@@ -541,6 +542,25 @@ int ndctl_namespace_set_sector_size(struct ndctl_namespace *ndns, int ndctl_namespace_get_raw_mode(struct ndctl_namespace *ndns); int ndctl_namespace_set_raw_mode(struct ndctl_namespace *ndns, int raw_mode); int ndctl_namespace_get_numa_node(struct ndctl_namespace *ndns); +int ndctl_namespace_inject_error(struct ndctl_namespace *ndns, + unsigned long long block, unsigned long long count, + bool notify); +int ndctl_namespace_uninject_error(struct ndctl_namespace *ndns, + unsigned long long block, unsigned long long count); +int ndctl_namespace_injection_status(struct ndctl_namespace *ndns); + +struct ndctl_bb; +unsigned long long ndctl_bb_get_block(struct ndctl_bb *bb); +unsigned long long ndctl_bb_get_count(struct ndctl_bb *bb); +struct ndctl_bb *ndctl_namespace_injection_get_first_bb( + struct ndctl_namespace *ndns); +struct ndctl_bb *ndctl_namespace_injection_get_next_bb( + struct ndctl_namespace *ndns, struct ndctl_bb *bb); +#define ndctl_namespace_bb_foreach(ndns, bb) \ + for (bb = ndctl_namespace_injection_get_first_bb(ndns); \ + bb != NULL; \ + bb = ndctl_namespace_injection_get_next_bb(ndns, bb)) + struct ndctl_btt; struct ndctl_btt *ndctl_btt_get_first(struct ndctl_region *region); struct ndctl_btt *ndctl_btt_get_next(struct ndctl_btt *btt);
Signature · 6 lines
2.9.5 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Vishal Verma
maintainerPATCH v3 3/6 ndctl: add an inject-error command
In reply to Vishal VermaAdd an inject-error command to ndctl. This uses the error injection DSMs in ACPI6.2 to provide a generic error injection and management interface. Once can inject errors, and view as well as clear injected errors using these commands.
--- Documentation/ndctl/Makefile.am | 1 + Documentation/ndctl/ndctl-inject-error.txt | 108 +++++++++ Documentation/ndctl/ndctl.txt | 1 + builtin.h | 1 + contrib/ndctl | 5 +- ndctl/Makefile.am | 3 +- ndctl/inject-error.c | 373 +++++++++++++++++++++++++++++ ndctl/libndctl-nfit.h | 8 + ndctl/ndctl.c | 1 + util/json.c | 26 ++ util/json.h | 3 + util/list.h | 50 ++++ util/size.h | 1 + 13 files changed, 579 insertions(+), 2 deletions(-) create mode 100644 Documentation/ndctl/ndctl-inject-error.txt create mode 100644 ndctl/inject-error.c create mode 100644 util/list.h
Documentation/ndctl/Makefile.am +1 -0
@@ -30,6 +30,7 @@ man1_MANS = \ ndctl-create-namespace.1 \ ndctl-destroy-namespace.1 \ ndctl-check-namespace.1 \ + ndctl-inject-error.1 \ ndctl-list.1 CLEANFILES = $(man1_MANS)
Documentation/ndctl/ndctl-inject-error.txt new file +108 -0
108 lines not on this page · raw message
Documentation/ndctl/ndctl.txt +1 -0
@@ -50,6 +50,7 @@ linkndctl:ndctl-enable-namespace[1], linkndctl:ndctl-disable-namespace[1], linkndctl:ndctl-zero-labels[1], linkndctl:ndctl-read-labels[1], +linkndctl:ndctl-inject-error[1], linkndctl:ndctl-list[1], https://www.kernel.org/doc/Documentation/nvdimm/nvdimm.txt[LIBNVDIMM Overview],
builtin.h +1 -0
@@ -35,6 +35,7 @@ int cmd_read_labels(int argc, const char **argv, void *ctx);int cmd_write_labels (int argc,const char **argv,void *ctx);int cmd_init_labels (int argc,const char **argv,void *ctx);int cmd_check_labels (int argc,const char **argv,void *ctx); +int cmd_inject_error (int argc,const char **argv,void *ctx);int cmd_list (int argc,const char **argv,void *ctx);#ifdef ENABLE_TEST int cmd_test (int argc,const char **argv,void *ctx);
contrib/ndctl +4 -1
@@ -91,7 +91,7 @@ __ndctlcomp() COMPREPLY=( $( compgen -W "$1" -- "$2" ) ) for cword in "${COMPREPLY[@]}"; do - if [[ "$cword" == @(--bus|--region|--type|--mode|--size|--dimm|--reconfig|--uuid|--name|--sector-size|--map|--namespace|--input|--output|--label-version|--align) ]]; then + if [[ "$cword" == @(--bus|--region|--type|--mode|--size|--dimm|--reconfig|--uuid|--name|--sector-size|--map|--namespace|--input|--output|--label-version|--align|--block|--count) ]]; then COMPREPLY[$i]="${cword}=" else COMPREPLY[$i]="${cword} "
@@ -257,6 +257,9 @@ __ndctl_comp_non_option_args() zero-labels) opts="$(__ndctl_get_dimms -i) all" ;; + inject-error) + opts="$(__ndctl_get_ns -i)" + ;; *) return ;;
ndctl/Makefile.am +2 -1
@@ -11,7 +11,8 @@ ndctl_SOURCES = ndctl.c \ ../util/log.c \ list.c \ test.c \ - ../util/json.c + ../util/json.c \ + inject-error.c if ENABLE_SMART ndctl_SOURCES += util/json-smart.c
ndctl/inject-error.c new file +373 -0
373 lines not on this page · raw message
ndctl/libndctl-nfit.h +8 -0
@@ -33,6 +33,14 @@ enum {/* error number of Translate SPA by firmware */ #define ND_TRANSLATE_SPA_STATUS_INVALID_SPA 2 +/* status definitions for error injection */ +#define ND_ARS_ERR_INJ_STATUS_NOT_SUPP 1 +#define ND_ARS_ERR_INJ_STATUS_INVALID_PARAM 2 + +enum err_inj_options { +ND_ARS_ERR_INJ_OPT_NOTIFY =0 , +}; +/* * The following structures are command packages which are * defined by ACPI 6.2 (or later).
ndctl/ndctl.c +1 -0
@@ -83,6 +83,7 @@ static struct cmd_struct commands[] = { { "write-labels", cmd_write_labels }, { "init-labels", cmd_init_labels }, { "check-labels", cmd_check_labels }, + { "inject-error", cmd_inject_error }, { "list", cmd_list }, { "help", cmd_help }, #ifdef ENABLE_TEST
util/json.c +26 -0
@@ -20,6 +20,7 @@#include <ndctl/libndctl.h> #include <daxctl/libdaxctl.h> #include <ccan/array_size/array_size.h> +#include <ccan/short_types/short_types.h> #ifdef HAVE_NDCTL_H #include <linux/ndctl.h>
@@ -845,3 +846,28 @@ struct json_object *util_mapping_to_json(struct ndctl_mapping *mapping,json_object_put (jmapping);return NULL ; } + +struct json_object *util_badblock_rec_to_json (u64 block,u64 count, +unsigned long flags) +{ +struct json_object *jerr =json_object_new_object (); +struct json_object *jobj; + +if (!jerr) +return NULL ; + + jobj =util_json_object_hex (block, flags); +if (!jobj) + goto err; +json_object_object_add (jerr,"block" , jobj); + + jobj =util_json_object_hex (count, flags); +if (!jobj) + goto err; +json_object_object_add (jerr,"count" , jobj); + +return jerr; + err: +json_object_put (jerr); +return NULL ; +}
util/json.h +3 -0
@@ -15,6 +15,7 @@#include <stdio.h> #include <stdbool.h> #include <ndctl/libndctl.h> +#include <ccan/short_types/short_types.h> enum util_json_flags {UTIL_JSON_IDLE = (1 <<0 ),
@@ -33,6 +34,8 @@ struct json_object *util_mapping_to_json(struct ndctl_mapping *mapping, unsigned long flags);struct json_object *util_namespace_to_json (struct ndctl_namespace *ndns,unsigned long flags); +struct json_object *util_badblock_rec_to_json (u64 block,u64 count, +unsigned long flags);struct daxctl_region ;struct daxctl_dev ; struct json_object *util_region_badblocks_to_json(struct ndctl_region *region,
util/list.h new file +50 -0
50 lines not on this page · raw message
util/size.h +1 -0
@@ -28,6 +28,7 @@ unsigned long long parse_size64(const char *str);unsigned long long __parse_size64 (const char *str,unsigned long long *units);#define ALIGN (x, a) ((((unsigned long long) x) + (a - 1)) & ~(a - 1)) +#define ALIGN_DOWN (x, a) (((((unsigned long long) x) + a) & ~(a - 1)) - a)#define BITS_PER_LONG (sizeof(unsigned long) * 8)#define HPAGE_SIZE (2 << 20)
Signature · 6 lines
2.9.5 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Vishal Verma
maintainerPATCH v3 4/6 ndctl/test: add a new unit test for inject-error
In reply to Vishal VermaAdd a new unit test to test all the features of the inject-error command.
--- test/Makefile.am | 3 +- test/inject-error.sh | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 1 deletion(-) create mode 100755 test/inject-error.sh
test/Makefile.am +2 -1
@@ -13,7 +13,8 @@ TESTS =\ multi-dax.sh \ btt-check.sh \ label-compat.sh \ - blk-exhaust.sh + blk-exhaust.sh \ + inject-error.sh check_PROGRAMS =\ libndctl \
test/inject-error.sh new file +120 -0
120 lines not on this page · raw message
Signature · 6 lines
2.9.5 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Vishal Verma
maintainerPATCH v3 5/6 ndctl/test: update existing unit tests to use inject-error
In reply to Vishal VermaUntil now, various unit tests related to error handling used to expect 'canned' errors to be present in the middle of every nfit_test namespace. With the ACPI error injection patches for nfit_test, this is no longer the case. Update the existing unit tests it inject any errors they need for testing themselves using inject-error, rather than expecting canned errors.
--- test/clear.sh | 5 ++++- test/dax-errors.sh | 5 ++++- test/daxdev-errors.sh | 17 ++++++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-)
test/clear.sh +4 -1
@@ -54,7 +54,10 @@ eval $(echo $json | sed -e "$json2var") [ $dev = "x" ] && echo "fail: $LINENO" && exit 1 [ $mode != "raw" ] && echo "fail: $LINENO" && exit 1 -# check for expected errors in the middle of the namespace +# inject errors in the middle of the namespace, verify that reading fails +err_sector="$(((size/512) / 2))" +err_count=8 +$NDCTL inject-error --block="$err_sector" --count=$err_count $dev read sector len < /sys/block/$blockdev/badblocks [ $((sector * 2)) -ne $((size /512)) ] && echo "fail: $LINENO" && exit 1 if dd if=/dev/$blockdev of=/dev/null iflag=direct bs=512 skip=$sector count=$len; then
test/dax-errors.sh +4 -1
@@ -64,7 +64,10 @@ eval $(echo $json | sed -e "$json2var") [ $dev = "x" ] && echo "fail: $LINENO" && exit 1 [ $mode != "raw" ] && echo "fail: $LINENO" && exit 1 -# check for expected errors in the middle of the namespace +# inject errors in the middle of the namespace, verify that reading fails +err_sector="$(((size/512) / 2))" +err_count=8 +$NDCTL inject-error --block="$err_sector" --count=$err_count $dev read sector len < /sys/block/$blockdev/badblocks [ $((sector * 2)) -ne $((size /512)) ] && echo "fail: $LINENO" && exit 1 if dd if=/dev/$blockdev of=/dev/null iflag=direct bs=512 skip=$sector count=$len; then
test/daxdev-errors.sh +14 -3
@@ -37,6 +37,7 @@ check_min_kver "4.12" || { echo "kernel $KVER lacks dax dev error handling"; exi set -e trap 'err $LINENO' ERR +rc=1 # setup (reset nfit_test dimms) modprobe nfit_test
@@ -68,18 +69,28 @@ chardev=$(echo $json | jq ". | select(.mode == \"dax\") | .daxregion.devices[0]. # } #} +json1=$($NDCTL list $BUS --mode=dax --namespaces) +eval $(echo $json1 | sed -e "$json2var") +nsdev=$dev + json1=$($NDCTL list $BUS) eval $(echo $json1 | sed -e "$json2var") +busdev=$dev + +# inject errors in the middle of the namespace +err_sector="$(((size/512) / 2))" +err_count=8 +$NDCTL inject-error --block="$err_sector" --count=$err_count $nsdev -read sector len < /sys/bus/platform/devices/nfit_test.0/$dev/$region/badblocks +read sector len < /sys/bus/nd/devices/$region/badblocks echo "sector: $sector len: $len" # run the daxdev-errors test test -x ./daxdev-errors -./daxdev-errors $dev $region +./daxdev-errors $busdev $region # check badblocks, should be empty -if read sector len < /sys/bus/platform/devices/nfit_test.0/$dev/$region/badblocks; then +if read sector len < /sys/bus/platform/devices/nfit_test.0/$busdev/$region/badblocks; then echo "badblocks empty, expected" fi [ -n "$sector" ] && echo "fail: $LINENO" && exit 1
Signature · 6 lines
2.9.5 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Vishal Verma
maintainerPATCH v3 6/6 ndctl/test: add a new unit test for BTT error clearing
In reply to Vishal VermaThe new error injection command allows us to inject errors that persist through changing the mode of a BTT namespace to 'raw' and back. This allows us to test error clearing with a BTT by adding a selective error block to the raw namespace, enabling the BTT, and then clearing it via a write.
--- test/Makefile.am | 3 +- test/btt-errors.sh | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+), 1 deletion(-) create mode 100755 test/btt-errors.sh
test/Makefile.am +2 -1
@@ -14,7 +14,8 @@ TESTS =\ btt-check.sh \ label-compat.sh \ blk-exhaust.sh \ - inject-error.sh + inject-error.sh \ + btt-errors.sh check_PROGRAMS =\ libndctl \
test/btt-errors.sh new file +149 -0
149 lines not on this page · raw message
Signature · 6 lines
2.9.5 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm