From: "Javier González" <jg@lightnvm.io>
To: mb@lightnvm.io
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
"Javier González" <javier@cnexlabs.com>
Subject: [PATCH 1/5] lightnvm: pblk: fix race condition on line retry
Date: Sat, 22 Apr 2017 01:32:45 +0200 [thread overview]
Message-ID: <1492817569-13532-2-git-send-email-javier@cnexlabs.com> (raw)
In-Reply-To: <1492817569-13532-1-git-send-email-javier@cnexlabs.com>
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>
---
drivers/lightnvm/pblk-core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c
index a2bcd09..7065658 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;
}
--
2.7.4
next prev parent reply other threads:[~2017-04-21 23:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-21 23:32 [PATCH 0/5] lightnvm: pblk extra patches for 4.12 Javier González
2017-04-21 23:32 ` Javier González [this message]
2017-04-22 8:51 ` [PATCH 1/5] lightnvm: pblk: fix race condition on line retry Matias Bjørling
2017-04-21 23:32 ` [PATCH 2/5] lightnvm: pblk: fix bad error check Javier González
2017-04-22 8:52 ` Matias Bjørling
2017-04-21 23:32 ` [PATCH 3/5] lightnvm: pblk: fix memory leak on error path Javier González
2017-04-22 8:57 ` Matias Bjørling
2017-04-21 23:32 ` [PATCH 4/5] lightnvm: pblk: free metadata on line alloc failure Javier González
2017-04-22 9:02 ` Matias Bjørling
2017-04-21 23:32 ` [PATCH 5/5] lightnvm: pblk: fix erase counters on error fail Javier González
2017-04-22 9:22 ` Matias Bjørling
2017-04-22 9:31 ` Javier González
2017-04-23 17:59 ` Matias Bjørling
2017-04-23 18:18 ` Javier González
2017-04-23 18:00 ` [PATCH 0/5] lightnvm: pblk extra patches for 4.12 Matias Bjørling
2017-04-23 22:58 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1492817569-13532-2-git-send-email-javier@cnexlabs.com \
--to=jg@lightnvm.io \
--cc=javier@cnexlabs.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mb@lightnvm.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).