Skip to content

Commit 9f5436f

Browse files
morbidrsamartinkpetersen
authored andcommitted
scsi: sd: sd_zbc: Trace zone append emulation
Add tracepoints to the SCSI zone append emulation in order to trace the zone start to write-pointer aligned LBA translation and the corresponding completion. Signed-off-by: Johannes Thumshirn <[email protected]> Link: https://lore.kernel.org/r/d103bcf5f90139143469f2a0084c74bd9e03ad4a.1669804487.git.johannes.thumshirn@wdc.com Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Jason Yan <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 6456ab5 commit 9f5436f

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

drivers/scsi/sd_trace.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (C) 2022 Western Digital Corporation or its affiliates.
4+
*/
5+
#undef TRACE_SYSTEM
6+
#define TRACE_SYSTEM sd
7+
8+
#undef TRACE_INCLUDE_FILE
9+
#define TRACE_INCLUDE_FILE sd_trace
10+
11+
#if !defined(_SD_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
12+
#include <scsi/scsi_cmnd.h>
13+
#include <scsi/scsi_host.h>
14+
#include <linux/tracepoint.h>
15+
16+
TRACE_EVENT(scsi_prepare_zone_append,
17+
18+
TP_PROTO(struct scsi_cmnd *cmnd, sector_t lba,
19+
unsigned int wp_offset),
20+
21+
TP_ARGS(cmnd, lba, wp_offset),
22+
23+
TP_STRUCT__entry(
24+
__field( unsigned int, host_no )
25+
__field( unsigned int, channel )
26+
__field( unsigned int, id )
27+
__field( unsigned int, lun )
28+
__field( sector_t, lba )
29+
__field( unsigned int, wp_offset )
30+
),
31+
32+
TP_fast_assign(
33+
__entry->host_no = cmnd->device->host->host_no;
34+
__entry->channel = cmnd->device->channel;
35+
__entry->id = cmnd->device->id;
36+
__entry->lun = cmnd->device->lun;
37+
__entry->lba = lba;
38+
__entry->wp_offset = wp_offset;
39+
),
40+
41+
TP_printk("host_no=%u, channel=%u id=%u lun=%u lba=%llu wp_offset=%u",
42+
__entry->host_no, __entry->channel, __entry->id,
43+
__entry->lun, __entry->lba, __entry->wp_offset)
44+
);
45+
46+
TRACE_EVENT(scsi_zone_wp_update,
47+
48+
TP_PROTO(struct scsi_cmnd *cmnd, sector_t rq_sector,
49+
unsigned int wp_offset, unsigned int good_bytes),
50+
51+
TP_ARGS(cmnd, rq_sector, wp_offset, good_bytes),
52+
53+
TP_STRUCT__entry(
54+
__field( unsigned int, host_no )
55+
__field( unsigned int, channel )
56+
__field( unsigned int, id )
57+
__field( unsigned int, lun )
58+
__field( sector_t, rq_sector )
59+
__field( unsigned int, wp_offset )
60+
__field( unsigned int, good_bytes )
61+
),
62+
63+
TP_fast_assign(
64+
__entry->host_no = cmnd->device->host->host_no;
65+
__entry->channel = cmnd->device->channel;
66+
__entry->id = cmnd->device->id;
67+
__entry->lun = cmnd->device->lun;
68+
__entry->rq_sector = rq_sector;
69+
__entry->wp_offset = wp_offset;
70+
__entry->good_bytes = good_bytes;
71+
),
72+
73+
TP_printk("host_no=%u, channel=%u id=%u lun=%u rq_sector=%llu" \
74+
" wp_offset=%u good_bytes=%u",
75+
__entry->host_no, __entry->channel, __entry->id,
76+
__entry->lun, __entry->rq_sector, __entry->wp_offset,
77+
__entry->good_bytes)
78+
);
79+
#endif /* _SD_TRACE_H */
80+
81+
/* This part must be outside protection */
82+
#undef TRACE_INCLUDE_PATH
83+
#define TRACE_INCLUDE_PATH ../../drivers/scsi
84+
#include <trace/define_trace.h>

drivers/scsi/sd_zbc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
#include "sd.h"
2222

23+
#define CREATE_TRACE_POINTS
24+
#include "sd_trace.h"
25+
2326
/**
2427
* sd_zbc_get_zone_wp_offset - Get zone write pointer offset.
2528
* @zone: Zone for which to return the write pointer offset.
@@ -450,6 +453,7 @@ blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba,
450453
break;
451454
}
452455

456+
trace_scsi_prepare_zone_append(cmd, *lba, wp_offset);
453457
*lba += wp_offset;
454458
}
455459
spin_unlock_irqrestore(&sdkp->zones_wp_offset_lock, flags);
@@ -558,6 +562,8 @@ static unsigned int sd_zbc_zone_wp_update(struct scsi_cmnd *cmd,
558562

559563
switch (op) {
560564
case REQ_OP_ZONE_APPEND:
565+
trace_scsi_zone_wp_update(cmd, rq->__sector,
566+
sdkp->zones_wp_offset[zno], good_bytes);
561567
rq->__sector += sdkp->zones_wp_offset[zno];
562568
fallthrough;
563569
case REQ_OP_WRITE_ZEROES:

0 commit comments

Comments
 (0)