summaryrefslogtreecommitdiff
path: root/drivers/lightnvm
diff options
context:
space:
mode:
authorJavier González <jg@lightnvm.io>2017-04-22 01:32:45 +0200
committerJens Axboe <axboe@fb.com>2017-04-23 16:57:52 -0600
commit3dc001f343659e4732b4ff6da1c28edbd56c6e15 (patch)
tree5d541173911c6ab32b812541aff08beeae5853fa /drivers/lightnvm
parent2859323e35ab5fc42f351fbda23ab544eaa85945 (diff)
downloadlinux-3dc001f343659e4732b4ff6da1c28edbd56c6e15.tar.gz
lightnvm: pblk: fix race condition on line retry
When a pblk line fails (or is recovered), make sure to take the line management lock. Fixes: a4bd217b4326 "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>
Diffstat (limited to 'drivers/lightnvm')
-rw-r--r--drivers/lightnvm/pblk-core.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index a2bcd098babc..7065658fd7ee 100644
--- a/drivers/lightnvm/pblk-core.c
+++ b/drivers/lightnvm/pblk-core.c
@@ -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);
@@ -1140,6 +1141,7 @@ 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))
@@ -1147,8 +1149,6 @@ static struct pblk_line *pblk_line_retry(struct pblk *pblk,
pblk_rl_free_lines_dec(&pblk->rl, retry_line);
- l_mg->data_line = retry_line;
-
return retry_line;
}