Skip to content

Commit

Permalink
lightnvm: pblk: fix race condition on line retry
Browse files Browse the repository at this point in the history
When a pblk line fails (or is recovered), make sure to take the line
management lock.

Fixes: a4bd217 "lightnvm: physical block device (pblk) target"

Signed-off-by: Javier González <javier@cnexlabs.com>
Reviewed-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Javier González authored and Jens Axboe committed Apr 23, 2017
1 parent 2859323 commit 3dc001f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/lightnvm/pblk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1050,13 +1050,14 @@ int pblk_line_recov_alloc(struct pblk *pblk, struct pblk_line *line)
spin_lock(&l_mg->free_lock);
l_mg->data_line = line;
list_del(&line->list);
spin_unlock(&l_mg->free_lock);

ret = pblk_line_prepare(pblk, line);
if (ret) {
list_add(&line->list, &l_mg->free_list);
spin_unlock(&l_mg->free_lock);
return ret;
}
spin_unlock(&l_mg->free_lock);

pblk_rl_free_lines_dec(&pblk->rl, line);

Expand Down Expand Up @@ -1140,15 +1141,14 @@ static struct pblk_line *pblk_line_retry(struct pblk *pblk,
line->invalid_bitmap = NULL;
line->smeta = NULL;
line->emeta = NULL;
l_mg->data_line = retry_line;
spin_unlock(&l_mg->free_lock);

if (pblk_line_erase(pblk, retry_line))
return NULL;

pblk_rl_free_lines_dec(&pblk->rl, retry_line);

l_mg->data_line = retry_line;

return retry_line;
}

Expand Down

0 comments on commit 3dc001f

Please sign in to comment.