nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [ndctl PATCH] ndctl: Suppress command errors if fallback exists
@ 2018-09-06 18:58 Keith Busch
  2018-09-06 21:58 ` Verma, Vishal L
  0 siblings, 1 reply; 2+ messages in thread
From: Keith Busch @ 2018-09-06 18:58 UTC (permalink / raw)
  To: linux-nvdimm, Vishal Verma

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 <keith.busch@intel.com>
---
 ndctl/lib/intel.c    | 9 +++++++--
 ndctl/lib/libndctl.c | 4 +++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/ndctl/lib/intel.c b/ndctl/lib/intel.c
index b1254bb..15c5d1a 100644
--- a/ndctl/lib/intel.c
+++ b/ndctl/lib/intel.c
@@ -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;
 }
 
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 226a577..481b110 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -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;
 	}
-- 
2.14.4

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ndctl PATCH] ndctl: Suppress command errors if fallback exists
  2018-09-06 18:58 [ndctl PATCH] ndctl: Suppress command errors if fallback exists Keith Busch
@ 2018-09-06 21:58 ` Verma, Vishal L
  0 siblings, 0 replies; 2+ messages in thread
From: Verma, Vishal L @ 2018-09-06 21:58 UTC (permalink / raw)
  To: Busch, Keith, linux-nvdimm


On Thu, 2018-09-06 at 12:58 -0600, Keith Busch wrote:
> 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 <keith.busch@intel.com>
> ---
>  ndctl/lib/intel.c    | 9 +++++++--
>  ndctl/lib/libndctl.c | 4 +++-
>  2 files changed, 10 insertions(+), 3 deletions(-)

Looks good, applied.

> 
> diff --git a/ndctl/lib/intel.c b/ndctl/lib/intel.c
> index b1254bb..15c5d1a 100644
> --- a/ndctl/lib/intel.c
> +++ b/ndctl/lib/intel.c
> @@ -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;
>  }
>  
> diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
> index 226a577..481b110 100644
> --- a/ndctl/lib/libndctl.c
> +++ b/ndctl/lib/libndctl.c
> @@ -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;
>  	}
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-06 22:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-06 18:58 [ndctl PATCH] ndctl: Suppress command errors if fallback exists Keith Busch
2018-09-06 21:58 ` Verma, Vishal L

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).