Skip to content

Commit d8392c2

Browse files
committed
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 <[email protected]> Reviewed-by: Bharath SM <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 8ca5d26 commit d8392c2

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

fs/smb/client/cifs_debug.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
659659
spin_lock(&tcon->stat_lock);
660660
tcon->bytes_read = 0;
661661
tcon->bytes_written = 0;
662+
tcon->stats_from_time = ktime_get_real_seconds();
662663
spin_unlock(&tcon->stat_lock);
663664
if (server->ops->clear_stats)
664665
server->ops->clear_stats(tcon);
@@ -737,8 +738,9 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
737738
seq_printf(m, "\n%d) %s", i, tcon->tree_name);
738739
if (tcon->need_reconnect)
739740
seq_puts(m, "\tDISCONNECTED ");
740-
seq_printf(m, "\nSMBs: %d",
741-
atomic_read(&tcon->num_smbs_sent));
741+
seq_printf(m, "\nSMBs: %d since %ptTs UTC",
742+
atomic_read(&tcon->num_smbs_sent),
743+
&tcon->stats_from_time);
742744
if (server->ops->print_stats)
743745
server->ops->print_stats(m, tcon);
744746
}

fs/smb/client/cifsglob.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,7 @@ struct cifs_tcon {
12071207
__u64 bytes_read;
12081208
__u64 bytes_written;
12091209
spinlock_t stat_lock; /* protects the two fields above */
1210+
time64_t stats_from_time;
12101211
FILE_SYSTEM_DEVICE_INFO fsDevInfo;
12111212
FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if fs name truncated */
12121213
FILE_SYSTEM_UNIX_INFO fsUnixInfo;

fs/smb/client/misc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ tcon_info_alloc(bool dir_leases_enabled)
140140
spin_lock_init(&ret_buf->stat_lock);
141141
atomic_set(&ret_buf->num_local_opens, 0);
142142
atomic_set(&ret_buf->num_remote_opens, 0);
143+
ret_buf->stats_from_time = ktime_get_real_seconds();
143144
#ifdef CONFIG_CIFS_DFS_UPCALL
144145
INIT_LIST_HEAD(&ret_buf->dfs_ses_list);
145146
#endif

0 commit comments

Comments
 (0)