Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

smb3: add dynamic trace points for tree disconnect

Needed this for debugging a failing xfstest.
Also change camel case for "treeName" to "tree_name" in tcon struct.

Example trace output (from "trace-cmd record -e smb3_tdis*"):
umount-9718 [006] ..... 5909.780244: smb3_tdis_enter: xid=206 sid=0xcf38894e tid=0x3d0b8cf8 path=\\localhost\test
umount-9718 [007] ..... 5909.780878: smb3_tdis_done: xid=206 sid=0xcf38894e tid=0x3d0b8cf8

Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>

+46 -38
+1 -1
fs/cifs/cached_dir.c
··· 160 160 if (rc == -EREMCHG) { 161 161 tcon->need_reconnect = true; 162 162 pr_warn_once("server share %s deleted\n", 163 - tcon->treeName); 163 + tcon->tree_name); 164 164 } 165 165 goto oshr_exit; 166 166 }
+2 -2
fs/cifs/cifs_debug.c
··· 87 87 { 88 88 __u32 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); 89 89 90 - seq_printf(m, "%s Mounts: %d ", tcon->treeName, tcon->tc_count); 90 + seq_printf(m, "%s Mounts: %d ", tcon->tree_name, tcon->tc_count); 91 91 if (tcon->nativeFileSystem) 92 92 seq_printf(m, "Type: %s ", tcon->nativeFileSystem); 93 93 seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x\n\tPathComponentMax: %d Status: %d", ··· 601 601 list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { 602 602 list_for_each_entry(tcon, &ses->tcon_list, tcon_list) { 603 603 i++; 604 - seq_printf(m, "\n%d) %s", i, tcon->treeName); 604 + seq_printf(m, "\n%d) %s", i, tcon->tree_name); 605 605 if (tcon->need_reconnect) 606 606 seq_puts(m, "\tDISCONNECTED "); 607 607 seq_printf(m, "\nSMBs: %d",
+3 -3
fs/cifs/cifs_debug.h
··· 108 108 #define cifs_tcon_dbg_func(ratefunc, type, fmt, ...) \ 109 109 do { \ 110 110 const char *tn = ""; \ 111 - if (tcon && tcon->treeName) \ 112 - tn = tcon->treeName; \ 111 + if (tcon && tcon->tree_name) \ 112 + tn = tcon->tree_name; \ 113 113 if ((type) & FYI && cifsFYI & CIFS_INFO) { \ 114 114 pr_debug_ ## ratefunc("%s: %s " fmt, \ 115 115 __FILE__, tn, ##__VA_ARGS__); \ ··· 150 150 #define cifs_tcon_dbg(type, fmt, ...) \ 151 151 do { \ 152 152 if (0) \ 153 - pr_debug("%s " fmt, tcon->treeName, ##__VA_ARGS__); \ 153 + pr_debug("%s " fmt, tcon->tree_name, ##__VA_ARGS__); \ 154 154 } while (0) 155 155 156 156 #define cifs_info(fmt, ...) \
+6 -6
fs/cifs/cifs_swn.c
··· 256 256 const char *share_name; 257 257 const char *net_name; 258 258 259 - net_name = extract_hostname(tcon->treeName); 259 + net_name = extract_hostname(tcon->tree_name); 260 260 if (IS_ERR(net_name)) { 261 261 int ret; 262 262 263 263 ret = PTR_ERR(net_name); 264 264 cifs_dbg(VFS, "%s: failed to extract host name from target '%s': %d\n", 265 - __func__, tcon->treeName, ret); 265 + __func__, tcon->tree_name, ret); 266 266 return ERR_PTR(-EINVAL); 267 267 } 268 268 269 - share_name = extract_sharename(tcon->treeName); 269 + share_name = extract_sharename(tcon->tree_name); 270 270 if (IS_ERR(share_name)) { 271 271 int ret; 272 272 273 273 ret = PTR_ERR(share_name); 274 274 cifs_dbg(VFS, "%s: failed to extract share name from target '%s': %d\n", 275 - __func__, tcon->treeName, ret); 275 + __func__, tcon->tree_name, ret); 276 276 kfree(net_name); 277 277 return ERR_PTR(-EINVAL); 278 278 } ··· 335 335 goto fail; 336 336 } 337 337 338 - reg->net_name = extract_hostname(tcon->treeName); 338 + reg->net_name = extract_hostname(tcon->tree_name); 339 339 if (IS_ERR(reg->net_name)) { 340 340 ret = PTR_ERR(reg->net_name); 341 341 cifs_dbg(VFS, "%s: failed to extract host name from target: %d\n", __func__, ret); 342 342 goto fail_idr; 343 343 } 344 344 345 - reg->share_name = extract_sharename(tcon->treeName); 345 + reg->share_name = extract_sharename(tcon->tree_name); 346 346 if (IS_ERR(reg->share_name)) { 347 347 ret = PTR_ERR(reg->share_name); 348 348 cifs_dbg(VFS, "%s: failed to extract share name from target: %d\n", __func__, ret);
+1 -1
fs/cifs/cifsglob.h
··· 1149 1149 struct list_head openFileList; 1150 1150 spinlock_t open_file_lock; /* protects list above */ 1151 1151 struct cifs_ses *ses; /* pointer to session associated with */ 1152 - char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */ 1152 + char tree_name[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */ 1153 1153 char *nativeFileSystem; 1154 1154 char *password; /* for share-level security */ 1155 1155 __u32 tid; /* The 4 byte tree id */
+7 -6
fs/cifs/connect.c
··· 1940 1940 spin_unlock(&ses->ses_lock); 1941 1941 1942 1942 cifs_dbg(FYI, "%s: ses_count=%d\n", __func__, ses->ses_count); 1943 - cifs_dbg(FYI, "%s: ses ipc: %s\n", __func__, ses->tcon_ipc ? ses->tcon_ipc->treeName : "NONE"); 1943 + cifs_dbg(FYI, 1944 + "%s: ses ipc: %s\n", __func__, ses->tcon_ipc ? ses->tcon_ipc->tree_name : "NONE"); 1944 1945 1945 1946 spin_lock(&cifs_tcp_ses_lock); 1946 1947 if (--ses->ses_count > 0) { ··· 2294 2293 { 2295 2294 if (tcon->status == TID_EXITING) 2296 2295 return 0; 2297 - if (strncmp(tcon->treeName, ctx->UNC, MAX_TREE_SIZE)) 2296 + if (strncmp(tcon->tree_name, ctx->UNC, MAX_TREE_SIZE)) 2298 2297 return 0; 2299 2298 if (tcon->seal != ctx->seal) 2300 2299 return 0; ··· 3990 3989 } 3991 3990 bcc_ptr += length + 1; 3992 3991 bytes_left -= (length + 1); 3993 - strscpy(tcon->treeName, tree, sizeof(tcon->treeName)); 3992 + strscpy(tcon->tree_name, tree, sizeof(tcon->tree_name)); 3994 3993 3995 3994 /* mostly informational -- no need to fail on error here */ 3996 3995 kfree(tcon->nativeFileSystem); ··· 4198 4197 ctx->local_nls = cifs_sb->local_nls; 4199 4198 ctx->linux_uid = fsuid; 4200 4199 ctx->cred_uid = fsuid; 4201 - ctx->UNC = master_tcon->treeName; 4200 + ctx->UNC = master_tcon->tree_name; 4202 4201 ctx->retry = master_tcon->retry; 4203 4202 ctx->nocase = master_tcon->nocase; 4204 4203 ctx->nohandlecache = master_tcon->nohandlecache; ··· 4664 4663 /* If it is not dfs or there was no cached dfs referral, then reconnect to same share */ 4665 4664 if (!server->current_fullpath || 4666 4665 dfs_cache_noreq_find(server->current_fullpath + 1, &ref, &tl)) { 4667 - rc = ops->tree_connect(xid, tcon->ses, tcon->treeName, tcon, cifs_sb->local_nls); 4666 + rc = ops->tree_connect(xid, tcon->ses, tcon->tree_name, tcon, cifs_sb->local_nls); 4668 4667 goto out; 4669 4668 } 4670 4669 ··· 4708 4707 tcon->status = TID_IN_TCON; 4709 4708 spin_unlock(&tcon->tc_lock); 4710 4709 4711 - rc = ops->tree_connect(xid, tcon->ses, tcon->treeName, tcon, nlsc); 4710 + rc = ops->tree_connect(xid, tcon->ses, tcon->tree_name, tcon, nlsc); 4712 4711 if (rc) { 4713 4712 spin_lock(&tcon->tc_lock); 4714 4713 if (tcon->status == TID_IN_TCON)
+1 -1
fs/cifs/dfs_cache.c
··· 98 98 99 99 get_ipc_unc(path, unc, sizeof(unc)); 100 100 for (; *ses; ses++) { 101 - if (!strcasecmp(unc, (*ses)->tcon_ipc->treeName)) 101 + if (!strcasecmp(unc, (*ses)->tcon_ipc->tree_name)) 102 102 return *ses; 103 103 } 104 104 return ERR_PTR(-ENOENT);
+4 -4
fs/cifs/dir.c
··· 50 50 } 51 51 52 52 if (add_treename) 53 - dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1); 53 + dfsplen = strnlen(tcon->tree_name, MAX_TREE_SIZE + 1); 54 54 else 55 55 dfsplen = 0; 56 56 ··· 59 59 return full_path; 60 60 61 61 if (dfsplen) 62 - memcpy(full_path, tcon->treeName, dfsplen); 62 + memcpy(full_path, tcon->tree_name, dfsplen); 63 63 full_path[dfsplen] = CIFS_DIR_SEP(cifs_sb); 64 64 memcpy(full_path + dfsplen + 1, ctx->prepath, pplen); 65 65 convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb)); ··· 93 93 return ERR_PTR(-ENOMEM); 94 94 95 95 if (prefix) 96 - dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1); 96 + dfsplen = strnlen(tcon->tree_name, MAX_TREE_SIZE + 1); 97 97 else 98 98 dfsplen = 0; 99 99 ··· 123 123 } 124 124 if (dfsplen) { 125 125 s -= dfsplen; 126 - memcpy(s, tcon->treeName, dfsplen); 126 + memcpy(s, tcon->tree_name, dfsplen); 127 127 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) { 128 128 int i; 129 129 for (i = 0; i < dfsplen; i++) {
+1 -1
fs/cifs/fscache.c
··· 45 45 46 46 memset(&key, 0, sizeof(key)); 47 47 48 - sharename = extract_sharename(tcon->treeName); 48 + sharename = extract_sharename(tcon->tree_name); 49 49 if (IS_ERR(sharename)) { 50 50 cifs_dbg(FYI, "%s: couldn't extract sharename\n", __func__); 51 51 return -EINVAL;
+1 -1
fs/cifs/inode.c
··· 913 913 } else { 914 914 /* make an ino by hashing the UNC */ 915 915 fattr->cf_flags |= CIFS_FATTR_FAKE_ROOT_INO; 916 - fattr->cf_uniqueid = simple_hashstr(tcon->treeName); 916 + fattr->cf_uniqueid = simple_hashstr(tcon->tree_name); 917 917 } 918 918 } 919 919 }
+2 -2
fs/cifs/misc.c
··· 525 525 cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM; 526 526 cifs_sb->mnt_cifs_serverino_autodisabled = true; 527 527 cifs_dbg(VFS, "Autodisabling the use of server inode numbers on %s\n", 528 - tcon ? tcon->treeName : "new server"); 528 + tcon ? tcon->tree_name : "new server"); 529 529 cifs_dbg(VFS, "The server doesn't seem to support them properly or the files might be on different servers (DFS)\n"); 530 530 cifs_dbg(VFS, "Hardlinks will not be recognized on this mount. Consider mounting with the \"noserverino\" option to silence this message.\n"); 531 531 ··· 1328 1328 char *treename, *dfspath, sep; 1329 1329 int treenamelen, linkpathlen, rc; 1330 1330 1331 - treename = tcon->treeName; 1331 + treename = tcon->tree_name; 1332 1332 /* MS-DFSC: All paths in REQ_GET_DFS_REFERRAL and RESP_GET_DFS_REFERRAL 1333 1333 * messages MUST be encoded with exactly one leading backslash, not two 1334 1334 * leading backslashes.
+1 -1
fs/cifs/smb2inode.c
··· 379 379 380 380 SMB2_open_free(&rqst[0]); 381 381 if (rc == -EREMCHG) { 382 - pr_warn_once("server share %s deleted\n", tcon->treeName); 382 + pr_warn_once("server share %s deleted\n", tcon->tree_name); 383 383 tcon->need_reconnect = true; 384 384 } 385 385
+3 -3
fs/cifs/smb2ops.c
··· 1327 1327 CIFSMaxBufSize, (char **)&res_key, &ret_data_len); 1328 1328 1329 1329 if (rc == -EOPNOTSUPP) { 1330 - pr_warn_once("Server share %s does not support copy range\n", tcon->treeName); 1330 + pr_warn_once("Server share %s does not support copy range\n", tcon->tree_name); 1331 1331 goto req_res_key_exit; 1332 1332 } else if (rc) { 1333 1333 cifs_tcon_dbg(VFS, "refcpy ioctl error %d getting resume key\n", rc); ··· 2289 2289 spin_unlock(&tcon->tc_lock); 2290 2290 spin_unlock(&cifs_tcp_ses_lock); 2291 2291 pr_warn_once("Server share %s deleted.\n", 2292 - tcon->treeName); 2292 + tcon->tree_name); 2293 2293 return; 2294 2294 } 2295 2295 } ··· 2498 2498 if (rc == -EREMCHG) { 2499 2499 tcon->need_reconnect = true; 2500 2500 pr_warn_once("server share %s deleted\n", 2501 - tcon->treeName); 2501 + tcon->tree_name); 2502 2502 } 2503 2503 goto qic_exit; 2504 2504 }
+10 -6
fs/cifs/smb2pdu.c
··· 1930 1930 tcon->capabilities = rsp->Capabilities; /* we keep caps little endian */ 1931 1931 tcon->maximal_access = le32_to_cpu(rsp->MaximalAccess); 1932 1932 tcon->tid = le32_to_cpu(rsp->hdr.Id.SyncId.TreeId); 1933 - strscpy(tcon->treeName, tree, sizeof(tcon->treeName)); 1933 + strscpy(tcon->tree_name, tree, sizeof(tcon->tree_name)); 1934 1934 1935 1935 if ((rsp->Capabilities & SMB2_SHARE_CAP_DFS) && 1936 1936 ((tcon->share_flags & SHI1005_FLAGS_DFS) == 0)) ··· 1973 1973 if (!ses || !(ses->server)) 1974 1974 return -EIO; 1975 1975 1976 + trace_smb3_tdis_enter(xid, tcon->tid, ses->Suid, tcon->tree_name); 1976 1977 spin_lock(&ses->chan_lock); 1977 1978 if ((tcon->need_reconnect) || 1978 1979 (CIFS_ALL_CHANS_NEED_RECONNECT(tcon->ses))) { ··· 2005 2004 rc = cifs_send_recv(xid, ses, ses->server, 2006 2005 &rqst, &resp_buf_type, flags, &rsp_iov); 2007 2006 cifs_small_buf_release(req); 2008 - if (rc) 2007 + if (rc) { 2009 2008 cifs_stats_fail_inc(tcon, SMB2_TREE_DISCONNECT_HE); 2009 + trace_smb3_tdis_err(xid, tcon->tid, ses->Suid, rc); 2010 + } 2011 + trace_smb3_tdis_done(xid, tcon->tid, ses->Suid); 2010 2012 2011 2013 return rc; 2012 2014 } ··· 2678 2674 req->hdr.Flags |= SMB2_FLAGS_DFS_OPERATIONS; 2679 2675 rc = alloc_path_with_tree_prefix(&copy_path, &copy_size, 2680 2676 &name_len, 2681 - tcon->treeName, utf16_path); 2677 + tcon->tree_name, utf16_path); 2682 2678 if (rc) 2683 2679 goto err_free_req; 2684 2680 ··· 2820 2816 req->hdr.Flags |= SMB2_FLAGS_DFS_OPERATIONS; 2821 2817 rc = alloc_path_with_tree_prefix(&copy_path, &copy_size, 2822 2818 &name_len, 2823 - tcon->treeName, path); 2819 + tcon->tree_name, path); 2824 2820 if (rc) 2825 2821 return rc; 2826 2822 req->NameLength = cpu_to_le16(name_len * 2); ··· 3015 3011 oparms->create_options, oparms->desired_access, rc); 3016 3012 if (rc == -EREMCHG) { 3017 3013 pr_warn_once("server share %s deleted\n", 3018 - tcon->treeName); 3014 + tcon->tree_name); 3019 3015 tcon->need_reconnect = true; 3020 3016 } 3021 3017 goto creat_exit; ··· 4433 4429 wdata->bytes, wdata->result); 4434 4430 if (wdata->result == -ENOSPC) 4435 4431 pr_warn_once("Out of space writing to %s\n", 4436 - tcon->treeName); 4432 + tcon->tree_name); 4437 4433 } else 4438 4434 trace_smb3_write_done(0 /* no xid */, 4439 4435 wdata->cfile->fid.persistent_fid,
+3
fs/cifs/trace.h
··· 372 372 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_info_compound_enter); 373 373 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(delete_enter); 374 374 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(mkdir_enter); 375 + DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(tdis_enter); 375 376 376 377 377 378 DECLARE_EVENT_CLASS(smb3_inf_compound_done_class, ··· 410 409 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_info_compound_done); 411 410 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(delete_done); 412 411 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(mkdir_done); 412 + DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(tdis_done); 413 413 414 414 415 415 DECLARE_EVENT_CLASS(smb3_inf_compound_err_class, ··· 453 451 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_info_compound_err); 454 452 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(mkdir_err); 455 453 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(delete_err); 454 + DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(tdis_err); 456 455 457 456 /* 458 457 * For logging SMB3 Status code and Command for responses which return errors