[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <930717BD-D32A-4BE2-AEE6-579594E70842@cnexlabs.com>
Date: Wed, 28 Nov 2018 09:16:13 +0000
From: Javier Gonzalez <javier@...xlabs.com>
To: Hua Su <suhua.tanke@...il.com>
CC: Matias Bjørling <mb@...htnvm.io>,
Jens Axboe <axboe@...nel.dk>,
"linux-block@...r.kernel.org" <linux-block@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] lightnvm: pblk: add lock protection to list operations
> On 28 Nov 2018, at 10.13, Hua Su <suhua.tanke@...il.com> wrote:
>
> Protect the list_add on the pblk_line_init_bb() error
> path in case this code is used for some other purpose
> in the future.
>
> Signed-off-by: Hua Su <suhua.tanke@...il.com>
> ---
> drivers/lightnvm/pblk-core.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
> index 6944aac43b01..247112e1db94 100644
> --- a/drivers/lightnvm/pblk-core.c
> +++ b/drivers/lightnvm/pblk-core.c
> @@ -1295,15 +1295,22 @@ int pblk_line_recov_alloc(struct pblk *pblk, struct pblk_line *line)
>
> ret = pblk_line_alloc_bitmaps(pblk, line);
> if (ret)
> - return ret;
> + goto fail;
>
> if (!pblk_line_init_bb(pblk, line, 0)) {
> - list_add(&line->list, &l_mg->free_list);
> - return -EINTR;
> + ret = -EINTR;
> + goto fail;
> }
>
> pblk_rl_free_lines_dec(&pblk->rl, line, true);
> return 0;
> +
> +fail:
> + spin_lock(&l_mg->free_lock);
> + list_add(&line->list, &l_mg->free_list);
> + spin_unlock(&l_mg->free_lock);
> +
> + return ret;
> }
>
> void pblk_line_recov_close(struct pblk *pblk, struct pblk_line *line)
> --
> 2.19.1
Looks good to me.
Reviewed-by: Javier González <javier@...xlabs.com>
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists