Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1683535lqp; Mon, 15 Apr 2024 13:51:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVJgOKKM3N+O8luhWVslWbYeQ9S9jXmrfvQaZEPuRRj4lDT3iawXrxYgxmvIKXClo+nqSkN+Rh4ZO2djoDYrLZabZjVB7Q17Umb4hZJhg== X-Google-Smtp-Source: AGHT+IFn9v+PA8yx5entKBq2Y27wOJY7sujEAhW49dzVfw0DAzdygWvRdY4YXs0A0n0z3rcA5OFs X-Received: by 2002:ac8:590b:0:b0:434:f1f5:3c4d with SMTP id 11-20020ac8590b000000b00434f1f53c4dmr13503043qty.2.1713214290064; Mon, 15 Apr 2024 13:51:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713214290; cv=pass; d=google.com; s=arc-20160816; b=r8qE77s20WRntLtfv9eI3ENPqT/XQ+FCStDT/dKQmsgTKDL6fcEsH6wPBO4xM+kDa5 QQxkQTjiKnN6cuPAAqpcRtU+PwpBNOmi9bjC6IrrETzpwWRzhqEnAXe+NPehp2C7lDq0 90GVqE6zqErZKJ22BYE8jY7iE4E9VIGttR2GfdNN/6bvTePHeq66oWHF/WHV6jKDSlBb xgeoTgyTzHYNHW0mnzHfEThXSvuqnk2fbwbVL5f0WDXA9Y6ryyZf/cf0Lw1Q32cklZXP ChaAJCm1+yky4MLbJ+iCMIaKhmtbuxYtPtHZAnKio+t5vk8sw+FZqSLZtknjv4BOGJkT 9Drw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=mCI08UxRqRdgLWPnXTXShrMmNNIATJiipTj4VitlO2E=; fh=CqE8nR7fEtXTKjnptFLV2LfrLndDVtKie4WbXSQdnWM=; b=bll6Oa9djS9l87cQY4IgftTAUenDZ0t6GhPUPI64uZxLKhRSdhJgjaV6bLLAQ52yt3 Fvf0IMEx+kCGpI805mDR4mgKIuxxGh6eV10SoHLHONpnxroW8FQY7l/4s3helndThnbq ImTHALG3yWsORTx0H1csx0FDpEwkG7TJN3Xzo9Rj2uqi+ucArQJrPI5FI69q7eqYSKbm Z97PB/Q6HNUXI/61Mij0A5Wf7iyk/DK1qIaVJHbcpW5H3nK3jIR9F8ig9Bb5DtZ5VKj7 dda+Z663aIC/kyCacRu+hHrLzJHSVD4n8QtU1iQ5x6tv3RF+4s5tKRSX7xpKhPPhuT5B E0WA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-145893-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145893-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id cm15-20020a05622a250f00b00436d10e9e84si5963073qtb.778.2024.04.15.13.51.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 13:51:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145893-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-145893-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145893-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 985901C20CBF for ; Mon, 15 Apr 2024 20:51:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDDA9156971; Mon, 15 Apr 2024 20:51:24 +0000 (UTC) Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C25B97F7FF for ; Mon, 15 Apr 2024 20:51:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713214284; cv=none; b=R77d7/ROKRvMHtstkmM+AjBkYIF+u8j0omKa2D/VCHLMa86sPcm0epJvVBCpYvoognExxToh1Ahy3rgJd6xPrqsc/Mz/VK53V3H2FVwzAm5VOcQM6hWCQkGdkv1NTOM6nOHj0jSF9Q1eQMU+a6P7+4Pton6Gie4pjQodkquT92k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713214284; c=relaxed/simple; bh=h5yR2ToXNmI+hGEQoWbQjkFb3fZNqCClbanXCKw6KzU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TQMoB0j7n1XpN53Tl5xCaot6/ntVmQkGK5cYOM4XCba8XbGNFxqM35YRNYzIuEXuT7yzkl0PJqoJl8fG/tjCvVCy11X8mw7gSWZeaqxKCntp6AMAPVMb+freMtuDWnTh/KXbX9Ksg+vfH85BkhvTQOn3EAaUdQP/a6DV4KW4gBs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=grimberg.me; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=grimberg.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-34801b1bc4aso234081f8f.0 for ; Mon, 15 Apr 2024 13:51:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713214281; x=1713819081; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mCI08UxRqRdgLWPnXTXShrMmNNIATJiipTj4VitlO2E=; b=tjxAhvPcUQHoZYFqlKA7pG/Cb0KOY/m6liKCJZIT5F7umzz2YujxQLC6kc20N2Sd/s ZHUUYNPG/zPbwef2oYetCtlH8BJQGHW3eNkGbfLqT+IB9aIr4UFgWTWFIlWMRoFrxhVi frNQzPu1459YR0pTM3U9R25bdOlt+YgNadUmL8y2Jz8uYHTzJIsp3FjfhT9FkKiwAcj9 Fz+R0oa7s5ocqdsArEOY3nwrImAOKF5hcyIiZZf8PgwS1Ee/nrF7MSRE7P1YfSkyf6Ox KAlaaHyH3sXNXGiqYYRo5nrgMfkuUDcjfuDs6My6l4M2G2QLVLH89CUO+fQutpYNpN/H N2aw== X-Forwarded-Encrypted: i=1; AJvYcCXqYBRv+tO/lSqeSkSvMDROUefNZFkR4RDcN5y02sq6ToCpZQKKs1/lvJ2rTC4sbGpFdOm19YkijOFOduyyoU0YEIfk2Awh+aONUD3+ X-Gm-Message-State: AOJu0YxJGKLn4addfWmKjGR96XdpiYe3Uq/mzA7uG76FeC2MuNfdqWVl 8Y2fPi5H42X8qNFR6HkFwf+JvL8oK1UlOFzk1PbFn4TpPfJysDW5 X-Received: by 2002:a5d:598c:0:b0:346:408d:4341 with SMTP id n12-20020a5d598c000000b00346408d4341mr8556311wri.1.1713214280910; Mon, 15 Apr 2024 13:51:20 -0700 (PDT) Received: from [10.100.102.74] (85.65.192.64.dynamic.barak-online.net. [85.65.192.64]) by smtp.gmail.com with ESMTPSA id g9-20020a5d5409000000b00343dc6a0019sm12943563wrv.68.2024.04.15.13.51.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Apr 2024 13:51:20 -0700 (PDT) Message-ID: <51fc1a3f-7166-49cf-9652-a95bdc5d2119@grimberg.me> Date: Mon, 15 Apr 2024 23:51:19 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 5/5] nvme-fabrics: handle transient auth failures To: Daniel Wagner , Christoph Hellwig Cc: Keith Busch , James Smart , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org References: <20240415124220.5433-1-dwagner@suse.de> <20240415124220.5433-6-dwagner@suse.de> Content-Language: he-IL, en-US From: Sagi Grimberg In-Reply-To: <20240415124220.5433-6-dwagner@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 15/04/2024 15:42, Daniel Wagner wrote: > Retry authentication a couple of times to avoid error out on transient > errors. E.g. if a new key is deployed on the host and the target. At the > same time the connection drops. The host might use the wrong key to > reconnect. > > Suggested-by: Sagi Grimberg > Signed-off-by: Daniel Wagner > --- > drivers/nvme/host/auth.c | 4 ++-- > drivers/nvme/host/fabrics.c | 10 +++++++++- > drivers/nvme/host/fc.c | 2 ++ > drivers/nvme/host/nvme.h | 1 + > drivers/nvme/host/rdma.c | 1 + > drivers/nvme/host/tcp.c | 1 + > 6 files changed, 16 insertions(+), 3 deletions(-) > > diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c > index a264b3ae078b..368dcc6ee11b 100644 > --- a/drivers/nvme/host/auth.c > +++ b/drivers/nvme/host/auth.c > @@ -797,7 +797,7 @@ static void nvme_queue_auth_work(struct work_struct *work) > NVME_AUTH_DHCHAP_MESSAGE_SUCCESS1); > if (ret) { > chap->status = ret; > - chap->error = -ECONNREFUSED; > + chap->error = -EKEYREJECTED; > return; > } > > @@ -818,7 +818,7 @@ static void nvme_queue_auth_work(struct work_struct *work) > ret = nvme_auth_process_dhchap_success1(ctrl, chap); > if (ret) { > /* Controller authentication failed */ > - chap->error = -ECONNREFUSED; > + chap->error = -EKEYREJECTED; > goto fail2; > } > > diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c > index d9a73b1b41c4..6dfa45dce232 100644 > --- a/drivers/nvme/host/fabrics.c > +++ b/drivers/nvme/host/fabrics.c > @@ -573,8 +573,16 @@ EXPORT_SYMBOL_GPL(nvmf_connect_io_queue); > */ > bool nvmf_should_reconnect(struct nvme_ctrl *ctrl, int status) > { > - if (status < 0) > + if (status < 0) { > + /* > + * authentication errors can be transient, thus retry a couple > + * of times before giving up. > + */ > + if (status == -EKEYREJECTED && > + ++ctrl->nr_auth_retries < 3) > + return true; I did not suggest nr_auth_retries. Where is the 3 coming from? The controller already has a number of reconnects before it gives up, no reason to add another one. Just don't return false based on the status if it is a transient authentication error. The patch just needs to be modified from:     if (status < 0) to     if (status < 0 && status != -EKEYREJECTED Plus a comment that explains it.