Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2688866ybl; Thu, 29 Aug 2019 11:30:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTWbWCy2GgvSEHMxt9wyKGWaxO/LfmXBVlSMFxGdLd/mq0uFl+ioCYX2+t0LWTO9vYzQmI X-Received: by 2002:a65:5a44:: with SMTP id z4mr9624642pgs.41.1567103421018; Thu, 29 Aug 2019 11:30:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567103421; cv=none; d=google.com; s=arc-20160816; b=hS2z1bYkHrmUAk2cpnlvvsFz1TjFbmupy+V2y0X+Gi9sBcd5hLv6zUccHFYiAV8YtV /zYIG8ObnZluveLm/tq8nd5D0FbBwu7l0kn3An4e14pLDNhPw6aBAOVsf+Kq+sDBvMFm UBkIrYEnH8hPcO1hir3rLb0L5TfzlxmQ7lBPSEy/d+BG3wcG+VnC8O4PYyV3lXscKYb1 YFQm477MYUAZWfG47ZJz1/1ywdnwLX06TmGd7XqRXuDWB29P2dRnxB5rDO+CHHxs2p+q dVVLV8v2kEJwX6pxOhX+JQBP0Qv79mUj1kc14xp9xrlf5VgjEGK8SGw+hqgtAzmBw+SE 6K5g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TuVGmSeGpZnd3TwS9763i73w8jixkNTCZIQBFMsCjdU=; b=ax29J53pG+jkY5JA2q8c/1pU3m2aJtYb8ioMAHY2MnsbNqK5fXLm4GQabk0Phg0fEW 9eAVQ//kJoVWmJad5/q3P9PKV8bt4z+AFbji/hTLi0ItCBNbaTItDpZZCnurztwL/0s/ QneWtqe1ZDt/Dl/92v6yoq5mLCEj9VqopKae5JBdy+7jALHoY+1GAZ3fbdFoPiR+YxqS Bw8KAi9XidwlNrvRdXvlY6qaKqKfBEl37p34PwETnZUMXAbHE6F6e5AfrbsDMDtYQgU0 tfC0AfClMU3PKgOTXxUfhFSxBCo0R2zu35an962uCiXoiqMilJqg4M7wgctqqlvVTxAe PSuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=am750hGK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si2650991pgp.423.2019.08.29.11.30.04; Thu, 29 Aug 2019 11:30:21 -0700 (PDT) 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=am750hGK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729814AbfH2S3N (ORCPT + 99 others); Thu, 29 Aug 2019 14:29:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:56778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729055AbfH2SPG (ORCPT ); Thu, 29 Aug 2019 14:15:06 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 27D2E23404; Thu, 29 Aug 2019 18:15:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567102506; bh=kCo6rtnN3uj+HRkVKB54selVGg42JXeQR2KTGbXdhjw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=am750hGKWqVrVOhuAO9brEHIGWEjdqh2tg+xQMeAoMKjGjSdRHU/uBYB6eOcKFtg5 pPmYC85rNYYwM1pdym3jHrAmeceM7rFHwG7d1+7g1gaFUns9hlTKOuaQG2Rj9nqEco 5YKq6uxFzX+oM6hg/mSECmIY8uxaog/XysxmAyco= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Anton Eidelman , Christoph Hellwig , Sagi Grimberg , Jens Axboe , Sasha Levin , linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 5.2 56/76] nvme-multipath: fix possible I/O hang when paths are updated Date: Thu, 29 Aug 2019 14:12:51 -0400 Message-Id: <20190829181311.7562-56-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190829181311.7562-1-sashal@kernel.org> References: <20190829181311.7562-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anton Eidelman [ Upstream commit 504db087aaccdb32af61539916409f7dca31ceb5 ] nvme_state_set_live() making a path available triggers requeue_work in order to resubmit requests that ended up on requeue_list when no paths were available. This requeue_work may race with concurrent nvme_ns_head_make_request() that do not observe the live path yet. Such concurrent requests may by made by either: - New IO submission. - Requeue_work triggered by nvme_failover_req() or another ana_work. A race may cause requeue_work capture the state of requeue_list before more requests get onto the list. These requests will stay on the list forever unless requeue_work is triggered again. In order to prevent such race, nvme_state_set_live() should synchronize_srcu(&head->srcu) before triggering the requeue_work and prevent nvme_ns_head_make_request referencing an old snapshot of the path list. Reviewed-by: Christoph Hellwig Signed-off-by: Anton Eidelman Signed-off-by: Sagi Grimberg Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/nvme/host/multipath.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index e942b3e840687..4f599366bc5ae 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -356,6 +356,7 @@ static void nvme_mpath_set_live(struct nvme_ns *ns) srcu_read_unlock(&head->srcu, srcu_idx); } + synchronize_srcu(&ns->head->srcu); kblockd_schedule_work(&ns->head->requeue_work); } -- 2.20.1