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: 914987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="UGisor72"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40mTw61g8vz9s1w for ; Thu, 17 May 2018 08:42:30 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751893AbeEPWm2 (ORCPT ); Wed, 16 May 2018 18:42:28 -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-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org 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