From patchwork Thu Nov 9 21:51:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 1862263 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=PALDFFI5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:4601:e00::3; helo=am.mirrors.kernel.org; envelope-from=linux-cifs+bounces-37-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SRFzh47K1z1yQy for ; Fri, 10 Nov 2023 08:52:16 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E6B461F21029 for ; Thu, 9 Nov 2023 21:52:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E4FA38F87; Thu, 9 Nov 2023 21:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PALDFFI5" X-Original-To: linux-cifs@vger.kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 366E638DF9 for ; Thu, 9 Nov 2023 21:52:10 +0000 (UTC) Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78B1E421B for ; Thu, 9 Nov 2023 13:52:09 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-507a5f2193bso1534406e87.1 for ; Thu, 09 Nov 2023 13:52:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699566727; x=1700171527; darn=vger.kernel.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=71N0m59xLukcDdkm4W+JIoiwHE7GiSCCkWsEYwiOgD4=; b=PALDFFI5KqInzo1nk/ez1eoxbpx/yjgL3TPTOV9TzB5hq/X6oJIFtvYEDfPNIAJ8Dm BZ5EjbFeag0KqOmT9JeLiw+dFlW4dDZuV7MMEEJOy5jUOcxzuIz0jGBjHz2kY+S8CYdf tWsKQNLjpn1BExGtv9owrZA9rgvpLLl/GZ3Fcw2hry2CedrMecq0o/+oks5df2tC8D69 NLnxm4P6WBvhPRNl80yFeCJ3QnXzA41ArCvO6JNVgNbULHWFz6fCxk8NFIzInFNZlj6s JowheMorFECO4z8Jb5aHo16mhNgumoAdZPZ6Mo6R+C4SsjS6DLwWtrQRdeBh0KnApW0X 11Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699566727; x=1700171527; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=71N0m59xLukcDdkm4W+JIoiwHE7GiSCCkWsEYwiOgD4=; b=qBa7fTXCr6sROOZoMKGRfbO3FtR3vvIfKPssqupZgycw8JwnN+dSVoQJLuI9Vcjwc5 0dmMP/TdLuR0DkHu316rVdQoeJMXAcl4SN8UbpwWiFv4c+ZwhLXMrplh5kncq6WSj1Cd aR0fjn3wTATRgrpwIIqvuF1qPAPwW5CZFY3TG0SJyNCoOsIi1gDfp+LX6sT/3tGW3xQD mRNneeGydH3I/Nk8yFXZT+EucHG9T38+0BD3mx+5bS0bZheaKfq3HjD9eXHVonuWAnuT CF5D6jdtdK3NT63xcEgziZQ96W1FQa6ot4vGq4B8ilTZ33w197UC4ePuDtpD1kkJRfoA uqkQ== X-Gm-Message-State: AOJu0YwiqRqQWzNYwG9dTaE7jvn2GLgpjLU8PfOryfzrUkSjcN1+O+gH MK8Sqgu6xBDPYxbtNMWSGh0uJX+B3Erh5aKUgR8G5vUTa6ISEf3J1dU= X-Google-Smtp-Source: AGHT+IGvEwR5spf34RJevg9oaG4NQSFW8MnTxOFoHMOBxPSPjaf/pCxyTIZyLN1nDPydcRHYL23zuXdey/PEq4vIwcs= X-Received: by 2002:a19:ad0d:0:b0:501:b929:48af with SMTP id t13-20020a19ad0d000000b00501b92948afmr217206lfc.34.1699566727022; Thu, 09 Nov 2023 13:52:07 -0800 (PST) Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Steve French Date: Thu, 9 Nov 2023 15:51:55 -0600 Message-ID: Subject: [PATCH][smb3 client] allow debugging session and tcon info to improve stats analysis and debugging To: CIFS , samba-technical [PATCH] smb3: allow debugging session and tcon info to improve stats analysis and debugging When multiple mounts are to the same share from the same client it was not possible to determine which section of /proc/fs/cifs/Stats (and DebugData) correspond to that mount. In some recent examples this turned out to be a significant problem when trying to analyze performance problems - since there are many cases where unless we know the tree id and session id we can't figure out which stats (e.g. number of SMB3.1.1 requests by type, the total time they take, which is slowest, how many fail etc.) apply to which mount. Add an ioctl to return tid, session id, tree connect count and tcon flags. From 54796a555a55c40ff61b14f574a139c912cffded Mon Sep 17 00:00:00 2001 From: Steve French Date: Thu, 9 Nov 2023 15:28:12 -0600 Subject: [PATCH] smb3: allow debugging session and tcon info to improve stats analysis and debugging When multiple mounts are to the same share from the same client it was not possible to determine which section of /proc/fs/cifs/Stats (and DebugData) correspond to that mount. In some recent examples this turned out to be a significant problem when trying to analyze performance problems - since there are many cases where unless we know the tree id and session id we can't figure out which stats (e.g. number of SMB3.1.1 requests by type, the total time they take, which is slowest, how many fail etc.) apply to which mount. Add an ioctl to return tid, session id, tree connect count and tcon flags. Signed-off-by: Steve French --- fs/smb/client/cifs_ioctl.h | 8 ++++++++ fs/smb/client/ioctl.c | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/fs/smb/client/cifs_ioctl.h b/fs/smb/client/cifs_ioctl.h index 332588e77c31..2eb0a747b6c3 100644 --- a/fs/smb/client/cifs_ioctl.h +++ b/fs/smb/client/cifs_ioctl.h @@ -26,6 +26,13 @@ struct smb_mnt_fs_info { __u64 cifs_posix_caps; } __packed; +struct smb_mnt_tcon_info { + __u32 tid; + __u64 session_id; + int tc_count; + __u16 flags; +} __packed; + struct smb_snapshot_array { __u32 number_of_snapshots; __u32 number_of_snapshots_returned; @@ -108,6 +115,7 @@ struct smb3_notify_info { #define CIFS_IOC_NOTIFY _IOW(CIFS_IOCTL_MAGIC, 9, struct smb3_notify) #define CIFS_DUMP_FULL_KEY _IOWR(CIFS_IOCTL_MAGIC, 10, struct smb3_full_key_debug_info) #define CIFS_IOC_NOTIFY_INFO _IOWR(CIFS_IOCTL_MAGIC, 11, struct smb3_notify_info) +#define CIFS_IOC_GET_TCON_INFO _IOR(CIFS_IOCTL_MAGIC, 12, struct smb_mnt_tcon_info) #define CIFS_IOC_SHUTDOWN _IOR('X', 125, __u32) /* diff --git a/fs/smb/client/ioctl.c b/fs/smb/client/ioctl.c index f7160003e0ed..8000433407df 100644 --- a/fs/smb/client/ioctl.c +++ b/fs/smb/client/ioctl.c @@ -117,6 +117,22 @@ static long cifs_ioctl_copychunk(unsigned int xid, struct file *dst_file, return rc; } +static long smb_mnt_get_tcon_info(struct cifs_tcon *tcon, void __user *arg) +{ + int rc = 0; + struct smb_mnt_tcon_info tcon_inf; + + tcon_inf.tid = tcon->tid; + tcon_inf.session_id = tcon->ses->Suid; + tcon_inf.tc_count = tcon->tc_count; + tcon_inf.flags = tcon->Flags; + + if (copy_to_user(arg, &tcon_inf, sizeof(struct smb_mnt_tcon_info))) + rc = -EFAULT; + + return rc; +} + static long smb_mnt_get_fsinfo(unsigned int xid, struct cifs_tcon *tcon, void __user *arg) { @@ -414,6 +430,16 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg) tcon = tlink_tcon(pSMBFile->tlink); rc = smb_mnt_get_fsinfo(xid, tcon, (void __user *)arg); break; + case CIFS_IOC_GET_TCON_INFO: + cifs_sb = CIFS_SB(inode->i_sb); + tlink = cifs_sb_tlink(cifs_sb); + if (IS_ERR(tlink)) { + rc = PTR_ERR(tlink); + break; + } + tcon = tlink_tcon(tlink); + rc = smb_mnt_get_tcon_info(tcon, (void __user *)arg); + break; case CIFS_ENUMERATE_SNAPSHOTS: if (pSMBFile == NULL) break; -- 2.39.2