From patchwork Mon Oct 22 04:43:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 10651683 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E07C109C for ; Mon, 22 Oct 2018 04:43:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59B22279E0 for ; Mon, 22 Oct 2018 04:43:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 49C0927C2D; Mon, 22 Oct 2018 04:43:24 +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=ham 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 72866279E0 for ; Mon, 22 Oct 2018 04:43:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726857AbeJVNAM (ORCPT ); Mon, 22 Oct 2018 09:00:12 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33890 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726784AbeJVNAM (ORCPT ); Mon, 22 Oct 2018 09:00:12 -0400 Received: by mail-pl1-f196.google.com with SMTP id f10-v6so673279plr.1 for ; Sun, 21 Oct 2018 21:43:21 -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=Cu3UygriQur8MCdRNeY457fr3/bWoks8v6tEC6a0MKE=; b=XFPayjMHOOzR7D528zm3KhNDh6hJ+3mvv854tTVfC4mXx8GqGUVvns9h03bNJlEYIf oULLCz3mckzCZj0SZ87wey1sniyR/PE1zam7bnEsM/NHr/Ea3eXalim6J5OINZg3Bl9b SimZQNRXm+dGSrk47vY+queKDGNtFePG0e0qIaAfb2fl+lLdJiWisaGKNsChLpHq4gCz SgOU7Pl4Um78uwRDLd0CkiZW1uXDKQ5oVomOgiYkdOMnJSkeT/Dal5WRevtmvQ+1N+wC GiztykO9OIx8RcKywJ7C/SQ77sKTLzQVkiVwp4cAvVIPMoaq8HXk8BGqlpY0yajveMw0 wlKA== 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=Cu3UygriQur8MCdRNeY457fr3/bWoks8v6tEC6a0MKE=; b=Eu02wRQ2o4FXgf9y6Ovm10rjqIoIalkEqnCJGkEnjOtkEuVDnANvyN7mPbN1epmE8H hjESmLJkRAEZGQmxs5P6e+7tilVlEwzwWTn6tzBhQMZCLesEzNi/ax5XGBvr/jFxZuaK jJ7UpPlcUX3qrz+csw1g1LzqZUV54wC33LvexVFjfM9sPGtAHruEFLLtAnBhF0I2lS4k 30x0pFJJlEwAUYe9kSBi+bKG9zM1Y3RobP1El+GGYv1z8Y7QLbHAEpgl0PWcgkELmYU+ Ej7uoGGy7Rn2W+LttBYQ7Vda8w33RbBmiE/suHapMOIJu0GvbFZ/fphAh8YKRYUbnWdj eiZg== X-Gm-Message-State: ABuFfojx2h8yw4T8jYAL0S1P89Xi9Aw5qOJEjLQodSuxQ31qKaRvgYon iAaQzjykFnllknvioYlIDorzSWGrmLAHTIT7qVJQPnVf X-Google-Smtp-Source: ACcGV61EoABQDvOvQdOeS8ROU2Thr3f0lMw5aPsn0vfL6+G2PXeY+N9QtNBAYm7xNRSz1GgSq5mKj+CgS5L7OvfPS/Q= X-Received: by 2002:a17:902:96a:: with SMTP id 97-v6mr10301522plm.32.1540183400432; Sun, 21 Oct 2018 21:43:20 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Sun, 21 Oct 2018 23:43:09 -0500 Message-ID: Subject: [PATCH] smb3: allow more detailed protocol info on open files on the Linux client for debugging To: CIFS , samba-technical Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to debug complex problems it is often helpful to have detailed information on the client and server view of the open file information. Add the ability for root to view the list of smb3 open files and dump the persistent handle and other info so that it can be more easily correlated with server logs. Sample output: Display debugging information for open files treeid: 0x8dce084 \\localhost\test Persistent fid: 0xaddde0a9 name: rofile flags 0x8000 count 1 pid: 7860 uid: 1000 mid 0x30 Persistent fid: 0xd634fe34 name: smallfile flags 0x8000 count 1 pid: 7858 uid: 1000 mid 0x24 Persistent fid: 0xc90bfdc9 name: smallfile flags 0x8000 count 1 pid: 7857 uid: 1000 mid 0x1a treeid: 0x34b9815b \\localhost\scratch Persistent fid: 0x86a6e394 name: f71 flags 0x8000 count 1 pid: 7861 uid: 1000 mid 0x20 Signed-off-by: Steve French --- fs/cifs/cifs_debug.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ fs/cifs/cifsglob.h | 3 +++ fs/cifs/smb2ops.c | 3 +++ fs/cifs/smb2pdu.c | 3 +++ 4 files changed, 59 insertions(+) memcpy(buf, &rsp->CreationTime, 32); From 325054f9f07d842cae41681c53165de878675509 Mon Sep 17 00:00:00 2001 From: Steve French Date: Sun, 21 Oct 2018 23:36:39 -0500 Subject: [PATCH] smb3: allow more detailed protocol info on open files for debugging In order to debug complex problems it is often helpful to have detailed information on the client and server view of the open file information. Add the ability for root to view the list of smb3 open files and dump the persistent handle and other info so that it can be more easily correlated with server logs. Sample output: Display debugging information for open files treeid: 0x8dce084 \\localhost\test Persistent fid: 0xaddde0a9 name: rofile flags 0x8000 count 1 pid: 7860 uid: 1000 mid 0x30 Persistent fid: 0xd634fe34 name: smallfile flags 0x8000 count 1 pid: 7858 uid: 1000 mid 0x24 Persistent fid: 0xc90bfdc9 name: smallfile flags 0x8000 count 1 pid: 7857 uid: 1000 mid 0x1a treeid: 0x34b9815b \\localhost\scratch Persistent fid: 0x86a6e394 name: f71 flags 0x8000 count 1 pid: 7861 uid: 1000 mid 0x20 Signed-off-by: Steve French --- fs/cifs/cifs_debug.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ fs/cifs/cifsglob.h | 3 +++ fs/cifs/smb2ops.c | 3 +++ fs/cifs/smb2pdu.c | 3 +++ 4 files changed, 59 insertions(+) diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index 3e812428ac8d..2c76fe38b073 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c @@ -145,6 +145,52 @@ cifs_dump_iface(struct seq_file *m, struct cifs_server_iface *iface) seq_printf(m, "\t\tIPv6: %pI6\n", &ipv6->sin6_addr); } +static int cifs_debug_files_proc_show(struct seq_file *m, void *v) +{ + struct list_head *stmp, *tmp, *tmp1, *tmp2; + struct TCP_Server_Info *server; + struct cifs_ses *ses; + struct cifs_tcon *tcon; + struct cifsFileInfo *cfile; + + seq_puts(m, "Display debugging information for open files\n"); + spin_lock(&cifs_tcp_ses_lock); + list_for_each(stmp, &cifs_tcp_ses_list) { + server = list_entry(stmp, struct TCP_Server_Info, + tcp_ses_list); + list_for_each(tmp, &server->smb_ses_list) { + ses = list_entry(tmp, struct cifs_ses, smb_ses_list); + list_for_each(tmp1, &ses->tcon_list) { + tcon = list_entry(tmp1, struct cifs_tcon, tcon_list); + seq_printf(m, "\ntreeid: 0x%x %s\n", tcon->tid, tcon->treeName); + spin_lock(&tcon->open_file_lock); + list_for_each(tmp2, &tcon->openFileList) { + cfile = list_entry(tmp2, struct cifsFileInfo, + tlist); + seq_printf(m, + "Persistent fid: 0x%llx name: %s flags 0x%x count %d pid: %d uid: %d", + cfile->fid.persistent_fid, + cfile->dentry->d_name.name, + cfile->f_flags, + cfile->count, + cfile->pid, + from_kuid(&init_user_ns, + cfile->uid)); +#ifdef CONFIG_CIFS_DEBUG2 + seq_printf(m, " mid 0x%llx\n", cfile->fid.mid); +#else + seq_printf(m, "\n"); +#endif /* CIFS_DEBUG2 */ + } + spin_unlock(&tcon->open_file_lock); + } + } + } + spin_unlock(&cifs_tcp_ses_lock); + seq_putc(m, '\n'); + return 0; +} + static int cifs_debug_data_proc_show(struct seq_file *m, void *v) { struct list_head *tmp1, *tmp2, *tmp3; @@ -565,6 +611,9 @@ cifs_proc_init(void) proc_create_single("DebugData", 0, proc_fs_cifs, cifs_debug_data_proc_show); + proc_create_single("open_files", 0400, proc_fs_cifs, + cifs_debug_files_proc_show); + proc_create("Stats", 0644, proc_fs_cifs, &cifs_stats_proc_fops); proc_create("cifsFYI", 0644, proc_fs_cifs, &cifsFYI_proc_fops); proc_create("traceSMB", 0644, proc_fs_cifs, &traceSMB_proc_fops); @@ -601,6 +650,7 @@ cifs_proc_clean(void) return; remove_proc_entry("DebugData", proc_fs_cifs); + remove_proc_entry("open_files", proc_fs_cifs); remove_proc_entry("cifsFYI", proc_fs_cifs); remove_proc_entry("traceSMB", proc_fs_cifs); remove_proc_entry("Stats", proc_fs_cifs); diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index ed1e0fcb69e3..d7c0443d47a4 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -1125,6 +1125,9 @@ struct cifs_fid { __u8 create_guid[16]; struct cifs_pending_open *pending_open; unsigned int epoch; +#ifdef CONFIG_CIFS_DEBUG2 + __u64 mid; +#endif /* CIFS_DEBUG2 */ bool purge_cache; }; diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index f85fc5aa2710..61cfd7028a9e 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1078,6 +1078,9 @@ smb2_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock) cfile->fid.persistent_fid = fid->persistent_fid; cfile->fid.volatile_fid = fid->volatile_fid; +#ifdef CONFIG_CIFS_DEBUG2 + cfile->fid.mid = fid->mid; +#endif /* CIFS_DEBUG2 */ server->ops->set_oplock_level(cinode, oplock, fid->epoch, &fid->purge_cache); cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode); diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 5a08c8f6a322..b83bc3f03a23 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2306,6 +2306,9 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, atomic_inc(&tcon->num_remote_opens); oparms->fid->persistent_fid = rsp->PersistentFileId; oparms->fid->volatile_fid = rsp->VolatileFileId; +#ifdef CONFIG_CIFS_DEBUG2 + oparms->fid->mid = le64_to_cpu(rsp->sync_hdr.MessageId); +#endif /* CIFS_DEBUG2 */ if (buf) { memcpy(buf, &rsp->CreationTime, 32); -- 2.17.1