LKML Archive on lore.kernel.org
 help / Atom feed
* [PATCH] lightnvm: pblk: fix rqd.error return value in pblk_blk_erase_sync
@ 2018-08-02 20:50 Matias Bjørling
  2018-08-03 12:25 ` Javier Gonzalez
  2018-08-10  8:17 ` Hans Holmberg
  0 siblings, 2 replies; 3+ messages in thread
From: Matias Bjørling @ 2018-08-02 20:50 UTC (permalink / raw)
  To: igor.j.konopko, marcin.dziegielewski, javier, hans.holmberg,
	hlitz, youngtack.jin
  Cc: linux-block, linux-kernel, Matias Bjørling

rqd.error is masked by the return value of pblk_submit_io_sync.
The rqd structure is then passed on to the end_io function, which
assumes that any error should lead to a chunk being marked
offline/bad. Since the pblk_submit_io_sync can fail before the
command is issued to the device, the error value maybe not correspond
to a media failure, leading to chunks being immaturely retired.

Also, the pblk_blk_erase_sync function prints an error message in case
the erase fails. Since the caller prints an error message by itself,
remove the error message in this function.

Signed-off-by: Matias Bjørling <mb@lightnvm.io>
---
 drivers/lightnvm/pblk-core.c | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index 72acf2f6dbd6..814204d22a2e 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -886,10 +886,8 @@ static void pblk_setup_e_rq(struct pblk *pblk, struct nvm_rq *rqd,
 
 static int pblk_blk_erase_sync(struct pblk *pblk, struct ppa_addr ppa)
 {
-	struct nvm_rq rqd;
-	int ret = 0;
-
-	memset(&rqd, 0, sizeof(struct nvm_rq));
+	struct nvm_rq rqd = {0};
+	int ret;
 
 	pblk_setup_e_rq(pblk, &rqd, ppa);
 
@@ -897,19 +895,6 @@ static int pblk_blk_erase_sync(struct pblk *pblk, struct ppa_addr ppa)
 	 * with writes. Thus, there is no need to take the LUN semaphore.
 	 */
 	ret = pblk_submit_io_sync(pblk, &rqd);
-	if (ret) {
-		struct nvm_tgt_dev *dev = pblk->dev;
-		struct nvm_geo *geo = &dev->geo;
-
-		pblk_err(pblk, "could not sync erase line:%d,blk:%d\n",
-					pblk_ppa_to_line(ppa),
-					pblk_ppa_to_pos(geo, ppa));
-
-		rqd.error = ret;
-		goto out;
-	}
-
-out:
 	rqd.private = pblk;
 	__pblk_end_io_erase(pblk, &rqd);
 
-- 
2.11.0


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

* Re: [PATCH] lightnvm: pblk: fix rqd.error return value in pblk_blk_erase_sync
  2018-08-02 20:50 [PATCH] lightnvm: pblk: fix rqd.error return value in pblk_blk_erase_sync Matias Bjørling
@ 2018-08-03 12:25 ` Javier Gonzalez
  2018-08-10  8:17 ` Hans Holmberg
  1 sibling, 0 replies; 3+ messages in thread
From: Javier Gonzalez @ 2018-08-03 12:25 UTC (permalink / raw)
  To: Matias Bjørling
  Cc: Konopko, Igor J, marcin.dziegielewski, Hans Holmberg,
	Heiner Litz, Young Tack Tack Jin, linux-block, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2331 bytes --]

> On 2 Aug 2018, at 22.50, Matias Bjørling <mb@lightnvm.io> wrote:
> 
> rqd.error is masked by the return value of pblk_submit_io_sync.
> The rqd structure is then passed on to the end_io function, which
> assumes that any error should lead to a chunk being marked
> offline/bad. Since the pblk_submit_io_sync can fail before the
> command is issued to the device, the error value maybe not correspond
> to a media failure, leading to chunks being immaturely retired.
> 
> Also, the pblk_blk_erase_sync function prints an error message in case
> the erase fails. Since the caller prints an error message by itself,
> remove the error message in this function.
> 
> Signed-off-by: Matias Bjørling <mb@lightnvm.io>
> ---
> drivers/lightnvm/pblk-core.c | 19 ++-----------------
> 1 file changed, 2 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
> index 72acf2f6dbd6..814204d22a2e 100644
> --- a/drivers/lightnvm/pblk-core.c
> +++ b/drivers/lightnvm/pblk-core.c
> @@ -886,10 +886,8 @@ static void pblk_setup_e_rq(struct pblk *pblk, struct nvm_rq *rqd,
> 
> static int pblk_blk_erase_sync(struct pblk *pblk, struct ppa_addr ppa)
> {
> -	struct nvm_rq rqd;
> -	int ret = 0;
> -
> -	memset(&rqd, 0, sizeof(struct nvm_rq));
> +	struct nvm_rq rqd = {0};

This is a matter of taste, but if you want to squeeze it in here, it is
fine by me. There are other places with the same pattern; if you feel
strongly about this then please send a patch changing it in all the
places.

> +	int ret;
> 
> 	pblk_setup_e_rq(pblk, &rqd, ppa);
> 
> @@ -897,19 +895,6 @@ static int pblk_blk_erase_sync(struct pblk *pblk, struct ppa_addr ppa)
> 	 * with writes. Thus, there is no need to take the LUN semaphore.
> 	 */
> 	ret = pblk_submit_io_sync(pblk, &rqd);
> -	if (ret) {
> -		struct nvm_tgt_dev *dev = pblk->dev;
> -		struct nvm_geo *geo = &dev->geo;
> -
> -		pblk_err(pblk, "could not sync erase line:%d,blk:%d\n",
> -					pblk_ppa_to_line(ppa),
> -					pblk_ppa_to_pos(geo, ppa));
> -
> -		rqd.error = ret;
> -		goto out;
> -	}
> -
> -out:
> 	rqd.private = pblk;
> 	__pblk_end_io_erase(pblk, &rqd);
> 
> --
> 2.11.0

Otherwise, it looks like a good cleanup. Thanks.

Reviewed-by: Javier González <javier@cnexlabs.com>


[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] lightnvm: pblk: fix rqd.error return value in pblk_blk_erase_sync
  2018-08-02 20:50 [PATCH] lightnvm: pblk: fix rqd.error return value in pblk_blk_erase_sync Matias Bjørling
  2018-08-03 12:25 ` Javier Gonzalez
@ 2018-08-10  8:17 ` Hans Holmberg
  1 sibling, 0 replies; 3+ messages in thread
From: Hans Holmberg @ 2018-08-10  8:17 UTC (permalink / raw)
  To: Matias Bjørling
  Cc: igor.j.konopko, marcin.dziegielewski, Javier Gonzalez,
	Hans Holmberg, hlitz, youngtack.jin, linux-block,
	Linux Kernel Mailing List

On Thu, Aug 2, 2018 at 10:50 PM, Matias Bjørling <mb@lightnvm.io> wrote:
> rqd.error is masked by the return value of pblk_submit_io_sync.
> The rqd structure is then passed on to the end_io function, which
> assumes that any error should lead to a chunk being marked
> offline/bad. Since the pblk_submit_io_sync can fail before the
> command is issued to the device, the error value maybe not correspond
> to a media failure, leading to chunks being immaturely retired.
>
> Also, the pblk_blk_erase_sync function prints an error message in case
> the erase fails. Since the caller prints an error message by itself,
> remove the error message in this function.
>
> Signed-off-by: Matias Bjørling <mb@lightnvm.io>
> ---
>  drivers/lightnvm/pblk-core.c | 19 ++-----------------
>  1 file changed, 2 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
> index 72acf2f6dbd6..814204d22a2e 100644
> --- a/drivers/lightnvm/pblk-core.c
> +++ b/drivers/lightnvm/pblk-core.c
> @@ -886,10 +886,8 @@ static void pblk_setup_e_rq(struct pblk *pblk, struct nvm_rq *rqd,
>
>  static int pblk_blk_erase_sync(struct pblk *pblk, struct ppa_addr ppa)
>  {
> -       struct nvm_rq rqd;
> -       int ret = 0;
> -
> -       memset(&rqd, 0, sizeof(struct nvm_rq));
> +       struct nvm_rq rqd = {0};
> +       int ret;
>
>         pblk_setup_e_rq(pblk, &rqd, ppa);
>
> @@ -897,19 +895,6 @@ static int pblk_blk_erase_sync(struct pblk *pblk, struct ppa_addr ppa)
>          * with writes. Thus, there is no need to take the LUN semaphore.
>          */
>         ret = pblk_submit_io_sync(pblk, &rqd);
> -       if (ret) {
> -               struct nvm_tgt_dev *dev = pblk->dev;
> -               struct nvm_geo *geo = &dev->geo;
> -
> -               pblk_err(pblk, "could not sync erase line:%d,blk:%d\n",
> -                                       pblk_ppa_to_line(ppa),
> -                                       pblk_ppa_to_pos(geo, ppa));
> -
> -               rqd.error = ret;
> -               goto out;
> -       }
> -
> -out:
>         rqd.private = pblk;
>         __pblk_end_io_erase(pblk, &rqd);
>
> --
> 2.11.0
>


Nice catch! I just added fixing this exact issue in my own backlog,
great that you've already fixed it.

Reviewed-by: Hans Holmberg <hans.holmberg@cnexlabs.com>

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-02 20:50 [PATCH] lightnvm: pblk: fix rqd.error return value in pblk_blk_erase_sync Matias Bjørling
2018-08-03 12:25 ` Javier Gonzalez
2018-08-10  8:17 ` Hans Holmberg

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox