* [PATCH] nvme: parse zns command's zsa and zrasf to string
@ 2024-03-12 7:52 Guixin Liu
2024-03-12 12:31 ` Christoph Hellwig
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Guixin Liu @ 2024-03-12 7:52 UTC (permalink / raw)
To: kbusch, axboe, hch, sagi; +Cc: linux-nvme
Parse zone mgmt send commands's zsa and receive command's
zrasf to string to make the trace log more human-readable.
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
drivers/nvme/host/trace.c | 38 +++++++++++++++++++++++++++++++++++---
1 file changed, 35 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/host/trace.c b/drivers/nvme/host/trace.c
index 1c36fcedea20..5e94b3c6d58a 100644
--- a/drivers/nvme/host/trace.c
+++ b/drivers/nvme/host/trace.c
@@ -164,12 +164,27 @@ static const char *nvme_trace_dsm(struct trace_seq *p, u8 *cdw10)
static const char *nvme_trace_zone_mgmt_send(struct trace_seq *p, u8 *cdw10)
{
+ static const char * const zsa_strs[] = {
+ [0x01] = "close zone",
+ [0x02] = "finish zone",
+ [0x03] = "open zone",
+ [0x04] = "reset zone",
+ [0x05] = "offline zone",
+ [0x10] = "set zone descriptor extension"
+ };
const char *ret = trace_seq_buffer_ptr(p);
u64 slba = get_unaligned_le64(cdw10);
+ const char *zsa_str;
u8 zsa = cdw10[12];
u8 all = cdw10[13];
- trace_seq_printf(p, "slba=%llu, zsa=%u, all=%u", slba, zsa, all);
+ if (zsa < ARRAY_SIZE(zsa_strs) && zsa_strs[zsa])
+ zsa_str = zsa_strs[zsa];
+ else
+ zsa_str = "reserved";
+
+ trace_seq_printf(p, "slba=%llu, zsa=%u:%s, all=%u",
+ slba, zsa, zsa_str, all);
trace_seq_putc(p, 0);
return ret;
@@ -177,15 +192,32 @@ static const char *nvme_trace_zone_mgmt_send(struct trace_seq *p, u8 *cdw10)
static const char *nvme_trace_zone_mgmt_recv(struct trace_seq *p, u8 *cdw10)
{
+ static const char * const zrasf_strs[] = {
+ [0x00] = "list all zones",
+ [0x01] = "list the zones in the ZSE: Empty state",
+ [0x02] = "list the zones in the ZSIO: Implicitly Opened state",
+ [0x03] = "list the zones in the ZSEO: Explicitly Opened state",
+ [0x04] = "list the zones in the ZSC: Closed state",
+ [0x05] = "list the zones in the ZSF: Full state",
+ [0x06] = "list the zones in the ZSRO: Read Only state",
+ [0x07] = "list the zones in the ZSO: Offline state",
+ [0x09] = "list the zones that have the zone attribute"
+ };
const char *ret = trace_seq_buffer_ptr(p);
u64 slba = get_unaligned_le64(cdw10);
u32 numd = get_unaligned_le32(cdw10 + 8);
u8 zra = cdw10[12];
u8 zrasf = cdw10[13];
+ const char *zrasf_str;
u8 pr = cdw10[14];
- trace_seq_printf(p, "slba=%llu, numd=%u, zra=%u, zrasf=%u, pr=%u",
- slba, numd, zra, zrasf, pr);
+ if (zrasf < ARRAY_SIZE(zrasf_strs) && zrasf_strs[zrasf])
+ zrasf_str = zrasf_strs[zrasf];
+ else
+ zrasf_str = "reserved";
+
+ trace_seq_printf(p, "slba=%llu, numd=%u, zra=%u, zrasf=%u:%s, pr=%u",
+ slba, numd, zra, zrasf, zrasf_str, pr);
trace_seq_putc(p, 0);
return ret;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme: parse zns command's zsa and zrasf to string
2024-03-12 7:52 [PATCH] nvme: parse zns command's zsa and zrasf to string Guixin Liu
@ 2024-03-12 12:31 ` Christoph Hellwig
2024-03-12 21:32 ` Sagi Grimberg
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2024-03-12 12:31 UTC (permalink / raw)
To: Guixin Liu; +Cc: kbusch, axboe, hch, sagi, linux-nvme
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme: parse zns command's zsa and zrasf to string
2024-03-12 7:52 [PATCH] nvme: parse zns command's zsa and zrasf to string Guixin Liu
2024-03-12 12:31 ` Christoph Hellwig
@ 2024-03-12 21:32 ` Sagi Grimberg
2024-03-13 5:59 ` Chaitanya Kulkarni
2024-03-14 18:43 ` Keith Busch
3 siblings, 0 replies; 5+ messages in thread
From: Sagi Grimberg @ 2024-03-12 21:32 UTC (permalink / raw)
To: Guixin Liu, kbusch, axboe, hch; +Cc: linux-nvme
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme: parse zns command's zsa and zrasf to string
2024-03-12 7:52 [PATCH] nvme: parse zns command's zsa and zrasf to string Guixin Liu
2024-03-12 12:31 ` Christoph Hellwig
2024-03-12 21:32 ` Sagi Grimberg
@ 2024-03-13 5:59 ` Chaitanya Kulkarni
2024-03-14 18:43 ` Keith Busch
3 siblings, 0 replies; 5+ messages in thread
From: Chaitanya Kulkarni @ 2024-03-13 5:59 UTC (permalink / raw)
To: Guixin Liu
Cc: kbusch@kernel.org, axboe@kernel.dk, hch@lst.de, sagi@grimberg.me,
linux-nvme@lists.infradead.org
>
> On Mar 12, 2024, at 12:53 AM, Guixin Liu <kanie@linux.alibaba.com> wrote:
>
> Parse zone mgmt send commands's zsa and receive command's
> zrasf to string to make the trace log more human-readable.
>
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
> ---
>
LGTM.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme: parse zns command's zsa and zrasf to string
2024-03-12 7:52 [PATCH] nvme: parse zns command's zsa and zrasf to string Guixin Liu
` (2 preceding siblings ...)
2024-03-13 5:59 ` Chaitanya Kulkarni
@ 2024-03-14 18:43 ` Keith Busch
3 siblings, 0 replies; 5+ messages in thread
From: Keith Busch @ 2024-03-14 18:43 UTC (permalink / raw)
To: Guixin Liu; +Cc: axboe, hch, sagi, linux-nvme
On Tue, Mar 12, 2024 at 03:52:43PM +0800, Guixin Liu wrote:
> Parse zone mgmt send commands's zsa and receive command's
> zrasf to string to make the trace log more human-readable.
>
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
Applied to nvme-6.9, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-03-14 18:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-12 7:52 [PATCH] nvme: parse zns command's zsa and zrasf to string Guixin Liu
2024-03-12 12:31 ` Christoph Hellwig
2024-03-12 21:32 ` Sagi Grimberg
2024-03-13 5:59 ` Chaitanya Kulkarni
2024-03-14 18:43 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox