Skip to content

Commit 468d677

Browse files
author
Steve French
committed
smb3: display stats counters for number of slow commands
When CONFIG_CIFS_STATS2 is enabled keep counters for slow commands (ie server took longer than 1 second to respond) by SMB2/SMB3 command code. This can help in diagnosing whether performance problems are on server (instead of client) and which commands are causing the problem. Sample output (the new lines contain words "slow responses ...") $ cat /proc/fs/cifs/Stats Resources in use CIFS Session: 1 Share (unique mount targets): 2 SMB Request/Response Buffer: 1 Pool size: 5 SMB Small Req/Resp Buffer: 1 Pool size: 30 Total Large 10 Small 490 Allocations Operations (MIDs): 0 0 session 0 share reconnects Total vfs operations: 67 maximum at one time: 2 4 slow responses from localhost for command 5 1 slow responses from localhost for command 6 1 slow responses from localhost for command 14 1 slow responses from localhost for command 16 1) \\localhost\test SMBs: 243 Bytes read: 1024000 Bytes written: 104857600 TreeConnects: 1 total 0 failed TreeDisconnects: 0 total 0 failed Creates: 40 total 0 failed Closes: 39 total 0 failed ... Signed-off-by: Steve French <[email protected]> Reviewed-by: Pavel Shilovsky <[email protected]> Reviewed-by: Aurelien Aptel <[email protected]>
1 parent a5c62f4 commit 468d677

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

fs/cifs/cifs_debug.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
378378
rc = kstrtobool_from_user(buffer, count, &bv);
379379
if (rc == 0) {
380380
#ifdef CONFIG_CIFS_STATS2
381+
int i;
382+
381383
atomic_set(&totBufAllocCount, 0);
382384
atomic_set(&totSmBufAllocCount, 0);
383385
#endif /* CONFIG_CIFS_STATS2 */
@@ -389,6 +391,10 @@ static ssize_t cifs_stats_proc_write(struct file *file,
389391
list_for_each(tmp1, &cifs_tcp_ses_list) {
390392
server = list_entry(tmp1, struct TCP_Server_Info,
391393
tcp_ses_list);
394+
#ifdef CONFIG_CIFS_STATS2
395+
for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++)
396+
atomic_set(&server->smb2slowcmd[i], 0);
397+
#endif /* CONFIG_CIFS_STATS2 */
392398
list_for_each(tmp2, &server->smb_ses_list) {
393399
ses = list_entry(tmp2, struct cifs_ses,
394400
smb_ses_list);
@@ -417,13 +423,15 @@ static ssize_t cifs_stats_proc_write(struct file *file,
417423
static int cifs_stats_proc_show(struct seq_file *m, void *v)
418424
{
419425
int i;
426+
#ifdef CONFIG_CIFS_STATS2
427+
int j;
428+
#endif /* STATS2 */
420429
struct list_head *tmp1, *tmp2, *tmp3;
421430
struct TCP_Server_Info *server;
422431
struct cifs_ses *ses;
423432
struct cifs_tcon *tcon;
424433

425-
seq_printf(m,
426-
"Resources in use\nCIFS Session: %d\n",
434+
seq_printf(m, "Resources in use\nCIFS Session: %d\n",
427435
sesInfoAllocCount.counter);
428436
seq_printf(m, "Share (unique mount targets): %d\n",
429437
tconInfoAllocCount.counter);
@@ -452,6 +460,13 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
452460
list_for_each(tmp1, &cifs_tcp_ses_list) {
453461
server = list_entry(tmp1, struct TCP_Server_Info,
454462
tcp_ses_list);
463+
#ifdef CONFIG_CIFS_STATS2
464+
for (j = 0; j < NUMBER_OF_SMB2_COMMANDS; j++)
465+
if (atomic_read(&server->smb2slowcmd[j]))
466+
seq_printf(m, "%d slow responses from %s for command %d\n",
467+
atomic_read(&server->smb2slowcmd[j]),
468+
server->hostname, j);
469+
#endif /* STATS2 */
455470
list_for_each(tmp2, &server->smb_ses_list) {
456471
ses = list_entry(tmp2, struct cifs_ses,
457472
smb_ses_list);

fs/cifs/cifsglob.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,8 @@ struct TCP_Server_Info {
680680
#ifdef CONFIG_CIFS_STATS2
681681
atomic_t in_send; /* requests trying to send */
682682
atomic_t num_waiters; /* blocked waiting to get in sendrecv */
683-
#endif
683+
atomic_t smb2slowcmd[NUMBER_OF_SMB2_COMMANDS]; /* count resps > 1 sec */
684+
#endif /* STATS2 */
684685
unsigned int max_read;
685686
unsigned int max_write;
686687
__le16 cipher_type;

fs/cifs/transport.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ DeleteMidQEntry(struct mid_q_entry *midEntry)
117117
something is wrong, unless it is quite a slow link or server */
118118
if (time_after(now, midEntry->when_alloc + HZ) &&
119119
(midEntry->command != command)) {
120+
/* smb2slowcmd[NUMBER_OF_SMB2_COMMANDS] counts by command */
121+
if ((le16_to_cpu(midEntry->command) < NUMBER_OF_SMB2_COMMANDS) &&
122+
(le16_to_cpu(midEntry->command) >= 0))
123+
cifs_stats_inc(&midEntry->server->smb2slowcmd[le16_to_cpu(midEntry->command)]);
124+
120125
trace_smb3_slow_rsp(le16_to_cpu(midEntry->command),
121126
midEntry->mid, midEntry->pid,
122127
midEntry->when_sent, midEntry->when_received);

0 commit comments

Comments
 (0)