Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2020030imu; Fri, 14 Dec 2018 04:36:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/ViEJmz7OIO3rMAwpT+3kncAcqI8jQlmx9LJKc4E9bU1lmFc6jVO2qhOAT/di7+b4D3uJU+ X-Received: by 2002:a17:902:bf44:: with SMTP id u4mr2739322pls.5.1544791015974; Fri, 14 Dec 2018 04:36:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544791015; cv=none; d=google.com; s=arc-20160816; b=gW9fVeI4512oasVV5JReKTHAr395xQhhZ6WpDNFLnyO8L4Dzc6arVJ4rHu9HhuZ/jv FLFXLxe3LFEoyGbpNOmFd86W5+FKWrnKqDY6ndXIigC7xgss+wfZQOmJ8GWsDJdmeXKl j2Wv9JGPi8gT5WK84tDUzLffywfMhletVedVdCcRgisRAueMCtcfQP9fhFxmWrFNxM91 eXkU36oX0nvr9wr/NRAE+ztuzNjgyXORMwG5QusJXoxmMS3/wOO5H+9Ppngow/x96yZf JQMThHRHTyfrC6ayP4b0IEj2kfmAYR9U+XhClxAnj1+S6LjVlokOhXpGhwVJNuOTymHr 4LuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nkGv53mBkqn8TMis0l9WUag3LihHw0dw4tm99VzJ0eY=; b=YzU0doqJfQXevTCUYgP7SgeABXpkb95FZ+3TaH48WA9GztRz85sEYP960AaJEFchqm 7va9HPxx1ql2sS+nR3bJibF321OtuOeYAgOg6ApnNOHESufQOJ2uqSaui79T7CQBWjMG cEKRf9BwAVteOpE7RAGXWSQ68xWd0yIBKzJXW9y690Izhy3/GCsqPa3tzmR3ECNrLD9y x45FPXStzcNQTn1I1IFja4NOkF6eO4wE1gSd9jknAoKdZztTl038aJx2gdDvaJuMM10N 78phTybocOZqRUtsOifszG3WxSySns8l9mzS6TElO+FZB07EzWdyon/I2npwQhHu2Hba gERQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bLJEuytN; 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 u8si3887933pgl.25.2018.12.14.04.36.41; Fri, 14 Dec 2018 04:36:55 -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=@kernel.org header.s=default header.b=bLJEuytN; 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 S1730579AbeLNMfu (ORCPT + 99 others); Fri, 14 Dec 2018 07:35:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:52272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731044AbeLNMHH (ORCPT ); Fri, 14 Dec 2018 07:07:07 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E3CD021486; Fri, 14 Dec 2018 12:07:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789227; bh=isQwEs0DvhaAqNQwOpr/yOGvX4J1VhSo7w40vMPoLx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bLJEuytNHRxvRYIQvejO0w2DAqsAVFNKouRhoMUhI2w5eoTok+oj6SRfERn65zJBb Njb9ug1V+F5nNh7dJ7zJVZ9JtZknXuvdM4tnckqbbJe8pO8pKLezA1qw1iCfbfbGGH Ff6dZ2wI0Jw4KF6br/FWBVbFVZ2kXIAQQfBt00j0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ming Lei , Sagi Grimberg , Keith Busch , "Ewan D. Milne" , Christoph Hellwig , Sasha Levin Subject: [PATCH 4.19 121/142] nvme: flush namespace scanning work just before removing namespaces Date: Fri, 14 Dec 2018 13:00:06 +0100 Message-Id: <20181214115751.869327188@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115747.053633987@linuxfoundation.org> References: <20181214115747.053633987@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit f6c8e432cb0479255322c5d0335b9f1699a0270c ] nvme_stop_ctrl can be called also for reset flow and there is no need to flush the scan_work as namespaces are not being removed. This can cause deadlock in rdma, fc and loop drivers since nvme_stop_ctrl barriers before controller teardown (and specifically I/O cancellation of the scan_work itself) takes place, but the scan_work will be blocked anyways so there is no need to flush it. Instead, move scan_work flush to nvme_remove_namespaces() where it really needs to flush. Reported-by: Ming Lei Signed-off-by: Sagi Grimberg Reviewed-by: Keith Busch Reviewed by: James Smart Tested-by: Ewan D. Milne Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 0ba301f7e8b4..b7b2659e02fa 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3308,6 +3308,9 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl) struct nvme_ns *ns, *next; LIST_HEAD(ns_list); + /* prevent racing with ns scanning */ + flush_work(&ctrl->scan_work); + /* * The dead states indicates the controller was not gracefully * disconnected. In that case, we won't be able to flush any data while @@ -3463,7 +3466,6 @@ void nvme_stop_ctrl(struct nvme_ctrl *ctrl) nvme_mpath_stop(ctrl); nvme_stop_keep_alive(ctrl); flush_work(&ctrl->async_event_work); - flush_work(&ctrl->scan_work); cancel_work_sync(&ctrl->fw_act_work); if (ctrl->ops->stop_ctrl) ctrl->ops->stop_ctrl(ctrl); -- 2.19.1