From: "Javier González" <jg@lightnvm.io>
To: linux-block@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, "Javier González" <javier@cnexlabs.com>
Subject: [PATCH 07/11] lightnvm: pblk: simplify path on REQ_PREFLUSH
Date: Fri, 15 Sep 2017 14:25:35 +0200 [thread overview]
Message-ID: <1505478339-13089-8-git-send-email-javier@cnexlabs.com> (raw)
In-Reply-To: <1505478339-13089-1-git-send-email-javier@cnexlabs.com>
On REQ_PREFLUSH, directly tag the I/O context flags to signal a flush in
the write to cache path, instead of finding the correct entry context
and imposing a memory barrier. This simplifies the code and might
potentially prevent race conditions when adding functionality to the
write path.
Signed-off-by: Javier González <javier@cnexlabs.com>
---
drivers/lightnvm/pblk-cache.c | 4 +++-
drivers/lightnvm/pblk-rb.c | 8 +-------
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/lightnvm/pblk-cache.c b/drivers/lightnvm/pblk-cache.c
index 1d6b8e3585f1..0d227ef7d1b9 100644
--- a/drivers/lightnvm/pblk-cache.c
+++ b/drivers/lightnvm/pblk-cache.c
@@ -43,8 +43,10 @@ int pblk_write_to_cache(struct pblk *pblk, struct bio *bio, unsigned long flags)
if (unlikely(!bio_has_data(bio)))
goto out;
+ pblk_ppa_set_empty(&w_ctx.ppa);
w_ctx.flags = flags;
- pblk_ppa_set_empty(&w_ctx.ppa);
+ if (bio->bi_opf & REQ_PREFLUSH)
+ w_ctx.flags |= PBLK_FLUSH_ENTRY;
for (i = 0; i < nr_entries; i++) {
void *data = bio_data(bio);
diff --git a/drivers/lightnvm/pblk-rb.c b/drivers/lightnvm/pblk-rb.c
index 74c768ce09ef..05e6b2e9221d 100644
--- a/drivers/lightnvm/pblk-rb.c
+++ b/drivers/lightnvm/pblk-rb.c
@@ -355,7 +355,6 @@ static int pblk_rb_sync_point_set(struct pblk_rb *rb, struct bio *bio,
{
struct pblk_rb_entry *entry;
unsigned int subm, sync_point;
- int flags;
subm = READ_ONCE(rb->subm);
@@ -369,12 +368,6 @@ static int pblk_rb_sync_point_set(struct pblk_rb *rb, struct bio *bio,
sync_point = (pos == 0) ? (rb->nr_entries - 1) : (pos - 1);
entry = &rb->entries[sync_point];
- flags = READ_ONCE(entry->w_ctx.flags);
- flags |= PBLK_FLUSH_ENTRY;
-
- /* Release flags on context. Protect from writes */
- smp_store_release(&entry->w_ctx.flags, flags);
-
/* Protect syncs */
smp_store_release(&rb->sync_point, sync_point);
@@ -454,6 +447,7 @@ static int pblk_rb_may_write_flush(struct pblk_rb *rb, unsigned int nr_entries,
/* Protect from read count */
smp_store_release(&rb->mem, mem);
+
return 1;
}
--
2.7.4
next prev parent reply other threads:[~2017-09-15 12:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-15 12:25 [PATCH 00/11] lightnvm: pblk: cleanup Javier González
2017-09-15 12:25 ` [PATCH 01/11] lightnvm: pblk: use constant for GC max inflight Javier González
2017-09-15 12:25 ` [PATCH 02/11] lightnvm: pblk: normalize ppa namings Javier González
2017-09-15 12:25 ` [PATCH 03/11] lightnvm: pblk: refactor read lba sanity check Javier González
2017-09-15 12:25 ` [PATCH 04/11] lightnvm: pblk: simplify data validity check on GC Javier González
2017-09-15 12:25 ` [PATCH 05/11] lightnvm: pblk: refactor read path " Javier González
2017-09-15 12:25 ` [PATCH 06/11] lightnvm: pblk: put bio on bio completion Javier González
2017-09-15 12:25 ` Javier González [this message]
2017-09-15 12:25 ` [PATCH 08/11] lightnvm: pblk: allocate bio size more accurately Javier González
2017-09-15 12:25 ` [PATCH 09/11] lightnvm: pblk: improve naming for internal req Javier González
2017-09-15 12:25 ` [PATCH 10/11] lightnvm: pblk: refactor rqd alloc/free Javier González
2017-09-15 12:25 ` [PATCH 11/11] lightnvm: pblk: use rqd->end_io for completion 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=1505478339-13089-8-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 \
/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).