From patchwork Wed Dec 20 17:21:55 2017 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: 10126041 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 0D6BF60245 for ; Wed, 20 Dec 2017 17:26:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA69829204 for ; Wed, 20 Dec 2017 17:26:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF411294B1; Wed, 20 Dec 2017 17:26:08 +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=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 80E4F29204 for ; Wed, 20 Dec 2017 17:26:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755060AbdLTR0H (ORCPT ); Wed, 20 Dec 2017 12:26:07 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35047 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755995AbdLTRWa (ORCPT ); Wed, 20 Dec 2017 12:22:30 -0500 Received: by mail-wm0-f66.google.com with SMTP id f9so11237529wmh.0 for ; Wed, 20 Dec 2017 09:22:29 -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=mr962C2H6LERqzo2jNq3jM1c8lPSxMY5GjMoo4jVaMw=; b=uD39sn6J2AY7MgUhNE/bPvHHTX5jNIs1n0sMYEXf+y7cp4+QzfoRNOApkek1hSxds0 EdkEy0gQH6I3Sf1aydsTpGy065jF9uA3rULcMAgPuTVCbfjFJG9nottkc5LZk7m3vyJI Q03/L8+4sS1cDIsCjBotOQZ1PahmoO6aXTBbM= 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=mr962C2H6LERqzo2jNq3jM1c8lPSxMY5GjMoo4jVaMw=; b=Lgjr+q7m6TSWgEpOSauw9QyCf6KEcqb3IeqzBGALSSwxGOz03tOfhoWokD5u0X03hI AcEuJS/Y5Ys63EqE2CuCRC4mUvNMmItqksD4Efos6ezWfy2ZLo0siGdJr00FA1j3oK1L ER+LGX6D23Mefk/Zcyq3jov6aBfhjHYAskVd+psShS/d6je5DYyN3q3r9YhDoRdcUSVZ 43YUd8Ziy7mXewzuEJzEML9aEHF39q8h6vx7wCTBzsSrch2cjDmPhHbeO8IsowskDBx6 kpE1n9quarXGSml3IbPHQ028cJ0rLPDCjWnw/LblhUEVdGuQosl8aYK1ZHBkkNx1eaLL 5k7Q== X-Gm-Message-State: AKGB3mI6vgBTMgxypWC8d9fCzmJEaq+jn77q4NBw2Dp6mQDeOAQp1NcX haVFdRe1Rz6X7O3zP+UcnSlGsxOk X-Google-Smtp-Source: ACJfBouXDvvh2tNs46lN+EYsz5UHmvh9FZE4U0Xy/4E/wyBY+iZ43RmxTdaGNYvfxgHraoJCl+t8Hw== X-Received: by 10.80.138.199 with SMTP id k7mr6400956edk.229.1513790548670; Wed, 20 Dec 2017 09:22:28 -0800 (PST) Received: from skyninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id 26sm15339120eds.67.2017.12.20.09.22.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Dec 2017 09:22:28 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hans Holmberg , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 15/25] lightnvm: pblk: prevent premature sync point resets Date: Wed, 20 Dec 2017 18:21:55 +0100 Message-Id: <20171220172205.26464-16-m@bjorling.me> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171220172205.26464-1-m@bjorling.me> References: <20171220172205.26464-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 9a4100c..3d33d77 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,