Skip to contentSkip to conversation

nvme: ignore starting sector while error logging for passthrough requests

PATCH In review Pankaj Raghav 3 participants 6 messages Oct 6, 2022 – Oct 18, 2022 1 message not in the archive NVMe

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20221006091054eucas1p1e4113b6dfd108907c2cd5ba7127a3f92@eucas1p1.samsung.com

#1 lore raw

PATCH 1/1 nvme: ignore starting sector while error logging for passthrough requests

Error log will print a garbage value as the starting LBA for passthrough requests and requests with uninitialized starting sector that return an error. Print LBA as 0 instead for these requests. This behaviour is similar what tracing does for these type of requests.

---
 drivers/nvme/host/core.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +8 -1
index 059737c1a2c1..41e0a257f1c2 100644
@@ -305,6 +305,13 @@ static void nvme_retry_req(struct request *req)
 	blk_mq_delay_kick_requeue_list(req->q, delay);
 }
 
+static inline u64 nvme_log_error_rq_lba(struct nvme_ns *ns, struct request *rq)
+{
+	if (blk_rq_is_passthrough(rq) || blk_rq_pos(rq) == (sector_t)-1)
+		return 0;
+	return nvme_sect_to_lba(ns, blk_rq_pos(rq));
+}
+
 static void nvme_log_error(struct request *req)
 {
 	struct nvme_ns *ns = req->q->queuedata;
@@ -315,7 +322,7 @@ static void nvme_log_error(struct request *req)
 		       ns->disk ? ns->disk->disk_name : "?",
 		       nvme_get_opcode_str(nr->cmd->common.opcode),
 		       nr->cmd->common.opcode,
-		       (unsigned long long)nvme_sect_to_lba(ns, blk_rq_pos(req)),
+		       (unsigned long long)nvme_log_error_rq_lba(ns, req),
 		       (unsigned long long)blk_rq_bytes(req) >> ns->lba_shift,
 		       nvme_get_error_status_str(nr->status),
 		       nr->status >> 8 & 7,	/* Status Code Type */
Signature · 1 line
2.25.1
#2 lore raw

The final consensus in Daniel's patch[1] seems to be adding an opt in to log error only for admin commands, and logging error for user IO commands will remain as is.

In that case, should we reconsider this patch to avoid printing a garbage value ((sector_t)-1) while logging error for IO passthrough commands?

[1]
https://lore.kernel.org/all/[email protected]/

Quoted 37 lines · Pankaj Raghav

Error log will print a garbage value as the starting LBA for passthrough requests and requests with uninitialized starting sector that return an error. Print LBA as 0 instead for these requests. This behaviour is similar what tracing does for these type of requests.

---
 drivers/nvme/host/core.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +8 -1
index 059737c1a2c1..41e0a257f1c2 100644
@@ -305,6 +305,13 @@ static void nvme_retry_req(struct request *req)
 	blk_mq_delay_kick_requeue_list(req->q, delay);
 }
 
+static inline u64 nvme_log_error_rq_lba(struct nvme_ns *ns, struct request *rq)
+{
+	if (blk_rq_is_passthrough(rq) || blk_rq_pos(rq) == (sector_t)-1)
+		return 0;
+	return nvme_sect_to_lba(ns, blk_rq_pos(rq));
+}
+
 static void nvme_log_error(struct request *req)
 {
 	struct nvme_ns *ns = req->q->queuedata;
@@ -315,7 +322,7 @@ static void nvme_log_error(struct request *req)
 		       ns->disk ? ns->disk->disk_name : "?",
 		       nvme_get_opcode_str(nr->cmd->common.opcode),
 		       nr->cmd->common.opcode,
-		       (unsigned long long)nvme_sect_to_lba(ns, blk_rq_pos(req)),
+		       (unsigned long long)nvme_log_error_rq_lba(ns, req),
 		       (unsigned long long)blk_rq_bytes(req) >> ns->lba_shift,
 		       nvme_get_error_status_str(nr->status),
 		       nr->status >> 8 & 7,	/* Status Code Type */
#3 lore raw
Quoted 3 lines · Pankaj Raghav

The final consensus in Daniel's patch[1] seems to be adding an opt in to log error only for admin commands, and logging error for user IO commands will remain as is.

Hmm, is it? I'd think even for I/O commands the opt in makes some sense.

Quoted 2 lines

In that case, should we reconsider this patch to avoid printing a garbage value ((sector_t)-1) while logging error for IO passthrough commands?

We should probably do this, but it should probably go along with the opt-in for I/O commands.

maintainer
#4 lore raw
Quoted 5 lines · Christoph Hellwig
Quoted 3 lines · Pankaj Raghav

The final consensus in Daniel's patch[1] seems to be adding an opt in to log error only for admin commands, and logging error for user IO commands will remain as is.

Quoted 8 lines

Hmm, is it? I'd think even for I/O commands the opt in makes some sense.

Quoted 2 lines

In that case, should we reconsider this patch to avoid printing a garbage value ((sector_t)-1) while logging error for IO passthrough commands?

We should probably do this, but it should probably go along with the opt-in for I/O commands.

What's the preferred opt-in mechanism? If we want to do it per-command, we have an unsused 'flags' field in the ioctl structures that we can start defining options for these kinds of things. If we don't want that level of fine grained control, we could set it at the controller or module level with a new sysfs file, though I'm not sure this warrants creating new exports there.

#5 lore raw
Quoted 6 lines · Keith Busch

What's the preferred opt-in mechanism? If we want to do it per-command, we have an unsused 'flags' field in the ioctl structures that we can start defining options for these kinds of things. If we don't want that level of fine grained control, we could set it at the controller or module level with a new sysfs file, though I'm not sure this warrants creating new exports there.

The flags field is what I had in mind. There's also another thing on the plate as some folks really want to opt into kernel error handling for passthrough commands, and that seems to be the only way to do it.

#6 lore raw
In reply to Christoph Hellwig
Quoted 5 lines
Quoted 2 lines

In that case, should we reconsider this patch to avoid printing a garbage value ((sector_t)-1) while logging error for IO passthrough commands?

We should probably do this, but it should probably go along with the opt-in for I/O commands.

Hmm, I think this patch will be orthogonal unless we put some of the opt-in logic in the nvme_log_error() function itself.

Currently, we always log the error with the -1 sector value for passthrough requests, which should be changed to print 0 so that we remain consistent with the tracing infra. The same behavior should also be applicable when we have the opt-in support, and the user decides to opt-in to log error for passthrough requests.

That said, I am fine with this update going along with the opt-in support.