From patchwork Tue Sep 1 15:09:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 264763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78119C433E6 for ; Tue, 1 Sep 2020 15:31:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B4622100A for ; Tue, 1 Sep 2020 15:31:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598974262; bh=TTNgKm9PeOPF0Su/rsa3v9hNhh3d4aOaKz6os1RirAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=cFmBt2Ca8z5WgdsIOFapBiYSTCRb5oAOBrQude1Wjt04PCUjY5kX2Y8g1KOWW1RKa G0WM7HhMxwykoUWswZsfSEnKWadgOVxzc34K/PJehUWoH4CLrGmOR0RFiAlYYpSjux znfVvFic9HApQMbFeKHelV0x4REAM31Mwd6ivYMM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730653AbgIAPbB (ORCPT ); Tue, 1 Sep 2020 11:31:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:33548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730649AbgIAPbA (ORCPT ); Tue, 1 Sep 2020 11:31:00 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 83915206EB; Tue, 1 Sep 2020 15:30:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598974260; bh=TTNgKm9PeOPF0Su/rsa3v9hNhh3d4aOaKz6os1RirAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=apn27nJbfQWB6UJNB9qcdyNoNLnFsXFo4ucUDlEW8jXkMVFU/sy5U6uGWP3nJH7Li /wJGxD3VfQYF85i+FhG+kmN191xS+Pj/0JmzhU5Nwm/0yP47m2dURUPQ2qYodEb6BG 8fgUXxCVTlzIOdsfIZN+9dVrPsmmFAq4Pm3WCc1k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Wilck , Martin George , Keith Busch , Sagi Grimberg , Jens Axboe , Sasha Levin Subject: [PATCH 5.4 108/214] nvme: multipath: round-robin: fix single non-optimized path case Date: Tue, 1 Sep 2020 17:09:48 +0200 Message-Id: <20200901150958.159507561@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150952.963606936@linuxfoundation.org> References: <20200901150952.963606936@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Martin Wilck [ Upstream commit 93eb0381e13d249a18ed4aae203291ff977e7ffb ] If there's only one usable, non-optimized path, nvme_round_robin_path() returns NULL, which is wrong. Fix it by falling back to "old", like in the single optimized path case. Also, if the active path isn't changed, there's no need to re-assign the pointer. Fixes: 3f6e3246db0e ("nvme-multipath: fix logic for non-optimized paths") Signed-off-by: Martin Wilck Signed-off-by: Martin George Reviewed-by: Keith Busch Signed-off-by: Sagi Grimberg Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/nvme/host/multipath.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index 484aad0d0c9c6..0a458f7880887 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -249,12 +249,17 @@ static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head, fallback = ns; } - /* No optimized path found, re-check the current path */ + /* + * The loop above skips the current path for round-robin semantics. + * Fall back to the current path if either: + * - no other optimized path found and current is optimized, + * - no other usable path found and current is usable. + */ if (!nvme_path_is_disabled(old) && - old->ana_state == NVME_ANA_OPTIMIZED) { - found = old; - goto out; - } + (old->ana_state == NVME_ANA_OPTIMIZED || + (!fallback && old->ana_state == NVME_ANA_NONOPTIMIZED))) + return old; + if (!fallback) return NULL; found = fallback;