Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagi@grimberg.me>
To: linux-nvme@lists.infradead.org, Christoph Hellwig <hch@lst.de>,
	Keith Busch <kbusch@kernel.org>,
	Chaitanya Kulkarni <kch@nvidia.com>
Cc: Daniel Wagner <dwagner@suse.de>,
	Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
	Hannes Reinecke <hare@suse.de>
Subject: [PATCH 6/6] nvme/fault-injection: Support for error injection with custom crd
Date: Sun, 23 Aug 2026 11:49:02 +0300	[thread overview]
Message-ID: <20260823084903.193188-7-sagi@grimberg.me> (raw)
In-Reply-To: <20260823084903.193188-1-sagi@grimberg.me>

This assumes that the controller exposed crdt[1,2,3] that are actually
meaningful in order to have make difference.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 drivers/nvme/host/fault_inject.c | 8 ++++++--
 drivers/nvme/host/nvme.h         | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/fault_inject.c b/drivers/nvme/host/fault_inject.c
index 105d6cb41c72..98363fc6dde7 100644
--- a/drivers/nvme/host/fault_inject.c
+++ b/drivers/nvme/host/fault_inject.c
@@ -42,11 +42,13 @@ void nvme_fault_inject_init(struct nvme_fault_inject *fault_inj,
 	}
 	fault_inj->parent = parent;
 
-	/* create debugfs for status code and dont_retry */
+	/* create debugfs for status code, dont_retry and crd */
 	fault_inj->status = NVME_SC_INVALID_OPCODE;
 	fault_inj->dont_retry = true;
+	fault_inj->crd = 0;
 	debugfs_create_x16("status", 0600, dir,	&fault_inj->status);
 	debugfs_create_bool("dont_retry", 0600, dir, &fault_inj->dont_retry);
+	debugfs_create_u8("crd", 0600, dir, &fault_inj->crd);
 }
 
 void nvme_fault_inject_fini(struct nvme_fault_inject *fault_inject)
@@ -73,10 +75,12 @@ void nvme_should_fail(struct request *req)
 	}
 
 	if (fault_inject && should_fail(&fault_inject->attr, 1)) {
-		/* inject status code and DNR bit */
+		/* inject status code, optional DNR and CRD */
 		status = fault_inject->status;
 		if (fault_inject->dont_retry)
 			status |= NVME_STATUS_DNR;
+		if (fault_inject->crd && fault_inject->crd <= 3)
+			status |= (fault_inject->crd << 11) & NVME_STATUS_CRD;
 		nvme_req(req)->status =	status;
 	}
 }
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index e63f21b3110c..9aa0fc5e473a 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -318,6 +318,7 @@ struct nvme_fault_inject {
 	struct fault_attr attr;
 	struct dentry *parent;
 	bool dont_retry;	/* DNR, do not retry */
+	u8 crd;			/* Command Retry Delay (0-3) */
 	u16 status;		/* status code */
 #endif
 };
-- 
2.43.0



  parent reply	other threads:[~2026-08-23  8:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-23  8:48 [PATCH 0/6] Support per command retry timer Sagi Grimberg
2026-08-23  8:48 ` [PATCH 1/6] nvme-mpath: No need to protect req->bio with requeue_lock Sagi Grimberg
2026-08-24 11:31   ` Hannes Reinecke
2026-08-24 15:53   ` John Garry
2026-09-02 13:39   ` Christoph Hellwig
2026-08-23  8:48 ` [PATCH 2/6] nvme: add nvme_crd_msecs helper Sagi Grimberg
2026-08-24 11:32   ` Hannes Reinecke
2026-09-02 13:40   ` Christoph Hellwig
2026-09-06  0:07     ` Sagi Grimberg
2026-08-23  8:48 ` [PATCH 3/6] nvme: add per request retry timer Sagi Grimberg
2026-08-24 13:25   ` Hannes Reinecke
2026-09-02 13:41   ` Christoph Hellwig
2026-09-06  0:09     ` Sagi Grimberg
2026-09-11 22:53       ` Sagi Grimberg
2026-08-23  8:49 ` [PATCH 4/6] nvme-mpath: support controller crd when failing over request Sagi Grimberg
2026-08-24 13:45   ` Hannes Reinecke
2026-08-24 14:23     ` Sagi Grimberg
2026-09-02 13:43   ` Christoph Hellwig
2026-09-06  0:15     ` Sagi Grimberg
2026-08-23  8:49 ` [PATCH 5/6] nvmet: Add support for configurable crdt (command retry delay) attributes Sagi Grimberg
2026-09-02 13:44   ` Christoph Hellwig
2026-09-06  0:20     ` Sagi Grimberg
2026-08-23  8:49 ` Sagi Grimberg [this message]
2026-08-23  8:49 ` [PATCH 7/6 RFC] nvme: test per-command retry delay Sagi Grimberg
2026-08-30  8:23   ` Shin'ichiro Kawasaki
2026-08-30 20:55     ` Sagi Grimberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260823084903.193188-7-sagi@grimberg.me \
    --to=sagi@grimberg.me \
    --cc=dwagner@suse.de \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=kch@nvidia.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=shinichiro.kawasaki@wdc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox