Skip to content

Commit de4ecea

Browse files
author
Steve French
committed
smb3: allow dumping session and tcon id 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 data - 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. The only existing loosely related ioctl CIFS_IOC_GET_MNT_INFO does not return the information needed to uniquely identify which tcon is which mount although it does return various flags and device info. Add a cifs.ko ioctl CIFS_IOC_GET_TCON_INFO (0x800ccf0c) to return tid, session id, tree connect count. Cc: [email protected] Reviewed-by: Shyam Prasad N <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 5e2fd17 commit de4ecea

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

fs/smb/client/cifs_ioctl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ struct smb_mnt_fs_info {
2626
__u64 cifs_posix_caps;
2727
} __packed;
2828

29+
struct smb_mnt_tcon_info {
30+
__u32 tid;
31+
__u64 session_id;
32+
} __packed;
33+
2934
struct smb_snapshot_array {
3035
__u32 number_of_snapshots;
3136
__u32 number_of_snapshots_returned;
@@ -108,6 +113,7 @@ struct smb3_notify_info {
108113
#define CIFS_IOC_NOTIFY _IOW(CIFS_IOCTL_MAGIC, 9, struct smb3_notify)
109114
#define CIFS_DUMP_FULL_KEY _IOWR(CIFS_IOCTL_MAGIC, 10, struct smb3_full_key_debug_info)
110115
#define CIFS_IOC_NOTIFY_INFO _IOWR(CIFS_IOCTL_MAGIC, 11, struct smb3_notify_info)
116+
#define CIFS_IOC_GET_TCON_INFO _IOR(CIFS_IOCTL_MAGIC, 12, struct smb_mnt_tcon_info)
111117
#define CIFS_IOC_SHUTDOWN _IOR('X', 125, __u32)
112118

113119
/*

fs/smb/client/ioctl.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,20 @@ static long cifs_ioctl_copychunk(unsigned int xid, struct file *dst_file,
117117
return rc;
118118
}
119119

120+
static long smb_mnt_get_tcon_info(struct cifs_tcon *tcon, void __user *arg)
121+
{
122+
int rc = 0;
123+
struct smb_mnt_tcon_info tcon_inf;
124+
125+
tcon_inf.tid = tcon->tid;
126+
tcon_inf.session_id = tcon->ses->Suid;
127+
128+
if (copy_to_user(arg, &tcon_inf, sizeof(struct smb_mnt_tcon_info)))
129+
rc = -EFAULT;
130+
131+
return rc;
132+
}
133+
120134
static long smb_mnt_get_fsinfo(unsigned int xid, struct cifs_tcon *tcon,
121135
void __user *arg)
122136
{
@@ -414,6 +428,17 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
414428
tcon = tlink_tcon(pSMBFile->tlink);
415429
rc = smb_mnt_get_fsinfo(xid, tcon, (void __user *)arg);
416430
break;
431+
case CIFS_IOC_GET_TCON_INFO:
432+
cifs_sb = CIFS_SB(inode->i_sb);
433+
tlink = cifs_sb_tlink(cifs_sb);
434+
if (IS_ERR(tlink)) {
435+
rc = PTR_ERR(tlink);
436+
break;
437+
}
438+
tcon = tlink_tcon(tlink);
439+
rc = smb_mnt_get_tcon_info(tcon, (void __user *)arg);
440+
cifs_put_tlink(tlink);
441+
break;
417442
case CIFS_ENUMERATE_SNAPSHOTS:
418443
if (pSMBFile == NULL)
419444
break;

0 commit comments

Comments
 (0)