From patchwork Wed May 16 22:42:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 10405003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 20073602C2 for ; Wed, 16 May 2018 22:42:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C898287DC for ; Wed, 16 May 2018 22:42:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 014782880F; Wed, 16 May 2018 22:42:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 237B1287DC for ; Wed, 16 May 2018 22:42:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752054AbeEPWm3 (ORCPT ); Wed, 16 May 2018 18:42:29 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:34240 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751312AbeEPWm1 (ORCPT ); Wed, 16 May 2018 18:42:27 -0400 Received: by mail-pg0-f66.google.com with SMTP id k2-v6so925441pgc.1; Wed, 16 May 2018 15:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=EJo/HD2W39lb4uKtkSvGJJy/DtFc7y1ilbAr5+ETxLU=; b=UGisor72nwQIf8XlAeWTLHZyQQ4u/KzJUIs6rXJpctW/k1k2V7TkyycNiN72iT+Gpo cOTRHec2p53n0qyKFI1+U1AGwxzXaF0rLwU7/B8Y/5mqlMySU0NQ7byneLY8z5+X8fSF 45lurq8ZuQoJ1mNi+Leq5pWl19SGxG1trLJlEwleKVM9R5XIF5HjYxazrjf0oYWUnlE3 oRtGbo/5DvEeASxhaKifgA2WgxXLEGKGb97QccVz31KfJ8bv1YLC1rxrpPER1hC2trF8 FodguPfhR/v/xJ7J1LdNDShf4yhGI4KRqAzu9/1mk65FbnwrEYZ/foljaL9SzymlhL2/ 7ZNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=EJo/HD2W39lb4uKtkSvGJJy/DtFc7y1ilbAr5+ETxLU=; b=J/7xkciVa1A4PvTOhsOwQ0B1Hu1AVG5yW59kOS+8+779uLeb1ZPmj3udmQo0WYKTq3 QXi3paoc9QOQecYLWfZYwa/JpiQ9ZnhXk7P1A4zVo7JHq5gDaZZwP8NmRDcNKt00vx0i dvS8kWEnPX/iN4bWttMVulX21bYHcLcMVB6r+D4G1VgJd2Qt1MSG+4looPoTCfzA2m/f 3GQr0kM0Pq6X/K66qU3lQToueGYt2zsWs0AR3v2emHJXU6iQAxTdd5cbhPFl6VxGUydF w/NuxxSQs3dzpCl6vsYrQTxdIiLCt6Bptd8JkgLo4uI8yzJdAyUF9/WKDATZcxliMqbt Xbrg== X-Gm-Message-State: ALKqPwd0sVkKfcOKI2l9NgXBYFBnaO8v09dMcq6ZOgdbyXPDH3HpY8Ij pNcjWz/XOlj3/Ok68LFrYv9N/XR3pxHvXWGSjJiEbxLO X-Google-Smtp-Source: AB8JxZod4fa+rjDwQEY/ZAGnFq48xHkMg0WHKv7EaVQre1RU8PettZnnFSBoy5Oj+U1JF9KeEXojgrPBdF3PoOrIWio= X-Received: by 2002:a63:3d0a:: with SMTP id k10-v6mr2216471pga.11.1526510546605; Wed, 16 May 2018 15:42:26 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a17:90a:bd8f:0:0:0:0 with HTTP; Wed, 16 May 2018 15:42:06 -0700 (PDT) From: Steve French Date: Wed, 16 May 2018 17:42:06 -0500 Message-ID: Subject: [PATCH][SMB3] Add ftrace support To: LKML , CIFS , samba-technical , linux-fsdevel Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP I plan to add various tracepoints to cifs.ko, but wanted to verify that the initial patch looks ok (which only adds logging for one event, write errors), before I start adding various other tracepoints. Also I need to know ... is the size of log entries a problem? I have to weight logging just the tree id (and relying on an ioctl or proc/fs/cifs call to resolve the numeric tree id to a more readable UNC name ie \\server\share for the mount)? Generally I want to log these four things tree id session id file id (for everything but open/tree connect/negprot/session setup where it is not applicable) and/or file name (is logging file name going to make log entries too big?) xid (so we can correlate events from one syscall) From f190a0c82ce8c95db1c43b7b41115ffc7bb6fb2f Mon Sep 17 00:00:00 2001 From: Steve French Date: Wed, 16 May 2018 16:42:27 -0500 Subject: [PATCH] smb3: Add ftrace tracepoints for improved SMB3 debugging Although dmesg logs and wireshark network traces can be helpful, being able to dynamically enable/disable tracepoints (in this case via the kernel ftrace mechanism) can also be helpful in more quickly debugging problems, and more selectively tracing the events related to the bug report. Add various ftrace tracepoints to cifs.ko for SMB3 events. Example use: trace-cmd record -e cifs trace-cmd show Various trace events can be filtered. See: trace-cmd list | grep cifs for the current list of cifs tracepoints. Signed-off-by: Steve French --- fs/cifs/Makefile | 7 +++-- fs/cifs/smb2pdu.c | 6 ++++ fs/cifs/trace.c | 18 ++++++++++++ fs/cifs/trace.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 fs/cifs/trace.c create mode 100644 fs/cifs/trace.h From f190a0c82ce8c95db1c43b7b41115ffc7bb6fb2f Mon Sep 17 00:00:00 2001 From: Steve French Date: Wed, 16 May 2018 16:42:27 -0500 Subject: [PATCH] smb3: Add ftrace tracepoints for improved SMB3 debugging Although dmesg errors and wireshark network traces can be helpful, being able to dynamically enable/disable tracepoints (in this case via the kernel ftrace mechanism) can also be helpful in more quickly debugging problems, and more selectively tracing the events related to the bug report. Add various ftrace tracepoints to cifs.ko for SMB3 events. Example use: trace-cmd record -e cifs trace-cmd show Various trace events can be filtered. See: trace-cmd list | grep cifs for the current list of cifs tracepoints. Signed-off-by: Steve French --- fs/cifs/Makefile | 7 +++-- fs/cifs/smb2pdu.c | 6 ++++ fs/cifs/trace.c | 18 ++++++++++++ fs/cifs/trace.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 fs/cifs/trace.c create mode 100644 fs/cifs/trace.h diff --git a/fs/cifs/Makefile b/fs/cifs/Makefile index 7e4a1e2f0696..85817991ee68 100644 --- a/fs/cifs/Makefile +++ b/fs/cifs/Makefile @@ -1,11 +1,12 @@ # SPDX-License-Identifier: GPL-2.0 # -# Makefile for Linux CIFS VFS client +# Makefile for Linux CIFS/SMB2/SMB3 VFS client # +ccflags-y += -I$(src) # needed for trace events obj-$(CONFIG_CIFS) += cifs.o -cifs-y := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o \ - link.o misc.o netmisc.o smbencrypt.o transport.o asn1.o \ +cifs-y := trace.o cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o \ + inode.o link.o misc.o netmisc.o smbencrypt.o transport.o asn1.o \ cifs_unicode.o nterr.o cifsencrypt.o \ readdir.o ioctl.o sess.o export.o smb1ops.o winucase.o \ smb2ops.o smb2maperror.o smb2transport.o \ diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 35350057fc23..790d8faf8e1e 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -49,6 +49,7 @@ #include "cifspdu.h" #include "cifs_spnego.h" #include "smbdirect.h" +#include "trace.h" /* * The following table defines the expected "StructureSize" of SMB2 requests @@ -3058,6 +3059,8 @@ smb2_async_writev(struct cifs_writedata *wdata, wdata, flags); if (rc) { + trace_smb3_write_err(rc, 0 /* no xid */, req->PersistentFileId, + tcon->tid, wdata->offset, wdata->bytes); kref_put(&wdata->refcount, release); cifs_stats_fail_inc(tcon, SMB2_WRITE_HE); } @@ -3124,6 +3127,9 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms, rsp = (struct smb2_write_rsp *)rsp_iov.iov_base; if (rc) { + trace_smb3_write_err(rc, xid, req->PersistentFileId, + io_parms->tcon->tid, io_parms->offset, + io_parms->length); cifs_stats_fail_inc(io_parms->tcon, SMB2_WRITE_HE); cifs_dbg(VFS, "Send error in write = %d\n", rc); } else diff --git a/fs/cifs/trace.c b/fs/cifs/trace.c new file mode 100644 index 000000000000..bd4a546feec1 --- /dev/null +++ b/fs/cifs/trace.c @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018, Microsoft Corporation. + * + * Author(s): Steve French + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + * the GNU General Public License for more details. + */ +#define CREATE_TRACE_POINTS +#include "trace.h" diff --git a/fs/cifs/trace.h b/fs/cifs/trace.h new file mode 100644 index 000000000000..1e7b38e2fa15 --- /dev/null +++ b/fs/cifs/trace.h @@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2018, Microsoft Corporation. + * + * Author(s): Steve French + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + * the GNU General Public License for more details. + */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM cifs + +#if !defined(_CIFS_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) +#define _CIFS_TRACE_H + +#include + +DECLARE_EVENT_CLASS(smb3_err_class, + TP_PROTO(unsigned int xid, + __u64 fid, + __u32 tid, + __u64 offset, + __u32 len, + int rc), + TP_ARGS(xid, fid, tid, offset, len, rc), + TP_STRUCT__entry( + __field(unsigned int, xid) + __field(__u64, fid) + __field(__u32, tid) + __field(__u64, offset) + __field(__u32, len) + __field(int, rc) + ), + TP_fast_assign( + __entry->xid = xid; + __entry->fid = fid; + __entry->tid = tid; + __entry->offset = offset; + __entry->len = len; + __entry->rc = rc; + ), + TP_printk("xid=%u fid=%llu tid=%u offset=%llu len=%u rc=%d", + __entry->xid, __entry->fid, __entry->tid, __entry->offset, + __entry->len, __entry->rc) +) + +#define DEFINE_SMB3_ERR_EVENT(name) \ +DEFINE_EVENT(smb3_err_class, smb3_##name, \ + TP_PROTO(unsigned int xid, \ + __u64 fid, \ + __u32 tid, \ + __u64 offset, \ + __u32 len, \ + int rc), \ + TP_ARGS(xid, fid, tid, offset, len, rc)) + +DEFINE_SMB3_ERR_EVENT(write_err); + +#endif /* _CIFS_TRACE_H */ + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#define TRACE_INCLUDE_FILE trace +#include -- 2.17.0