ndctl: Suppress command errors if fallback exists
PATCH 1/1 ndctl: Suppress command errors if fallback exists
If a command has a fallback to handle an error, this patch will not emit an error message and instead let the handler report any errors.
Signed-off-by Keith Busch <[email protected]>
--- ndctl/lib/intel.c | 9 +++++++-- ndctl/lib/libndctl.c | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-)
ndctl/lib/intel.c +7 -2
@@ -64,15 +64,17 @@ static struct ndctl_cmd *alloc_intel_cmd(struct ndctl_dimm *dimm,static int intel_smart_handle_error (struct ndctl_cmd *cmd) {struct ndctl_dimm *dimm = cmd->dimm; +struct ndctl_bus *bus =cmd_to_bus (cmd); +struct ndctl_ctx *ctx =ndctl_bus_get_ctx (bus);char *path =NULL , shutdown_count[16 ] = {};int fd, rc = cmd->status;if (!dimm) -return 0 ; + goto out;if (asprintf (&path,DEF_TMPFS_DIR "/%s/usc" ,ndctl_dimm_get_devname (dimm)) <0 ) -return rc; + goto out; fd =open (path,O_RDONLY );if (fd <0 )
@@ -88,6 +90,9 @@ static int intel_smart_handle_error(struct ndctl_cmd *cmd)close (fd); free_path:free (path); + out: +if (rc) +err (ctx,"failed: %s\n" ,strerror (errno));return rc; }
ndctl/lib/libndctl.c +3 -1
@@ -2753,7 +2753,9 @@ NDCTL_EXPORT int ndctl_cmd_submit(struct ndctl_cmd *cmd) fd =open (path,O_RDWR );if (fd <0 ) { -err (ctx,"failed to open %s: %s\n" , path,strerror (errno)); +if (!cmd->handle_error) +err (ctx,"failed to open %s: %s\n" , path, +strerror (errno)); rc = -errno; goto out; }
Signature · 6 lines
2.14.4 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Verma, Vishal L
maintainerQuoted 9 lines · Keith Busch
If a command has a fallback to handle an error, this patch will not emit
an error message and instead let the handler report any errors.Signed-off-by Keith Busch <[email protected]>--- ndctl/lib/intel.c | 9 +++++++-- ndctl/lib/libndctl.c | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-)
Looks good, applied.
Quoted 52 lines
ndctl/lib/intel.c +4
-2@@ -64,15 +64,17 @@ static struct ndctl_cmd *alloc_intel_cmd(structndctl_dimm *dimm, static int intel_smart_handle_error(struct ndctl_cmd *cmd) { struct ndctl_dimm *dimm = cmd->dimm; +struct ndctl_bus *bus =cmd_to_bus (cmd); +struct ndctl_ctx *ctx =ndctl_bus_get_ctx (bus);char *path =NULL , shutdown_count[16 ] = {};int fd, rc = cmd->status;if (!dimm) -return 0 ; + goto out;if (asprintf (&path,DEF_TMPFS_DIR "/%s/usc" ,ndctl_dimm_get_devname (dimm)) <0 ) -return rc; + goto out; fd =open (path,O_RDONLY );ndctl/lib/intel.c +3
-0if (fd <0 )@@ -88,6 +90,9 @@ static int intel_smart_handle_error(struct ndctl_cmd *cmd)close (fd ); free_path:free (path); + out: +if (rc) +err (ctx,"failed: %s\n" ,strerror (errno));return rc; }ndctl/lib/libndctl.c +3
-1@@ -2753,7 +2753,9 @@ NDCTL_EXPORT int ndctl_cmd_submit(struct ndctl_cmd *cmd) fd =open (path,O_RDWR );if (fd <0 ) { -err (ctx,"failed to open %s: %s\n" , path, strerror(errno)); +if (!cmd->handle_error) +err (ctx,"failed to open %s: %s\n" , path, +strerror (errno)); rc = -errno;
ndctl/lib/libndctl.c NDCTL_EXPORT int ndctl_cmd_submit(struct ndctl_cmd *cmd) · line 2761
Quoted 2 lines
ndctl/lib/libndctl.c +0
-0goto out; }
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm