* [PATCH 2/6] lightnvm: pblk: protect line bitmap while submitting meta io
@ 2017-09-21 11:26 Rakesh Pandit
2017-09-22 8:49 ` Javier González
2017-10-04 11:24 ` Javier González
0 siblings, 2 replies; 4+ messages in thread
From: Rakesh Pandit @ 2017-09-21 11:26 UTC (permalink / raw)
To: Matias Bjørling, linux-block, linux-kernel; +Cc: Javier González
It seems pblk_dealloc_page would race against pblk_alloc_pages for
line bitmap for sector allocation. The chances are very low but might
as well protect the bitmap properly. It's not even in fast path.
Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
---
drivers/lightnvm/pblk-core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index a230125..b92eabc 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -502,12 +502,14 @@ void pblk_dealloc_page(struct pblk *pblk, struct pblk_line *line, int nr_secs)
u64 addr;
int i;
+ spin_lock(&line->lock);
addr = find_next_zero_bit(line->map_bitmap,
pblk->lm.sec_per_line, line->cur_sec);
line->cur_sec = addr - nr_secs;
for (i = 0; i < nr_secs; i++, line->cur_sec--)
WARN_ON(!test_and_clear_bit(line->cur_sec, line->map_bitmap));
+ spin_lock(&line->lock);
}
u64 __pblk_alloc_page(struct pblk *pblk, struct pblk_line *line, int nr_secs)
--
2.5.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/6] lightnvm: pblk: protect line bitmap while submitting meta io
2017-09-21 11:26 [PATCH 2/6] lightnvm: pblk: protect line bitmap while submitting meta io Rakesh Pandit
@ 2017-09-22 8:49 ` Javier González
2017-09-25 10:14 ` Matias Bjørling
2017-10-04 11:24 ` Javier González
1 sibling, 1 reply; 4+ messages in thread
From: Javier González @ 2017-09-22 8:49 UTC (permalink / raw)
To: Rakesh Pandit; +Cc: Matias Bjørling, linux-block, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1497 bytes --]
> On 21 Sep 2017, at 13.26, Rakesh Pandit <rakesh@tuxera.com> wrote:
>
> It seems pblk_dealloc_page would race against pblk_alloc_pages for
> line bitmap for sector allocation. The chances are very low but might
> as well protect the bitmap properly. It's not even in fast path.
>
> Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
> ---
> drivers/lightnvm/pblk-core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
> index a230125..b92eabc 100644
> --- a/drivers/lightnvm/pblk-core.c
> +++ b/drivers/lightnvm/pblk-core.c
> @@ -502,12 +502,14 @@ void pblk_dealloc_page(struct pblk *pblk, struct pblk_line *line, int nr_secs)
> u64 addr;
> int i;
>
> + spin_lock(&line->lock);
> addr = find_next_zero_bit(line->map_bitmap,
> pblk->lm.sec_per_line, line->cur_sec);
> line->cur_sec = addr - nr_secs;
>
> for (i = 0; i < nr_secs; i++, line->cur_sec--)
> WARN_ON(!test_and_clear_bit(line->cur_sec, line->map_bitmap));
> + spin_lock(&line->lock);
> }
>
> u64 __pblk_alloc_page(struct pblk *pblk, struct pblk_line *line, int nr_secs)
> --
> 2.5.0
Looks good. The reason not to have locks here was that the caller is
always on the write thread - who did the allocation -, since it is error
handling. So there is no protection needed. In any case, it is better to
have it since it is implemented as a helper function.
Reviewed-by: Javier González <javier@cnexlabs.com>
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/6] lightnvm: pblk: protect line bitmap while submitting meta io
2017-09-22 8:49 ` Javier González
@ 2017-09-25 10:14 ` Matias Bjørling
0 siblings, 0 replies; 4+ messages in thread
From: Matias Bjørling @ 2017-09-25 10:14 UTC (permalink / raw)
To: Javier González, Rakesh Pandit; +Cc: linux-block, linux-kernel
On 09/22/2017 10:49 AM, Javier González wrote:
>> On 21 Sep 2017, at 13.26, Rakesh Pandit <rakesh@tuxera.com> wrote:
>>
>> It seems pblk_dealloc_page would race against pblk_alloc_pages for
>> line bitmap for sector allocation. The chances are very low but might
>> as well protect the bitmap properly. It's not even in fast path.
>>
>> Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
>> ---
>> drivers/lightnvm/pblk-core.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
>> index a230125..b92eabc 100644
>> --- a/drivers/lightnvm/pblk-core.c
>> +++ b/drivers/lightnvm/pblk-core.c
>> @@ -502,12 +502,14 @@ void pblk_dealloc_page(struct pblk *pblk, struct pblk_line *line, int nr_secs)
>> u64 addr;
>> int i;
>>
>> + spin_lock(&line->lock);
>> addr = find_next_zero_bit(line->map_bitmap,
>> pblk->lm.sec_per_line, line->cur_sec);
>> line->cur_sec = addr - nr_secs;
>>
>> for (i = 0; i < nr_secs; i++, line->cur_sec--)
>> WARN_ON(!test_and_clear_bit(line->cur_sec, line->map_bitmap));
>> + spin_lock(&line->lock);
>> }
>>
>> u64 __pblk_alloc_page(struct pblk *pblk, struct pblk_line *line, int nr_secs)
>> --
>> 2.5.0
>
> Looks good. The reason not to have locks here was that the caller is
> always on the write thread - who did the allocation -, since it is error
> handling. So there is no protection needed. In any case, it is better to
> have it since it is implemented as a helper function.
>
>
> Reviewed-by: Javier González <javier@cnexlabs.com>
>
Thanks, I picked it up.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/6] lightnvm: pblk: protect line bitmap while submitting meta io
2017-09-21 11:26 [PATCH 2/6] lightnvm: pblk: protect line bitmap while submitting meta io Rakesh Pandit
2017-09-22 8:49 ` Javier González
@ 2017-10-04 11:24 ` Javier González
1 sibling, 0 replies; 4+ messages in thread
From: Javier González @ 2017-10-04 11:24 UTC (permalink / raw)
To: Rakesh Pandit; +Cc: Matias Bjørling, linux-block, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1122 bytes --]
> On 21 Sep 2017, at 13.26, Rakesh Pandit <rakesh@tuxera.com> wrote:
>
> It seems pblk_dealloc_page would race against pblk_alloc_pages for
> line bitmap for sector allocation. The chances are very low but might
> as well protect the bitmap properly. It's not even in fast path.
>
> Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
> ---
> drivers/lightnvm/pblk-core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
> index a230125..b92eabc 100644
> --- a/drivers/lightnvm/pblk-core.c
> +++ b/drivers/lightnvm/pblk-core.c
> @@ -502,12 +502,14 @@ void pblk_dealloc_page(struct pblk *pblk, struct pblk_line *line, int nr_secs)
> u64 addr;
> int i;
>
> + spin_lock(&line->lock);
> addr = find_next_zero_bit(line->map_bitmap,
> pblk->lm.sec_per_line, line->cur_sec);
> line->cur_sec = addr - nr_secs;
>
> for (i = 0; i < nr_secs; i++, line->cur_sec--)
> WARN_ON(!test_and_clear_bit(line->cur_sec, line->map_bitmap));
> + spin_lock(&line->lock);
Changed this to spin_unlock() when picking it up.
Javier.
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-10-04 11:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-21 11:26 [PATCH 2/6] lightnvm: pblk: protect line bitmap while submitting meta io Rakesh Pandit
2017-09-22 8:49 ` Javier González
2017-09-25 10:14 ` Matias Bjørling
2017-10-04 11:24 ` Javier González
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).