From patchwork Fri Jan 5 13:16:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 10146527 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 DCFF1601A1 for ; Fri, 5 Jan 2018 13:21:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9F0E206AC for ; Fri, 5 Jan 2018 13:21:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCDAC27CAF; Fri, 5 Jan 2018 13:21:03 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 55BB326E97 for ; Fri, 5 Jan 2018 13:21:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751787AbeAENUe (ORCPT ); Fri, 5 Jan 2018 08:20:34 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:37976 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751983AbeAENQ4 (ORCPT ); Fri, 5 Jan 2018 08:16:56 -0500 Received: by mail-wm0-f67.google.com with SMTP id 64so2416229wme.3 for ; Fri, 05 Jan 2018 05:16:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jwCLm2lYVKYdemeKMhVoLt2MMy+jCqe9eKyb//YwVpw=; b=Sk+ucH3QdBAIZtz46KGwT/T1loNajGW7bEUdyEF3A1KCSZD6JkFEToqu2XSAjQUKsu m4So5l2LdrDHH5y3LOeMSzUSkECae5ks7MtFQp9GYQckdE1z7ozePrFbCh+x81bKJC+W d2xtxigpje2Va6MUNXChXhahA6IavT7br6sTg= 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=jwCLm2lYVKYdemeKMhVoLt2MMy+jCqe9eKyb//YwVpw=; b=iiYyCYU2iGL5FX+7+Wa7ys/7SoUCbsl9enTya7LJQN4dnh9oVAa25Y1MwhgXzV7tjI ta1dw7Uz37rReQCEZP6iMTqk8xvaDuifWz08RAEflyk0CC5B8Qvlkiovs07tXzVI94wb bd96EwJege3CbViIpc7Bw7KWwjlctxlGVOV644j7f/CkICCw/4pHSNJvdruMLyqFiagU TyzeeeugRuIkK/e4CMRdDs+S0TOadPc4Tz/Hm77l3hgVCDiauj2JA/ZbqLipvzvY9AHR 0kOC4vT1CGBW05eNR2f313G+cCumH8YN5zK1qJbKSN1+t8RhyG2mbUWYTVJsjKEYay/j b2cA== X-Gm-Message-State: AKGB3mKt4hzuACyyoCIQZsa2ujGBWcUSkrC7Si5P4gBeY2ptkaWa/snP XuRV6kcpFMSfEQh41hXOyRWnEw== X-Google-Smtp-Source: ACJfBov080d6wmjLZh1FjtSErT4xX3zdtWymoNL+UZS8h8TwnmegVw2pHAac+BKdNo2aTXo8LB7qGg== X-Received: by 10.80.131.101 with SMTP id 92mr4187554edh.16.1515158215290; Fri, 05 Jan 2018 05:16:55 -0800 (PST) Received: from skyninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id e46sm4228940edb.93.2018.01.05.05.16.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 05:16:54 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 15/25] lightnvm: pblk: prevent premature sync point resets Date: Fri, 5 Jan 2018 14:16:11 +0100 Message-Id: <20180105131621.20808-16-m@bjorling.me> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180105131621.20808-1-m@bjorling.me> References: <20180105131621.20808-1-m@bjorling.me> 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 Unless we protect flush pointer updates with a lock, we risk resetting new flush points before we've synced all sectors up to that point. This patch protects new flush points with the same spin lock that is being held when advancing the sync pointer and resetting completed flush points. Signed-off-by: Hans Holmberg Signed-off-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-rb.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/lightnvm/pblk-rb.c b/drivers/lightnvm/pblk-rb.c index 672ef8c..ec8fc31 100644 --- a/drivers/lightnvm/pblk-rb.c +++ b/drivers/lightnvm/pblk-rb.c @@ -367,17 +367,17 @@ 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); - if (!bio) - return 0; + if (bio) + bio_list_add(&entry->w_ctx.bios, bio); - spin_lock_irq(&rb->s_lock); - bio_list_add(&entry->w_ctx.bios, bio); - spin_unlock_irq(&rb->s_lock); + pblk_rb_sync_end(rb, NULL); - return 1; + return bio ? 1 : 0; } static int __pblk_rb_may_write(struct pblk_rb *rb, unsigned int nr_entries,