Skip to content

Commit 020eec5

Browse files
author
Steve French
committed
smb3: add tracepoint for slow responses
If responses take longer than one second from the server, we can optionally log them to dmesg in current cifs.ko code (CONFIG_CIFS_STATS2 must be configured and a /proc/fs/cifs/cifsFYI flag must be set), but can be more useful to log these via ftrace (tracepoint is smb3_slow_rsp) which is easier and more granular (still requires CONFIG_CIFS_STATS2 to be configured in the build though). Signed-off-by: Steve French <[email protected]> Reviewed-by: Pavel Shilovsky <[email protected]>
1 parent e0bba0b commit 020eec5

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

fs/cifs/trace.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,43 @@ DEFINE_EVENT(smb3_cmd_done_class, smb3_##name, \
283283
DEFINE_SMB3_CMD_DONE_EVENT(cmd_done);
284284
DEFINE_SMB3_CMD_DONE_EVENT(ses_expired);
285285

286+
DECLARE_EVENT_CLASS(smb3_mid_class,
287+
TP_PROTO(__u16 cmd,
288+
__u64 mid,
289+
__u32 pid,
290+
unsigned long when_sent,
291+
unsigned long when_received),
292+
TP_ARGS(cmd, mid, pid, when_sent, when_received),
293+
TP_STRUCT__entry(
294+
__field(__u16, cmd)
295+
__field(__u64, mid)
296+
__field(__u32, pid)
297+
__field(unsigned long, when_sent)
298+
__field(unsigned long, when_received)
299+
),
300+
TP_fast_assign(
301+
__entry->cmd = cmd;
302+
__entry->mid = mid;
303+
__entry->pid = pid;
304+
__entry->when_sent = when_sent;
305+
__entry->when_received = when_received;
306+
),
307+
TP_printk("\tcmd=%u mid=%llu pid=%u, when_sent=%lu when_rcv=%lu",
308+
__entry->cmd, __entry->mid, __entry->pid, __entry->when_sent,
309+
__entry->when_received)
310+
)
311+
312+
#define DEFINE_SMB3_MID_EVENT(name) \
313+
DEFINE_EVENT(smb3_mid_class, smb3_##name, \
314+
TP_PROTO(__u16 cmd, \
315+
__u64 mid, \
316+
__u32 pid, \
317+
unsigned long when_sent, \
318+
unsigned long when_received), \
319+
TP_ARGS(cmd, mid, pid, when_sent, when_received))
320+
321+
DEFINE_SMB3_MID_EVENT(slow_rsp);
322+
286323
DECLARE_EVENT_CLASS(smb3_exit_err_class,
287324
TP_PROTO(unsigned int xid,
288325
const char *func_name,

fs/cifs/transport.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,12 @@ DeleteMidQEntry(struct mid_q_entry *midEntry)
115115
now = jiffies;
116116
/* commands taking longer than one second are indications that
117117
something is wrong, unless it is quite a slow link or server */
118-
if (time_after(now, midEntry->when_alloc + HZ)) {
119-
if ((cifsFYI & CIFS_TIMER) && (midEntry->command != command)) {
118+
if (time_after(now, midEntry->when_alloc + HZ) &&
119+
(midEntry->command != command)) {
120+
trace_smb3_slow_rsp(le16_to_cpu(midEntry->command),
121+
midEntry->mid, midEntry->pid,
122+
midEntry->when_sent, midEntry->when_received);
123+
if (cifsFYI & CIFS_TIMER) {
120124
pr_debug(" CIFS slow rsp: cmd %d mid %llu",
121125
midEntry->command, midEntry->mid);
122126
pr_info(" A: 0x%lx S: 0x%lx R: 0x%lx\n",

0 commit comments

Comments
 (0)