Received: by 10.223.185.116 with SMTP id b49csp414258wrg; Wed, 21 Feb 2018 00:06:39 -0800 (PST) X-Google-Smtp-Source: AH8x226tRmvyWEtykNGmfIc9Hm3T/aHZigKL5Ausk9dPkFTFYFEOo+9u9K0yMC8/Xcd4O5tCMfUF X-Received: by 2002:a17:902:b582:: with SMTP id a2-v6mr2389154pls.349.1519200399605; Wed, 21 Feb 2018 00:06:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519200399; cv=none; d=google.com; s=arc-20160816; b=gNaQcSgR+Q6XJTqWLy/BAUlrFg3J8lV1JL3NY8sdn5wA7lD4+zuQ3kw+ITyXlqXvln 1SMEm+lwWYUu3wZDpkHrdCU42LnRlZj0KjSjHTA/5e06ZZ5k4jPe/mxdL9rnu8/6zJmX GKXN8v22WAJIZNNa+D6vpSms5fOTO9YNcqfFRhfqgyP4//Wtci94id9ZLvZ2nP5fkCvY mkjAnvZRM9fhzpm0kvl14kGhht6R/gAPJshsZJvdIx6iqmsMjNwdMmsOQGZ2KspVTtIK aBoAKxkT23mXjMKq8KKVlEyM1hE/q3Oyg8H7LAYFnzHLMQQoErNNru638/Ca80OED960 1IPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=B2jNg5JY8Ad8eSsHbnZfQNaR4PjIMPX+beTxiwG4FQA=; b=IqQAAZeLe2e/EZTvwRvSbnoOge4ZtQ5wZal4X1WBvyVxbv9fsvrDQCeZQJLzjrQK9D GMFn+lauHoq6SDJYKfRwISx5BLTQBMrVOX7cOp5lFee3UQxcCa2UDvxqFeex8fABbEOe 1qEiLDURwveFWgGMxLOycb5QgkSiCFNpbZuBFwQPjJQQcTnvkpG3li4Cqq8z6JEmy3hW /b++uO77ASrS1GfpzaCazP4wxybu2xTmOAzs/ycMlTRWd9iIEmmpw0YtRzvRJFVE6ct1 qS4KVozOkN44SMsilS2wjpVa0TnNa4X0HVsVt2k4kPwghlNEl3OHQ/sfATxINloK1ECP zQmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=zRJkrLAl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x33-v6si9969552plb.477.2018.02.21.00.06.25; Wed, 21 Feb 2018 00:06:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=zRJkrLAl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751911AbeBUIED (ORCPT + 99 others); Wed, 21 Feb 2018 03:04:03 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:35393 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751812AbeBUID4 (ORCPT ); Wed, 21 Feb 2018 03:03:56 -0500 Received: by mail-lf0-f65.google.com with SMTP id 70so1076864lfw.2 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=GIljPTdF36j+NP/YjC9+EVtpQv71u7zBMxUECPyPKAlVbS+UmAM8LPMHxmgomMYOrf kb99Ll0XJjH9Ugly0i4J8bn3FEiXmg4qksccS5BN/pFtOUoQGcthMivFrmZrv3YNi3eC fZLNFqDHHKX7vXQVHa1xcfSr9mHooBhWQsuQF6mDjshTjg589IK0LZUJ4SbQvKHHbZ9T TzwOfClfoZUKMlyeR4tfap7ePJT/Vx18Mgcj7voSnANNKj16EhMNByM8MMcRkGebk6Hn Qbh4AutWKRamJH8FJyZUqAGSVGG2cat4zxbeFcpw6sllUiFXLXxnIwnKh4n+Xps+aAso QXNA== X-Gm-Message-State: APf1xPCVjvhwznqOxK8AWI1JuRMGaQgf+70BbYC35Zcq6I/+ceX9DnEn 1Zqokl+ycilY5caEe4HOnFZUCg== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.7.4