From: hans.ml.holmberg@owltronix.com
To: "Matias Bjørling" <mb@lightnvm.io>
Cc: "Javier González" <jg@lightnvm.io>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
"Hans Holmberg" <hans.holmberg@cnexlabs.com>
Subject: [PATCH 3/3] lightnvm: pblk: prevent race in pblk_rb_flush_point_set
Date: Wed, 21 Feb 2018 09:03:01 +0100 [thread overview]
Message-ID: <1519200181-10886-4-git-send-email-hans.ml.holmberg@owltronix.com> (raw)
In-Reply-To: <1519200181-10886-1-git-send-email-hans.ml.holmberg@owltronix.com>
From: Hans Holmberg <hans.holmberg@cnexlabs.com>
Make sure that we are not advancing the sync pointer while
we're adding bios to the write buffer entry completion list.
This race condition results in bios not completing and was identified
by a hang when running xfstest generic/113.
Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
---
drivers/lightnvm/pblk-rb.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/lightnvm/pblk-rb.c b/drivers/lightnvm/pblk-rb.c
index 8b14340..52fdd85 100644
--- a/drivers/lightnvm/pblk-rb.c
+++ b/drivers/lightnvm/pblk-rb.c
@@ -355,10 +355,13 @@ static int pblk_rb_flush_point_set(struct pblk_rb *rb, struct bio *bio,
struct pblk_rb_entry *entry;
unsigned int sync, flush_point;
+ pblk_rb_sync_init(rb, NULL);
sync = READ_ONCE(rb->sync);
- if (pos == sync)
+ if (pos == sync) {
+ pblk_rb_sync_end(rb, NULL);
return 0;
+ }
#ifdef CONFIG_NVM_DEBUG
atomic_inc(&rb->inflight_flush_point);
@@ -367,8 +370,6 @@ static int pblk_rb_flush_point_set(struct pblk_rb *rb, struct bio *bio,
flush_point = (pos == 0) ? (rb->nr_entries - 1) : (pos - 1);
entry = &rb->entries[flush_point];
- pblk_rb_sync_init(rb, NULL);
-
/* Protect flush points */
smp_store_release(&rb->flush_point, flush_point);
--
2.7.4
next prev parent reply other threads:[~2018-02-21 8:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-21 8:02 [PATCH 0/3] pblk bugfixes hans.ml.holmberg
2018-02-21 8:02 ` [PATCH 1/3] lightnvm: pblk: delete writer kick timer before stopping thread hans.ml.holmberg
2018-02-21 8:03 ` [PATCH 2/3] lightnvm: pblk: allow allocation of new lines during shutdown hans.ml.holmberg
2018-02-21 8:03 ` hans.ml.holmberg [this message]
2018-02-21 8:09 ` [PATCH 0/3] pblk bugfixes Matias Bjørling
2018-02-21 8:12 ` Javier González
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=1519200181-10886-4-git-send-email-hans.ml.holmberg@owltronix.com \
--to=hans.ml.holmberg@owltronix.com \
--cc=hans.holmberg@cnexlabs.com \
--cc=jg@lightnvm.io \
--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
all inboxes | Powered by JetHome®