[RFC v0] nvme: do not log errors for user commands

Daniel Wagner dwagner at suse.de
Thu Sep 29 10:13:37 PDT 2022


User space might issue commands which fail. Currently this gets logged
and irretates users.

libnvme's nvme_scan_topology function is using Namespace
Identification Descriptor list (CNS Value 0x03) for discovering. It
handles the case where it fails but the kernel logs this as error:

 nvme0: Admin Cmd(0x6), I/O Error (sct 0x0 / sc 0x2) DNR
 nvme1: Admin Cmd(0x6), I/O Error (sct 0x0 / sc 0x2) DNR

Thus filter out error logs for user commands.

Link: https://github.com/linux-nvme/libnvme/issues/485
Reported-by: yi.zhang at redhat.com
Reported-by: Tomas Bzatek <tbzatek at redhat.com>
Signed-off-by: Daniel Wagner <dwagner at suse.de>
---

Only compile tested, just wanted to ask if this approach would be acceptable?

 drivers/nvme/host/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f2786a6b1a85..b86b3b7e37cc 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -325,6 +325,9 @@ static void nvme_log_error(struct request *req)
 		return;
 	}
 
+	if (nr->flags & NVME_REQ_USERCMD)
+		return;
+
 	pr_err_ratelimited("%s: %s(0x%x), %s (sct 0x%x / sc 0x%x) %s%s\n",
 			   dev_name(nr->ctrl->device),
 			   nvme_get_admin_opcode_str(nr->cmd->common.opcode),
-- 
2.37.3




More information about the Linux-nvme mailing list