[PATCH v2 1/2] nvmet: add tracing of zns commands

Chaitanya Kulkarni chaitanyak at nvidia.com
Tue Feb 27 21:25:07 PST 2024


On 2/27/24 18:31, Guixin Liu wrote:
> Add nvme_cmd_zone_append, nvme_cmd_zone_mgmt_send and
> nvme_cmd_zone_mgmt_recv parse to nvme target tracing.
>
> Signed-off-by: Guixin Liu <kanie at linux.alibaba.com>
> ---
>   drivers/nvme/target/trace.c | 34 ++++++++++++++++++++++++++++++++++
>   1 file changed, 34 insertions(+)
>
> diff --git a/drivers/nvme/target/trace.c b/drivers/nvme/target/trace.c
> index 657bd31841b2..6604e5fe57d8 100644
> --- a/drivers/nvme/target/trace.c
> +++ b/drivers/nvme/target/trace.c
> @@ -119,6 +119,35 @@ const char *nvmet_trace_parse_admin_cmd(struct trace_seq *p,
>   	}
>   }
>   
> +static const char *nvmet_trace_zone_mgmt_send(struct trace_seq *p, u8 *cdw10)
> +{
> +	const char *ret = trace_seq_buffer_ptr(p);
> +	u64 slba = get_unaligned_le64(cdw10);
> +	u8 zsa = cdw10[12];
> +	u8 all = cdw10[13];
> +
> +	trace_seq_printf(p, "slba=%llu, zsa=%u, all=%u", slba, zsa, all);
> +	trace_seq_putc(p, 0);
> +
> +	return ret;
> +}
> +
> +static const char *nvmet_trace_zone_mgmt_recv(struct trace_seq *p, u8 *cdw10)
> +{
> +	const char *ret = trace_seq_buffer_ptr(p);
> +	u64 slba = get_unaligned_le64(cdw10);
> +	u32 numd = get_unaligned_le32(cdw10 + 8);

please use consistent notation :- &cdw10[8]

> +	u8 zra = cdw10[12];
> +	u8 zrasf = cdw10[13];

why not decode zrasf values 0h-9h to make it more readable ?
printing number only will make a trip to the spec since I don't think
everyone will remember those values all the time , more importantly
this will also help in testing to grep for right string when using zrasf.

same goes for zsa I guess above ...
> +	u8 pr = cdw10[14];
> +
> +	trace_seq_printf(p, "slba=%llu, numd=%u, zra=%u, zrasf=%u, pr=%u",
> +			 slba, numd, zra, zrasf, pr);
> +	trace_seq_putc(p, 0);
> +
> +	return ret;
> +}
> +
>   const char *nvmet_trace_parse_nvm_cmd(struct trace_seq *p,
>   		u8 opcode, u8 *cdw10)
>   {
> @@ -126,9 +155,14 @@ const char *nvmet_trace_parse_nvm_cmd(struct trace_seq *p,
>   	case nvme_cmd_read:
>   	case nvme_cmd_write:
>   	case nvme_cmd_write_zeroes:
> +	case nvme_cmd_zone_append:
>   		return nvmet_trace_read_write(p, cdw10);
>   	case nvme_cmd_dsm:
>   		return nvmet_trace_dsm(p, cdw10);
> +	case nvme_cmd_zone_mgmt_send:
> +		return nvmet_trace_zone_mgmt_send(p, cdw10);
> +	case nvme_cmd_zone_mgmt_recv:
> +		return nvmet_trace_zone_mgmt_recv(p, cdw10);
>   	default:
>   		return nvmet_trace_common(p, cdw10);
>   	}

-ck




More information about the Linux-nvme mailing list