From patchwork Wed Jan 17 22:28:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 13522219 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7102025569 for ; Wed, 17 Jan 2024 22:28:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705530507; cv=none; b=R1S+nXiVbkRNQUB99qSqD4x0JzjxNTYDzcpxh+PXOaTDgm9Awz1Meye2eWwThhgL8yLgv0VcwJcvqYDRNcBgDkFZLRo6pRnLNlkHzYDPi1Jfd90wiaeddmohfvK91n3DGxlQZd349PvX7vcfihcwGwCJ2yDJDpADttCizSaYhe8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705530507; c=relaxed/simple; bh=NAMc9Npooyg9jZZEHHnvXWkj8ltsHkd8vcYv7r5Fs68=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:MIME-Version: From:Date:Message-ID:Subject:To:Cc:Content-Type; b=oBIwPTAsAEPECM+n5pFqK0hjyPrkUg+vej5jjb9CSKNdIIdGqAZzZ6CbduPp5KMA6MH63QeKJ7kpAVNnzNyl/XXYD+DFuANh7TfYzzcv+251PucttbrPgfopDFVZPkjgBCtvjQxhMucSLFubynjEdtqtyosYpGGOKiX1Q/rKBL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JnRtX4AU; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JnRtX4AU" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-50eabd1c701so14435263e87.3 for ; Wed, 17 Jan 2024 14:28:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705530503; x=1706135303; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=84XkGLvsoppwnjCl11vVf4LSthAdwJOsUjCsA2aCCuo=; b=JnRtX4AU2l5hd/t9Gbep7ci1mb7coPcciGrkOSBr8mde9crw3lr1+y/zQWn8SZAlnz /ekWbOw5gO9TLo3O3jgAIjBaJ0bPdYuSrkyiiAeXJlnHA0SLLL0LxWdEUkYZfAtFSbXW 3YWZ3lale4jnDAKUa28OkN2RBxKyBaN+UvWigyWXQRvVfsIC4tCfdRZDx+SlMWJZ0crV 2LZFf+e7MsBwtTwlB0oQ+ORr315LMBxwXaC/LVpuo5wyCMFa+NY26GJU1xSlFqjLLnQe bx61R83swnj3VFT8vo+nC+s0gQs0SPrNwaE5H/9QA5owJHGS3F43qXL+sNlLLreMbGnc ZOhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705530503; x=1706135303; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=84XkGLvsoppwnjCl11vVf4LSthAdwJOsUjCsA2aCCuo=; b=flqhst57MfFaeOIhhiqmYmzHQOndro0MY6Qn/+RkG5DM+FS3lSRoTS7bhucBb9RtcF 8001f56/pdYU93ijC8pv7KzsizqpPz7fquKcO0fj6V6FQx0QXWHUxTWaw+kX63M6dozL A7H2z8Czyk/1mfnvpQT3RZPQlXlvvrkqwdyWZ1D2yuJaxV0/ivIdqV2O8cy9kPu9Ns1e F3HT3O18r7ZO7EkU11vzhCqdAnCdo4tQgy5VeIn13apjL2o1AVTCb9a/XG9z/zAlSEV0 /CQjeLcfsE4tNjKTLtA4QatfsCoT6/jGjDE7FbgsIe5TMgSux1odksOQRjgXxtpKrDMa FSvw== X-Gm-Message-State: AOJu0Yzn3eZMhEwTbv7PlwNmSiNRqrcUy0JmZQ4xinE36a0G/qMfFuYP quSWO4XgfREYya+9t1jru5n0og13oYIDNcGRxUpNHWR08USZYA== X-Google-Smtp-Source: AGHT+IHe7584WO2xjM8XG8HJoRVvKIZLd9hxhb9ZJhjMK1Tvg7ut6/cLj1Di9DSsrG8/t5h3dzqYX3zEua7QPyfLlZU= X-Received: by 2002:ac2:46e9:0:b0:50e:7b0d:5b66 with SMTP id q9-20020ac246e9000000b0050e7b0d5b66mr4561023lfo.73.1705530502845; Wed, 17 Jan 2024 14:28:22 -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: Wed, 17 Jan 2024 16:28:11 -0600 Message-ID: Subject: [PATCH][SMB3 client] show beginning time for per share stats To: CIFS Cc: Shyam Prasad N , samba-technical In analyzing problems, one missing piece of debug data is when the mount occurred. A related problem is when collecting stats we don't know the period of time the stats covered, ie when this set of stats for the tcon started to be collected. To make debugging easier track the stats begin time. Set it when the mount occurred at mount time, and reset it to current time whenever stats are reset. For example, ... 1) \\localhost\test SMBs: 14 since 2024-01-17 22:17:30 UTC Bytes read: 0 Bytes written: 0 Open files: 0 total (local), 0 open on server TreeConnects: 1 total 0 failed TreeDisconnects: 0 total 0 failed ... 2) \\localhost\scratch SMBs: 24 since 2024-01-17 22:16:04 UTC Bytes read: 0 Bytes written: 0 Open files: 0 total (local), 0 open on server TreeConnects: 1 total 0 failed TreeDisconnects: 0 total 0 failed ... Note the time "since ... UTC" is now displayed in /proc/fs/cifs/Stats for each share that is mounted. See attached From 1142c1a922d5681cf44c84c653dc8104fb32933b Mon Sep 17 00:00:00 2001 From: Steve French Date: Wed, 17 Jan 2024 16:15:18 -0600 Subject: [PATCH] smb3: show beginning time for per share stats In analyzing problems, one missing piece of debug data is when the mount occurred. A related problem is when collecting stats we don't know the period of time the stats covered, ie when this set of stats for the tcon started to be collected. To make debugging easier track the stats begin time. Set it when the mount occurred at mount time, and reset it to current time whenever stats are reset. For example, ... 1) \\localhost\test SMBs: 14 since 2024-01-17 22:17:30 UTC Bytes read: 0 Bytes written: 0 Open files: 0 total (local), 0 open on server TreeConnects: 1 total 0 failed TreeDisconnects: 0 total 0 failed ... 2) \\localhost\scratch SMBs: 24 since 2024-01-17 22:16:04 UTC Bytes read: 0 Bytes written: 0 Open files: 0 total (local), 0 open on server TreeConnects: 1 total 0 failed TreeDisconnects: 0 total 0 failed ... Note the time "since ... UTC" is now displayed in /proc/fs/cifs/Stats for each share that is mounted. Suggested-by: Shyam Prasad N Signed-off-by: Steve French --- fs/smb/client/cifs_debug.c | 6 ++++-- fs/smb/client/cifsglob.h | 1 + fs/smb/client/misc.c | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/cifs_debug.c b/fs/smb/client/cifs_debug.c index 60027f5aebe8..3e4209f41c18 100644 --- a/fs/smb/client/cifs_debug.c +++ b/fs/smb/client/cifs_debug.c @@ -659,6 +659,7 @@ static ssize_t cifs_stats_proc_write(struct file *file, spin_lock(&tcon->stat_lock); tcon->bytes_read = 0; tcon->bytes_written = 0; + tcon->stats_from_time = ktime_get_real_seconds(); spin_unlock(&tcon->stat_lock); if (server->ops->clear_stats) server->ops->clear_stats(tcon); @@ -737,8 +738,9 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v) seq_printf(m, "\n%d) %s", i, tcon->tree_name); if (tcon->need_reconnect) seq_puts(m, "\tDISCONNECTED "); - seq_printf(m, "\nSMBs: %d", - atomic_read(&tcon->num_smbs_sent)); + seq_printf(m, "\nSMBs: %d since %ptTs UTC", + atomic_read(&tcon->num_smbs_sent), + &tcon->stats_from_time); if (server->ops->print_stats) server->ops->print_stats(m, tcon); } diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index 879d5ef8a66e..f576ceee6157 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -1207,6 +1207,7 @@ struct cifs_tcon { __u64 bytes_read; __u64 bytes_written; spinlock_t stat_lock; /* protects the two fields above */ + time64_t stats_from_time; FILE_SYSTEM_DEVICE_INFO fsDevInfo; FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if fs name truncated */ FILE_SYSTEM_UNIX_INFO fsUnixInfo; diff --git a/fs/smb/client/misc.c b/fs/smb/client/misc.c index c2137ea3c253..0748d7b757b9 100644 --- a/fs/smb/client/misc.c +++ b/fs/smb/client/misc.c @@ -140,6 +140,7 @@ tcon_info_alloc(bool dir_leases_enabled) spin_lock_init(&ret_buf->stat_lock); atomic_set(&ret_buf->num_local_opens, 0); atomic_set(&ret_buf->num_remote_opens, 0); + ret_buf->stats_from_time = ktime_get_real_seconds(); #ifdef CONFIG_CIFS_DFS_UPCALL INIT_LIST_HEAD(&ret_buf->dfs_ses_list); #endif -- 2.40.1