linux-nvdimm.lists.01.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] nvdimm/btt: fix variable 'rc' set but not used
@ 2019-10-30 21:28 Qian Cai
  2019-10-30 21:38 ` Verma, Vishal L
  0 siblings, 1 reply; 3+ messages in thread
From: Qian Cai @ 2019-10-30 21:28 UTC (permalink / raw)
  To: dan.j.williams; +Cc: linux-nvdimm, linux-kernel, Qian Cai

drivers/nvdimm/btt.c: In function 'btt_read_pg':
drivers/nvdimm/btt.c:1264:8: warning: variable 'rc' set but not used
[-Wunused-but-set-variable]
    int rc;
        ^~

Add a ratelimited message in case a storm of errors is encountered.

Fixes: d9b83c756953 ("libnvdimm, btt: rework error clearing")
Signed-off-by: Qian Cai <cai@lca.pw>
---

v2: include the block address that is returning an error per Dan.

 drivers/nvdimm/btt.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 3e9f45aec8d1..10313be78221 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1266,6 +1266,12 @@ static int btt_read_pg(struct btt *btt, struct bio_integrity_payload *bip,
 			/* Media error - set the e_flag */
 			rc = btt_map_write(arena, premap, postmap, 0, 1,
 				NVDIMM_IO_ATOMIC);
+
+			if (rc)
+				dev_warn_ratelimited(to_dev(arena),
+					"Error persistently tracking bad blocks at %#x\n",
+					premap);
+
 			goto out_rtt;
 		}
 
-- 
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

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

* Re: [PATCH v2] nvdimm/btt: fix variable 'rc' set but not used
  2019-10-30 21:28 [PATCH v2] nvdimm/btt: fix variable 'rc' set but not used Qian Cai
@ 2019-10-30 21:38 ` Verma, Vishal L
  2019-10-30 21:54   ` Qian Cai
  0 siblings, 1 reply; 3+ messages in thread
From: Verma, Vishal L @ 2019-10-30 21:38 UTC (permalink / raw)
  To: cai, Williams, Dan J; +Cc: linux-nvdimm, linux-kernel


On Wed, 2019-10-30 at 17:28 -0400, Qian Cai wrote:
> drivers/nvdimm/btt.c: In function 'btt_read_pg':
> drivers/nvdimm/btt.c:1264:8: warning: variable 'rc' set but not used
> [-Wunused-but-set-variable]
>     int rc;
>         ^~
> 
> Add a ratelimited message in case a storm of errors is encountered.
> 
> Fixes: d9b83c756953 ("libnvdimm, btt: rework error clearing")
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
> 
> v2: include the block address that is returning an error per Dan.
> 
>  drivers/nvdimm/btt.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
> index 3e9f45aec8d1..10313be78221 100644
> --- a/drivers/nvdimm/btt.c
> +++ b/drivers/nvdimm/btt.c
> @@ -1266,6 +1266,12 @@ static int btt_read_pg(struct btt *btt, struct bio_integrity_payload *bip,
>  			/* Media error - set the e_flag */
>  			rc = btt_map_write(arena, premap, postmap, 0, 1,
>  				NVDIMM_IO_ATOMIC);
> +
> +			if (rc)
> +				dev_warn_ratelimited(to_dev(arena),
> +					"Error persistently tracking bad blocks at %#x\n",
> +					premap);
> +
>  			goto out_rtt;
>  		}

Good find! Since we're not really using rc later, we should just
simplify this to:

	if (btt_map_write(...))
		dev_warn_ratelimited(...)
	goto out_rtt;


_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

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

* Re: [PATCH v2] nvdimm/btt: fix variable 'rc' set but not used
  2019-10-30 21:38 ` Verma, Vishal L
@ 2019-10-30 21:54   ` Qian Cai
  0 siblings, 0 replies; 3+ messages in thread
From: Qian Cai @ 2019-10-30 21:54 UTC (permalink / raw)
  To: Verma, Vishal L; +Cc: linux-nvdimm, linux-kernel



> On Oct 30, 2019, at 5:38 PM, Verma, Vishal L <vishal.l.verma@intel.com> wrote:
> 
> Good find! Since we're not really using rc later, we should just
> simplify this to:
> 
>    if (btt_map_write(...))
>        dev_warn_ratelimited(...)
>    goto out_rtt;

Ah, I thought about printing the rc as well at first, but it seems only return -EIO for errors, so I agree with you.
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

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

end of thread, other threads:[~2019-10-30 21:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 21:28 [PATCH v2] nvdimm/btt: fix variable 'rc' set but not used Qian Cai
2019-10-30 21:38 ` Verma, Vishal L
2019-10-30 21:54   ` Qian Cai

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).