From patchwork Wed Sep 6 10:51:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= X-Patchwork-Id: 9940369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E9000602CC for ; Wed, 6 Sep 2017 10:54:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8EBB283DA for ; Wed, 6 Sep 2017 10:54:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD5D828556; Wed, 6 Sep 2017 10:54:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77925283DA for ; Wed, 6 Sep 2017 10:54:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753375AbdIFKyO (ORCPT ); Wed, 6 Sep 2017 06:54:14 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:36235 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753362AbdIFKwu (ORCPT ); Wed, 6 Sep 2017 06:52:50 -0400 Received: by mail-wm0-f49.google.com with SMTP id i145so28015795wmf.1 for ; Wed, 06 Sep 2017 03:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iwAVdZg6xe/jqh/0fckGD/Wr4BC8RmqOW1jvEhkF0eE=; b=nfRZg32XCyZ/DdGlUMjL43YV6bQw66rj2csosIILCVpRGoW6C/6j01xPgE87PLJ1rY H4nKSUNb2nuTwp1nW1Zi/Ax/3ikPFhcofgW6lFkEg3sE3e5BWoH3x5IJ3+RIpLR8d4bz CAX4YBxAxeMGqH7IoGXNH7km8l4hXST5lnCnBmhdN3LILR4LAxYCU3yxRskXObuIt4it xS9NrYKz8hUZKkqN8we6ApJc3arotBbeFHjXbYJ/vsltqhyOdBkCUCUHgeY4sI1UCLDE /z1zuaPCj+im10s6YZAdAcVb819n7MzYxo2yLLNoNUeIVMgWQcErKO1haUNy1cjxML5N UCrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iwAVdZg6xe/jqh/0fckGD/Wr4BC8RmqOW1jvEhkF0eE=; b=t4W0TaARC3Hyh8TtNi2iWkLY10SSF7NHxdx4IslXvPucIATg+sXrw/TkxMjD5Mfq3u 4MKbbuJM1hRgae8eeYR9a8FzWGa/gel6GmcTv0vu+6IEOCnWry/3zsrC1cd0X/msBi4J +2h7YG103y927QFTsFi0le1+K8a1Kw4oC9oY2UOwTsxxYPaEx3p/zc3iZYmP7SWSRKQG 0ZMa9RSTB2yZXKo0EwUFetmKD2h3OUXqAPVgTqu9GX5dQSeWnBv17bgFD9VWYS0qeed6 wv7atxdEYOtNlzwr/kOCrFKkQxKlKw8hMV+D0Wz6i05I0xTqTmnHLgcDSqwrfxyBTkdy Jb9A== X-Gm-Message-State: AHPjjUgG4SXjArqvUXUHOHpNdAhpd2QszMy9VR5JmtZfP6iTA3GNa+qj wDOUXzjcbDHVMU06 X-Google-Smtp-Source: ADKCNb57uWKn6q3F5h62EU2ZStkZChTGC8cebmXo/SrDTEJkblfT4SXQ5P9mn4HneWT0Vjrk8ccR4A== X-Received: by 10.80.225.194 with SMTP id m2mr5530961edl.216.1504695169572; Wed, 06 Sep 2017 03:52:49 -0700 (PDT) Received: from uHalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id b8sm1044007edi.46.2017.09.06.03.52.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Sep 2017 03:52:49 -0700 (PDT) From: "=?UTF-8?q?Javier=20Gonz=C3=A1lez?=" X-Google-Original-From: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= To: mb@lightnvm.io, axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 14/18] lightnvm: pblk: simplify path on REQ_PREFLUSH Date: Wed, 6 Sep 2017 12:51:07 +0200 Message-Id: <1504695071-25928-15-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504695071-25928-1-git-send-email-javier@cnexlabs.com> References: <1504695071-25928-1-git-send-email-javier@cnexlabs.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Matias Bjørling --- 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; }