Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1993169imu; Fri, 14 Dec 2018 04:12:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/UdmOMvZkYiiefon2OaYEC5SFhfP4DdcDuOdtm0iB3BIbsFJnRkWT8etAhOE2EATaZO9NdU X-Received: by 2002:a63:b94c:: with SMTP id v12mr2464884pgo.221.1544789530598; Fri, 14 Dec 2018 04:12:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544789530; cv=none; d=google.com; s=arc-20160816; b=OzpTobHEHfYLIZVCn9i2sy2ppmGyTwUIDQrtwFmmTwVyt3vDjY4kWAGugt45eDWbCv lS2VV82zJgv0TOI9qArs66hn5aHxAKqbpfpSWOD+NzyuIO6YOe4YYr4qmY86L6UjU43l 6ykE2On/zprsjygpDAbFe1aaeBqUr/tDn0EKe/FixF9+fkqaW7KbWF2EScaI2mUMxzd6 w0D8/BM1FgJtga6sReRF+MOPqxhlsGmhA0/gLzDJvi2eUpUyPXU+qIGhRST5dSdrsC+W DlAD9ylGOsmuCKj/12x7CbF1TTK654UsCC2eM3gZVFmxnTp/zht2CfDzaCCZE4g/VakW kBXw== 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=5UCYiPtktJnASKfwaZftMraWodvFtJOPibgPRHgGht8=; b=Cl/pGbBbEFyOqOmEvSI4EGdU8KcYCq1t/RTfLmngFiqhYxxBcOpLSvG6tKAuGX1OoW 0RWD1bA03gBlSFEgnJUp/v/mMcX1u4w0BSpAoYhtJEgy45AlpXiTt/cH/CdHumU2FVoq nXkM7LZUYC7DHgPl2pSH+gecxPRdUIIj4NnvPEjNptK5s8mOQdOOzhlJTkM9Wc5eAE1V j6uJXinBIlJMtRboGHa/8X5F2t1diwVI3samGwW1qE2LH/FrKnVEQHe5tyqaIds5fTD6 c81zTcQecjrwEJ4tB6feBZaxwp8FTzk5gSSoyLrUdyyb59CdDio87FzLbZ9hrbVjuuYw mk5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PpFcDgvn; 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 j14si4085239pgi.354.2018.12.14.04.11.56; Fri, 14 Dec 2018 04:12:10 -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=PpFcDgvn; 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 S1731718AbeLNMLD (ORCPT + 99 others); Fri, 14 Dec 2018 07:11:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:57458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731707AbeLNMK7 (ORCPT ); Fri, 14 Dec 2018 07:10:59 -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 A1EF62147C; Fri, 14 Dec 2018 12:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789459; bh=M7P7K3yLUajR8BT57sKvbGkcJzeAT+GuekVPPRnIdwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PpFcDgvn0rNlKERO2M80qE7Qafk5RtDuYjowfWOODiTJJ725JW+JE7mloPt4YYIy9 MJo51yr2hvW2ZakfSkMaWvMTRKbDneRz+mDU8/GXkCuxnfwmNzbdysGck/NVoiYuZA nFMmrQ/2OIUVvdKOqqOTSCH9qFt9JXC3r9wGGJ7Y= 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.14 71/89] nvme: flush namespace scanning work just before removing namespaces Date: Fri, 14 Dec 2018 13:00:24 +0100 Message-Id: <20181214115733.184937377@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115729.658859279@linuxfoundation.org> References: <20181214115729.658859279@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.14-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 3a63d58d2ca9..65f3f1a34b6b 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2572,6 +2572,9 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl) { struct nvme_ns *ns, *next; + /* 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 @@ -2743,7 +2746,6 @@ void nvme_stop_ctrl(struct nvme_ctrl *ctrl) { nvme_stop_keep_alive(ctrl); flush_work(&ctrl->async_event_work); - flush_work(&ctrl->scan_work); cancel_work_sync(&ctrl->fw_act_work); } EXPORT_SYMBOL_GPL(nvme_stop_ctrl); -- 2.19.1