From patchwork Wed Feb 21 08:03:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 10231385 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 D365760209 for ; Wed, 21 Feb 2018 08:04:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5E0A289A6 for ; Wed, 21 Feb 2018 08:04:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA86428A69; Wed, 21 Feb 2018 08:04:02 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI 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 5CD8A289A6 for ; Wed, 21 Feb 2018 08:04:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751841AbeBUID7 (ORCPT ); Wed, 21 Feb 2018 03:03:59 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:33663 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751810AbeBUID4 (ORCPT ); Wed, 21 Feb 2018 03:03:56 -0500 Received: by mail-lf0-f65.google.com with SMTP id f19so1085821lfg.0 for ; Wed, 21 Feb 2018 00:03:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B2jNg5JY8Ad8eSsHbnZfQNaR4PjIMPX+beTxiwG4FQA=; b=zRJkrLAluF7uivycu6hd4z4YfYxpuAa9Xn0TSb/vDMzWUPnJJ5Wm44X2J2aMDOTZh8 kkxxhZ8FqH308yv4ougS9HG0e2PYWA2NeVCj//v6vj/DmnU7eLElpXkYSAEEAWlESWxr QE2Taft2P0Crz/TOl3r6FT7QSfkAz4WE+5gSqVLKe90jOtES/kCOJpQmiC4r/9WNKRrq za3RKP9px69rKmiUtgKzGfQoQSKw9ZbilD1S2+Krb7mtaibu6yscZ2MWNjMFn0Nwn3Xj dJPOm+Q5I9moZIZevFuBfa9GaTvONNFyLUXDWZpCYd6q9oGtfUMPAszWf0jNXZLXvSni 2Suw== 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; bh=B2jNg5JY8Ad8eSsHbnZfQNaR4PjIMPX+beTxiwG4FQA=; b=XTw9CKynXWKPC5HBEDFFlbUj5EmMBOBAZa7QIudlvnUO0i1R0SaFwohwa3BsEjJ6Gy TBT5UwcC6cmHdT0cMSmkz6y0o1JI6SEtW+Xl3FGizJuayQkE+hwG8UYAooP1l44x+xyd 3NMziXIuVn7l/ScBzO5YnEDK/6l/MI89WjkKFobzrToLWjJ8cLvmZma0iA51H3TmVYfD b8qvKt1EQrGTb3F8iPpmz2OZqnrRdX50rUQSLhxs/1iJVcI2D5vqywIDxBEKUDZ5LJO+ veey50+3RBTFlwLK84PIZKxBBcjXa32ATtmlQUXeDW7EeFSw6EaNsNLwbixG7dXgBM8D cp5w== X-Gm-Message-State: APf1xPBRl3i8L6BhiFyVcqqIOPJoDHar8TzWx9rKG/6idCExlMw1Nhl5 scCCInuUSpruRaF6EUdcxHzTyGRSgwM= X-Google-Smtp-Source: AH8x224yjtwhXGbkZuA2MQwCgWuyO8MvybMGtPugf3oFgR0gBYQrBNzOegh3jyhVI8tfitS4Z++7nw== X-Received: by 10.46.99.130 with SMTP id s2mr1621731lje.17.1519200235174; Wed, 21 Feb 2018 00:03:55 -0800 (PST) Received: from titan.bredbandsbolaget.se (c-b9b6e655.03-91-6d6c6d4.cust.bredbandsbolaget.se. [85.230.182.185]) by smtp.gmail.com with ESMTPSA id k8sm13417ljk.63.2018.02.21.00.03.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Feb 2018 00:03:54 -0800 (PST) From: hans.ml.holmberg@owltronix.com To: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Cc: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg Subject: [PATCH 3/3] lightnvm: pblk: prevent race in pblk_rb_flush_point_set Date: Wed, 21 Feb 2018 09:03:01 +0100 Message-Id: <1519200181-10886-4-git-send-email-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519200181-10886-1-git-send-email-hans.ml.holmberg@owltronix.com> References: <1519200181-10886-1-git-send-email-hans.ml.holmberg@owltronix.com> 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 From: Hans Holmberg 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 --- 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);