Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3419293pxf; Mon, 29 Mar 2021 01:30:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcotkajncrdInhUFuB+Y5P5PyZm20FBSU0hsHi6sPrE0awvcijAG3sWVBCyqxga0ogiXpm X-Received: by 2002:aa7:c5cf:: with SMTP id h15mr17962118eds.190.1617006623063; Mon, 29 Mar 2021 01:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617006623; cv=none; d=google.com; s=arc-20160816; b=l65RoPyXwO1fP2Gq+zhTol7LgVJw9Mxp+hqKaS/ODSV8tULwqXGuE9IJqXHNgUrOuG vMXauOph8YfLuJhMpF3ZhnG0XRFo9ntrI6+G3UD3dC8IqYtSyJHdvvuUuep1ZmcIUKE/ Uc2VkCTW3eAwifAed1O31t8+lz8Suq/vIh29gQ87eUvR/vCfqOBx1Pb8TDrR54o3KJna S8DzQX6fLfL6er3jFE8dCSh2Zw9/4h0fCkU09vrAUwV7MPbSCA8kRwKueiQnJCBbowZX e5UqW1ybBRRpDc4+gLvmAb+rfjehWMJyQO/5WNSIeEzg5w0SHmh1zsOckQrlz3HcJ4Gx 9eig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DMvVF7HMMkrucmWdPgV7xP7o2rS34Eb+OVGi1bR2VJM=; b=oJYJPGgus7vSwLe8rcQ3f/CEooKxy7x9xSgB290DGbwxkxqyI8U7HF1PjRvrgIMnan didOrsxem+pOY4QUf/uqIN7DMizWAlJf1wwGZsuZRnAj4N5taqYusEqQhaRW1yJTo3em w9sESLZG26NRgNgeylHzpeQEGHvVcESBerfs5TTLfh9s9t0F1acG2EcDcGh9/mSLS9ht 9EjRPoQ7zsnYFFma1cTODbyL27td6+IvG2kQwv0doS/vYY00GKORff9aXsW8U8ic2mi7 pLIHHPQe8KX0w0U1uTCnExk0+rLA5UhqjM72/L5mKIGLcqd+lZw1OWpFdNYh2LYAvAjC 6mHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UYlkXq0Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a7si14306421edb.607.2021.03.29.01.29.55; Mon, 29 Mar 2021 01:30:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UYlkXq0Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234644AbhC2I2w (ORCPT + 99 others); Mon, 29 Mar 2021 04:28:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:34298 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233010AbhC2ISW (ORCPT ); Mon, 29 Mar 2021 04:18:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9DF816044F; Mon, 29 Mar 2021 08:18:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617005901; bh=Vm04plOsjhlfLiwtFfQDIF+xCKzVZSCaeinJiKu6Zt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UYlkXq0Y+kbZ7pMrhIX50SXSn3IXqg5j2xCQxEzOjXaURdEL2EuLIAdZ00pHFf9pE RFlGZegIggETFqXe59PMtEDV3qw5z6levi5mRgMd9IssltYer4rVmlWj/BcygsWFhd bC1WzlW4Z3n9LR6qBFGl08Ush4khbWxuDtb6aHEs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hannes Reinecke , Keith Busch , Sagi Grimberg , Daniel Wagner , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.10 045/221] nvme: simplify error logic in nvme_validate_ns() Date: Mon, 29 Mar 2021 09:56:16 +0200 Message-Id: <20210329075630.675406720@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hannes Reinecke [ Upstream commit d95c1f4179a7f3ea8aa728ed00252a8ed0f8158f ] We only should remove namespaces when we get fatal error back from the device or when the namespace IDs have changed. So instead of painfully masking out error numbers which might indicate that the error should be ignored we could use an NVME status code to indicated when the namespace should be removed. That simplifies the final logic and makes it less error-prone. Signed-off-by: Hannes Reinecke Reviewed-by: Keith Busch Reviewed-by: Sagi Grimberg Reviewed-by: Daniel Wagner Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index de846aaa8728..fbe2918ade78 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1371,7 +1371,7 @@ static int nvme_identify_ns(struct nvme_ctrl *ctrl, unsigned nsid, goto out_free_id; } - error = -ENODEV; + error = NVME_SC_INVALID_NS | NVME_SC_DNR; if ((*id)->ncap == 0) /* namespace not allocated or attached */ goto out_free_id; @@ -3959,7 +3959,7 @@ static void nvme_ns_remove_by_nsid(struct nvme_ctrl *ctrl, u32 nsid) static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids) { struct nvme_id_ns *id; - int ret = -ENODEV; + int ret = NVME_SC_INVALID_NS | NVME_SC_DNR; if (test_bit(NVME_NS_DEAD, &ns->flags)) goto out; @@ -3968,7 +3968,7 @@ static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids) if (ret) goto out; - ret = -ENODEV; + ret = NVME_SC_INVALID_NS | NVME_SC_DNR; if (!nvme_ns_ids_equal(&ns->head->ids, ids)) { dev_err(ns->ctrl->device, "identifiers changed for nsid %d\n", ns->head->ns_id); @@ -3986,7 +3986,7 @@ static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_ids *ids) * * TODO: we should probably schedule a delayed retry here. */ - if (ret && ret != -ENOMEM && !(ret > 0 && !(ret & NVME_SC_DNR))) + if (ret > 0 && (ret & NVME_SC_DNR)) nvme_ns_remove(ns); else revalidate_disk_size(ns->disk, true); -- 2.30.1