All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lightnvm: pblk: add lock protection to list operations
@ 2018-11-28  9:13 Hua Su
  2018-11-28  9:16 ` Javier Gonzalez
  0 siblings, 1 reply; 3+ messages in thread
From: Hua Su @ 2018-11-28  9:13 UTC (permalink / raw)
  To: mb; +Cc: javier, axboe, linux-block, linux-kernel, suhua.tanke

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@gmail.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


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

* Re: [PATCH] lightnvm: pblk: add lock protection to list operations
  2018-11-28  9:13 [PATCH] lightnvm: pblk: add lock protection to list operations Hua Su
@ 2018-11-28  9:16 ` Javier Gonzalez
  2018-11-30  8:36   ` Matias Bjørling
  0 siblings, 1 reply; 3+ messages in thread
From: Javier Gonzalez @ 2018-11-28  9:16 UTC (permalink / raw)
  To: Hua Su; +Cc: Matias Bjørling, Jens Axboe, linux-block, linux-kernel

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

> On 28 Nov 2018, at 10.13, Hua Su <suhua.tanke@gmail.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@gmail.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@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: add lock protection to list operations
  2018-11-28  9:16 ` Javier Gonzalez
@ 2018-11-30  8:36   ` Matias Bjørling
  0 siblings, 0 replies; 3+ messages in thread
From: Matias Bjørling @ 2018-11-30  8:36 UTC (permalink / raw)
  To: Javier Gonzalez, Hua Su; +Cc: Jens Axboe, linux-block, linux-kernel

On 11/28/2018 10:16 AM, Javier Gonzalez wrote:
>> On 28 Nov 2018, at 10.13, Hua Su <suhua.tanke@gmail.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@gmail.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@cnexlabs.com>
> 

Picked up for 4.21.

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

end of thread, other threads:[~2018-11-30  8:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-28  9:13 [PATCH] lightnvm: pblk: add lock protection to list operations Hua Su
2018-11-28  9:16 ` Javier Gonzalez
2018-11-30  8:36   ` Matias Bjørling

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.