From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 CB4071FB1 for ; Sat, 27 Dec 2025 10:42:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766832164; cv=none; b=sljcziK3XlYelC+VeyWA2eVggqZd9x/5LiZU+3YSGeDP/+ebvZDWzJn6wZmc7d7jiJMbpVmIMvzwroceqkDBGt/Y/njWdCxHcACKsRdQE8G/z6OKQT1XJ16l5Vrw6Jju0+iNYrwnTARgG1Y8cCwfsX+nmDr4jdkaSdLcxjc+830= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766832164; c=relaxed/simple; bh=rEx5uxIiPSAN3tlNp+oyxXBP6Y1QzioKssHjv6sWU2U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kROwDZQaA+D3kdVrUgXQm36JoqdB6G7MyCaluExXK7ROSLz6I6IUlV0FsD8B4W4xn1j1T57vCWwpQVu2WYnWkIOjMslxzK4ykPmixSWwC5VK7BuZT+Qb8ek4sK5yGD/UylyIr5EHgdi9FPD8P0/cHOmyJtSmGvfWvj5MYL6ULg4= 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.128.45 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-wm1-f45.google.com with SMTP id 5b1f17b1804b1-477619f8ae5so46316065e9.3 for ; Sat, 27 Dec 2025 02:42:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766832161; x=1767436961; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LtLBBtJhALKfBZ8r2HTslPHOEI+CfYAyFADAeQFApKA=; b=Bqs9MnwKxYeES28pOZHBAihWYDLwKQ6g3k+HLejVY1R2pr8L8KoloU9/u8K+XcAEsR DDzbzUWsf0/8O2JN07D3i+9L3KNCLzlnI+lF0MiiJ9Qiyj5NIQKmuYsVK/a9yuzzKgLq GEgHHeWYle4iMreA1sQItCz/8Fa83G+UmnL8m98taxFd5ExOc2+AzhyDArl5QkmHbjJ/ WQ2OR9lH8Q6BnYro9mLvGhg9zmdb0/tWKhxJHazfrxMbVh5adZZY402ZCtCFxWe/52LI ypi1ooGDPIz0ZiSmzfaUyKJBSKLwjMHeN3i7TaH3LUcw9Lxi+JJSEk97LEF+X+p5jkLj fg4A== X-Forwarded-Encrypted: i=1; AJvYcCWUiKo7tIhaLDvJpDCuUDcr9H+oRF+bTAT8ETea+3YbnPj5xYSHSQ9K6jeCRu5z82CVjGk3oyVInnZxO3s=@vger.kernel.org X-Gm-Message-State: AOJu0YwvJAFYgcxpruwHzOaa72EbTt605BZjRUC7fabuY8fbXl3u9iJR wLolumEkgUpQKdRhkEvwg5k//GDaH75tqWy8Wavlm3YCRdNxmD42PsG/PmSePh5e X-Gm-Gg: AY/fxX79NwX0ApXT3vGrjO6b5Q59ktQ6ieeEwFgqlLsPkXudfDL92iaag1XV7Q6gtI2 vfyG14Ax9JUBfu4Ff7udhJhVmHCjjAqsq/dVrvv3GB99oyG/EjPMrfB4IEwnoYrGQzS7ICYxujG aCyXUWb43ScWqXD6aeu9IPBX9wEDQF9Bg02ps+C3vzpMp5r2CwQ2q9SxBmzCqDZ+PgmJr6n22tj D1V7FhiZ55+pnyjuI67vUzifUMKDSRhFguBylWO2oz1y5ZxVnXWOS9aVzhUG91tr8FcECczG6UX C+dgW9vR9IKPqViMNqUQLm5CcLWBw7ySXUKQMa9Ek0zy2Yr9Qz/5Tgxapat5z3ou3/fhhOunqMs OTwdGQ5DGV9ZAl1F6B0FuMh24aBvEYIupjrVhnNacC1uFc6x8ZTFAp1gsWDF1Qsy9H95aFEUNdi Tr17oEb523BDwD5rS6svDtYoLOTjiQK7E/aXFqlVkevJ0= X-Google-Smtp-Source: AGHT+IFifuKoIXgl+8sbJHAXGbEeChOXwycxKAlvotTjNABbq8Myxb19pNbT8slbgYzuKWDeS2s9sw== X-Received: by 2002:a05:600c:1550:b0:477:9fcf:3ff9 with SMTP id 5b1f17b1804b1-47d19589575mr261915915e9.27.1766832160985; Sat, 27 Dec 2025 02:42:40 -0800 (PST) Received: from [10.100.102.74] (89-138-76-94.bb.netvision.net.il. [89.138.76.94]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be3a203d4sm189837855e9.1.2025.12.27.02.42.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Dec 2025 02:42:40 -0800 (PST) Message-ID: <91ed7327-bf4c-4912-a490-ce7606b854a7@grimberg.me> Date: Sat, 27 Dec 2025 12:42:39 +0200 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 v2] nvme/host: add delayed retries upon non-fatal error during ns validation To: Alex Tran , Keith Busch , Jens Axboe , Christoph Hellwig Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org References: <20251226-nvme_ns_validation-v2-1-0e1b3a142553@gmail.com> Content-Language: en-US From: Sagi Grimberg In-Reply-To: <20251226-nvme_ns_validation-v2-1-0e1b3a142553@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 26/12/2025 19:54, Alex Tran wrote: > If a non-fatal error is received during nvme namespace validation, it > should not be ignored and the namespace should not be removed immediately. > Rather, delayed retries should be performed on the namespace validation > process. > > This handles non-fatal issues more robustly, by retrying a few times before > giving up and removing the namespace. The number of retries is set > to 3 and the interval between retries is set to 3 seconds. > > The retries are handled locally. Upon success then end. Upon fatal error > then remove the namespace before ending. Upon non-fatal error, retry > until the max retry amount is hit before ending. > > Signed-off-by: Alex Tran > --- > Changes in v2: > - Simplify retry logic with local loop instead of delayed work. > --- > drivers/nvme/host/core.c | 37 +++++++++++++++++++++++++++++-------- > drivers/nvme/host/nvme.h | 6 ++++++ > 2 files changed, 35 insertions(+), 8 deletions(-) > > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > index 7bf228df6001f1f4d0b3c570de285a5eb17bb08e..6cd1ce4a60af55e5673e5fd0ec2053a028fae4f2 100644 > --- a/drivers/nvme/host/core.c > +++ b/drivers/nvme/host/core.c > @@ -4289,23 +4289,44 @@ 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_info *info) > { > int ret = NVME_SC_INVALID_NS | NVME_STATUS_DNR; > + unsigned int i; > > if (!nvme_ns_ids_equal(&ns->head->ids, &info->ids)) { > - dev_err(ns->ctrl->device, > - "identifiers changed for nsid %d\n", ns->head->ns_id); > + dev_err(ns->ctrl->device, "identifiers changed for nsid %d\n", > + ns->head->ns_id); > goto out; > } > > - ret = nvme_update_ns_info(ns, info); > + for (i = 0; i <= NVME_NS_VALIDATION_MAX_RETRIES; i++) { > + ret = nvme_update_ns_info(ns, info); > + if (ret == 0) > + return; > + > + if (ret > 0 && (ret & NVME_STATUS_DNR)) > + goto out; > + > + if (i == NVME_NS_VALIDATION_MAX_RETRIES) { > + dev_err(ns->ctrl->device, > + "validation failed for nsid %d after %d retries\n", > + ns->head->ns_id, > + NVME_NS_VALIDATION_MAX_RETRIES); > + return; > + } This is really redundant. just make the loop (i < NVME_NS_VALIDATION_MAX_RETRIES) and print in the end outside the loop. BTW, don't you need to remove the ns here? > + > + dev_warn(ns->ctrl->device, > + "validation failed for nsid %d, retry %d/%d in %dms\n", > + ns->head->ns_id, i + 1, NVME_NS_VALIDATION_MAX_RETRIES, > + NVME_NS_VALIDATION_RETRY_INTERVAL); This can safely be debug print. > + > + msleep(NVME_NS_VALIDATION_RETRY_INTERVAL); > + } > + > out: > /* > * Only remove the namespace if we got a fatal error back from the > - * device, otherwise ignore the error and just move on. > - * > - * TODO: we should probably schedule a delayed retry here. > + * device. > */ > - if (ret > 0 && (ret & NVME_STATUS_DNR)) > - nvme_ns_remove(ns); > + nvme_ns_remove(ns); > } > > static void nvme_scan_ns(struct nvme_ctrl *ctrl, unsigned nsid) > diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h > index 9a5f28c5103c5c42777bd9309a983ef0196c1b95..dcbdc7fa8af0cb838b3f1a774d4c67fa69a00050 100644 > --- a/drivers/nvme/host/nvme.h > +++ b/drivers/nvme/host/nvme.h > @@ -46,6 +46,12 @@ extern unsigned int admin_timeout; > #define NVME_CTRL_PAGE_SHIFT 12 > #define NVME_CTRL_PAGE_SIZE (1 << NVME_CTRL_PAGE_SHIFT) > > +/* > + * Default to 3 retries in intervals of 3000ms for namespace validation > + */ > +#define NVME_NS_VALIDATION_MAX_RETRIES 3 > +#define NVME_NS_VALIDATION_RETRY_INTERVAL 3000 > + > extern struct workqueue_struct *nvme_wq; > extern struct workqueue_struct *nvme_reset_wq; > extern struct workqueue_struct *nvme_delete_wq; > > --- > base-commit: fa084c35afa13ab07a860ef0936cd987f9aa0460 > change-id: 20251225-nvme_ns_validation-310a07aa8b2b > > Best regards,