From patchwork Thu Mar 29 22:04:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10316569 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 5383060353 for ; Thu, 29 Mar 2018 22:13:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BF1E2A534 for ; Thu, 29 Mar 2018 22:13:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3063A2A539; Thu, 29 Mar 2018 22:13:55 +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=unavailable 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 B63892A534 for ; Thu, 29 Mar 2018 22:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751935AbeC2WNx (ORCPT ); Thu, 29 Mar 2018 18:13:53 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:33178 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752500AbeC2WHO (ORCPT ); Thu, 29 Mar 2018 18:07:14 -0400 Received: by mail-lf0-f67.google.com with SMTP id x70-v6so3501660lfa.0 for ; Thu, 29 Mar 2018 15:07:13 -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=cr00/NF7a0kzePwtVBcZqiTThHHZMAsnEL4r+DoxeI4=; b=LdlPuf4PNiUtscU1gzrpCX5NTIPTzhBlIjBwzjk7SPfHz0saLPKjFSWzQmgVYFWNiK Kxbz3R9gyZ6IeLosHwek44IjkoGsFaOKgpXPJ949l715FA8Gk65V0OZ2yuQW+FHSoAFZ N5TpGkRL8+k84h0HUnjsph2SNmgupPgyl/a3S1C1EqCl+g2ywVaYleFGvo5t/0JQkknc X0nS40uWUMNkSQO8OPlZo2hP/QP1vVMOnatYa1rzGqB0HmIw3r8SvNY8rYhsC9qhHREv AF6MAwxebARGcUIDUvKDYlxNdq7OfkNqbh5PEXkP8sPJ5+K0b63Swg4X3MKtBWd0z8p7 Pn2g== 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=cr00/NF7a0kzePwtVBcZqiTThHHZMAsnEL4r+DoxeI4=; b=MAFd+LmdWgJF0UpjPk3odWGOnXOygiyDg7c1KLDYUkPd+au3wdCARG2nBMD28OsHlX FvckKDNa9JfSg9PTrVD2VSrzBDAaV329P2cRkfQRUlDkhcuTKOirHlg2DAWUnb5Ry5Yv PEh+JjU2WSlB6uv8k1xc89rqpOfvIiMJ88RpjmntRuI9MrY9H1ELJT7+3yDa78hdol6j xaegn3anziXnRmsTalI8WDtnebh+2yYZJKqcHj+W44HafhnkCzyKH42jlQ1JVf2dxivE f3Z02wh+auxH4l34n30yH2WMrN5743h3ql0ZANW8PApQ3Yg+qttIREad9LI4lFbefznr ufEQ== X-Gm-Message-State: AElRT7Fxl87obl1GOb+9dGAkyxE38scGIQDUAbDR/WGGWXF+k+DIBDrc j71Ub8/880AGX03BceOW/Oe4GA== X-Google-Smtp-Source: AIpwx49w0pi7M/UdNkS5caoNztXIeH2c21Y9d2qFOHbn3yh8LI76oz3h4U1QKgKj0m1XO3QnAvtd0A== X-Received: by 10.46.113.17 with SMTP id m17mr6380258ljc.114.1522361227913; Thu, 29 Mar 2018 15:07:07 -0700 (PDT) Received: from Macroninja.cnexlabs.com (x1-6-a4-08-f5-18-3c-3a.cpe.webspeed.dk. [188.176.29.198]) by smtp.gmail.com with ESMTPSA id i89-v6sm1365508lfk.12.2018.03.29.15.07.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Mar 2018 15:07:06 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, keith.busch@intel.com, javier@cnexlabs.com, Hans Holmberg , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 11/37] lightnvm: pblk: prevent race in pblk_rb_flush_point_set Date: Fri, 30 Mar 2018 00:04:58 +0200 Message-Id: <20180329220524.30363-12-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180329220524.30363-1-mb@lightnvm.io> References: <20180329220524.30363-1-mb@lightnvm.io> 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 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 Reviewed-by: Javier González Signed-off-by: Matias Bjørling --- 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 8b1434060fb3..52fdd85dbc97 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);