Skip to content

Commit 50bee38

Browse files
guixinliu1995keithbusch
authored andcommitted
nvmet: add tracing of reservation commands
Add tracing of reservation commands, including register, acquire, release and report, and also parse the action and rtype to string to make the trace log more human-readable. Signed-off-by: Guixin Liu <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 8a502b5 commit 50bee38

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

drivers/nvme/target/trace.c

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,106 @@ static const char *nvmet_trace_zone_mgmt_recv(struct trace_seq *p, u8 *cdw10)
180180
return ret;
181181
}
182182

183+
static const char *nvmet_trace_resv_reg(struct trace_seq *p, u8 *cdw10)
184+
{
185+
static const char * const rrega_strs[] = {
186+
[0x00] = "register",
187+
[0x01] = "unregister",
188+
[0x02] = "replace",
189+
};
190+
const char *ret = trace_seq_buffer_ptr(p);
191+
u8 rrega = cdw10[0] & 0x7;
192+
u8 iekey = (cdw10[0] >> 3) & 0x1;
193+
u8 ptpl = (cdw10[3] >> 6) & 0x3;
194+
const char *rrega_str;
195+
196+
if (rrega < ARRAY_SIZE(rrega_strs) && rrega_strs[rrega])
197+
rrega_str = rrega_strs[rrega];
198+
else
199+
rrega_str = "reserved";
200+
201+
trace_seq_printf(p, "rrega=%u:%s, iekey=%u, ptpl=%u",
202+
rrega, rrega_str, iekey, ptpl);
203+
trace_seq_putc(p, 0);
204+
205+
return ret;
206+
}
207+
208+
static const char * const rtype_strs[] = {
209+
[0x00] = "reserved",
210+
[0x01] = "write exclusive",
211+
[0x02] = "exclusive access",
212+
[0x03] = "write exclusive registrants only",
213+
[0x04] = "exclusive access registrants only",
214+
[0x05] = "write exclusive all registrants",
215+
[0x06] = "exclusive access all registrants",
216+
};
217+
218+
static const char *nvmet_trace_resv_acq(struct trace_seq *p, u8 *cdw10)
219+
{
220+
static const char * const racqa_strs[] = {
221+
[0x00] = "acquire",
222+
[0x01] = "preempt",
223+
[0x02] = "preempt and abort",
224+
};
225+
const char *ret = trace_seq_buffer_ptr(p);
226+
u8 racqa = cdw10[0] & 0x7;
227+
u8 iekey = (cdw10[0] >> 3) & 0x1;
228+
u8 rtype = cdw10[1];
229+
const char *racqa_str = "reserved";
230+
const char *rtype_str = "reserved";
231+
232+
if (racqa < ARRAY_SIZE(racqa_strs) && racqa_strs[racqa])
233+
racqa_str = racqa_strs[racqa];
234+
235+
if (rtype < ARRAY_SIZE(rtype_strs) && rtype_strs[rtype])
236+
rtype_str = rtype_strs[rtype];
237+
238+
trace_seq_printf(p, "racqa=%u:%s, iekey=%u, rtype=%u:%s",
239+
racqa, racqa_str, iekey, rtype, rtype_str);
240+
trace_seq_putc(p, 0);
241+
242+
return ret;
243+
}
244+
245+
static const char *nvmet_trace_resv_rel(struct trace_seq *p, u8 *cdw10)
246+
{
247+
static const char * const rrela_strs[] = {
248+
[0x00] = "release",
249+
[0x01] = "clear",
250+
};
251+
const char *ret = trace_seq_buffer_ptr(p);
252+
u8 rrela = cdw10[0] & 0x7;
253+
u8 iekey = (cdw10[0] >> 3) & 0x1;
254+
u8 rtype = cdw10[1];
255+
const char *rrela_str = "reserved";
256+
const char *rtype_str = "reserved";
257+
258+
if (rrela < ARRAY_SIZE(rrela_strs) && rrela_strs[rrela])
259+
rrela_str = rrela_strs[rrela];
260+
261+
if (rtype < ARRAY_SIZE(rtype_strs) && rtype_strs[rtype])
262+
rtype_str = rtype_strs[rtype];
263+
264+
trace_seq_printf(p, "rrela=%u:%s, iekey=%u, rtype=%u:%s",
265+
rrela, rrela_str, iekey, rtype, rtype_str);
266+
trace_seq_putc(p, 0);
267+
268+
return ret;
269+
}
270+
271+
static const char *nvmet_trace_resv_report(struct trace_seq *p, u8 *cdw10)
272+
{
273+
const char *ret = trace_seq_buffer_ptr(p);
274+
u32 numd = get_unaligned_le32(cdw10);
275+
u8 eds = cdw10[4] & 0x1;
276+
277+
trace_seq_printf(p, "numd=%u, eds=%u", numd, eds);
278+
trace_seq_putc(p, 0);
279+
280+
return ret;
281+
}
282+
183283
const char *nvmet_trace_parse_nvm_cmd(struct trace_seq *p,
184284
u8 opcode, u8 *cdw10)
185285
{
@@ -195,6 +295,14 @@ const char *nvmet_trace_parse_nvm_cmd(struct trace_seq *p,
195295
return nvmet_trace_zone_mgmt_send(p, cdw10);
196296
case nvme_cmd_zone_mgmt_recv:
197297
return nvmet_trace_zone_mgmt_recv(p, cdw10);
298+
case nvme_cmd_resv_register:
299+
return nvmet_trace_resv_reg(p, cdw10);
300+
case nvme_cmd_resv_acquire:
301+
return nvmet_trace_resv_acq(p, cdw10);
302+
case nvme_cmd_resv_release:
303+
return nvmet_trace_resv_rel(p, cdw10);
304+
case nvme_cmd_resv_report:
305+
return nvmet_trace_resv_report(p, cdw10);
198306
default:
199307
return nvmet_trace_common(p, cdw10);
200308
}

0 commit comments

Comments
 (0)