mirror of https://gitee.com/openkylin/linux.git
smb3: show number of current open files in /proc/fs/cifs/Stats
To allow better debugging (for example applications with handle leaks, or complex reconnect scenarios) display the number of open files (on the client) and number of open server file handles for each tcon in /proc/fs/cifs/Stats. Note that open files on server is one larger than local due to handle caching (in this case of the root of the share). In this example there are two local open files, and three (two file and one directory handle) open on the server. Sample output: $ 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 Operations (MIDs): 0 0 session 0 share reconnects Total vfs operations: 36 maximum at one time: 2 1) \\localhost\test SMBs: 69 Bytes read: 27 Bytes written: 0 Open files: 2 total (local), 3 open on server TreeConnects: 1 total 0 failed TreeDisconnects: 0 total 0 failed Creates: 19 total 0 failed Closes: 16 total 0 failed ... Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
parent
8d8b26e584
commit
fae8044c03
|
@ -932,6 +932,8 @@ struct cifs_tcon {
|
|||
struct list_head tcon_list;
|
||||
int tc_count;
|
||||
struct list_head rlist; /* reconnect list */
|
||||
atomic_t num_local_opens; /* num of all opens including disconnected */
|
||||
atomic_t num_remote_opens; /* num of all network opens on server */
|
||||
struct list_head openFileList;
|
||||
spinlock_t open_file_lock; /* protects list above */
|
||||
struct cifs_ses *ses; /* pointer to session associated with */
|
||||
|
|
|
@ -334,6 +334,7 @@ cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,
|
|||
server->ops->set_fid(cfile, fid, oplock);
|
||||
|
||||
list_add(&cfile->tlist, &tcon->openFileList);
|
||||
atomic_inc(&tcon->num_local_opens);
|
||||
|
||||
/* if readable file instance put first in list*/
|
||||
if (file->f_mode & FMODE_READ)
|
||||
|
@ -395,6 +396,7 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file)
|
|||
/* remove it from the lists */
|
||||
list_del(&cifs_file->flist);
|
||||
list_del(&cifs_file->tlist);
|
||||
atomic_dec(&tcon->num_local_opens);
|
||||
|
||||
if (list_empty(&cifsi->openFileList)) {
|
||||
cifs_dbg(FYI, "closing last open instance for inode %p\n",
|
||||
|
|
|
@ -123,6 +123,8 @@ tconInfoAlloc(void)
|
|||
ret_buf->crfid.fid = kzalloc(sizeof(struct cifs_fid),
|
||||
GFP_KERNEL);
|
||||
spin_lock_init(&ret_buf->stat_lock);
|
||||
atomic_set(&ret_buf->num_local_opens, 0);
|
||||
atomic_set(&ret_buf->num_remote_opens, 0);
|
||||
}
|
||||
return ret_buf;
|
||||
}
|
||||
|
|
|
@ -1023,6 +1023,9 @@ smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
|
|||
seq_printf(m, "\nBytes read: %llu Bytes written: %llu",
|
||||
(long long)(tcon->bytes_read),
|
||||
(long long)(tcon->bytes_written));
|
||||
seq_printf(m, "\nOpen files: %d total (local), %d open on server",
|
||||
atomic_read(&tcon->num_local_opens),
|
||||
atomic_read(&tcon->num_remote_opens));
|
||||
seq_printf(m, "\nTreeConnects: %d total %d failed",
|
||||
atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
|
||||
atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
|
||||
|
|
|
@ -1478,7 +1478,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
|
|||
|
||||
/* SMB2 TREE_CONNECT request must be called with TreeId == 0 */
|
||||
tcon->tid = 0;
|
||||
|
||||
atomic_set(&tcon->num_remote_opens, 0);
|
||||
rc = smb2_plain_req_init(SMB2_TREE_CONNECT, tcon, (void **) &req,
|
||||
&total_len);
|
||||
if (rc) {
|
||||
|
@ -2303,6 +2303,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
|
|||
ses->Suid, oparms->create_options,
|
||||
oparms->desired_access);
|
||||
|
||||
atomic_inc(&tcon->num_remote_opens);
|
||||
oparms->fid->persistent_fid = rsp->PersistentFileId;
|
||||
oparms->fid->volatile_fid = rsp->VolatileFileId;
|
||||
|
||||
|
@ -2577,6 +2578,8 @@ SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon,
|
|||
goto close_exit;
|
||||
}
|
||||
|
||||
atomic_dec(&tcon->num_remote_opens);
|
||||
|
||||
/* BB FIXME - decode close response, update inode for caching */
|
||||
|
||||
close_exit:
|
||||
|
|
Loading…
Reference in New Issue