smb3: add dynamic trace points for tree disconnect
authorSteve French <stfrench@microsoft.com>
Wed, 21 Sep 2022 19:05:53 +0000 (14:05 -0500)
committerSteve French <stfrench@microsoft.com>
Wed, 5 Oct 2022 06:31:18 +0000 (01:31 -0500)
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>
15 files changed:
fs/cifs/cached_dir.c
fs/cifs/cifs_debug.c
fs/cifs/cifs_debug.h
fs/cifs/cifs_swn.c
fs/cifs/cifsglob.h
fs/cifs/connect.c
fs/cifs/dfs_cache.c
fs/cifs/dir.c
fs/cifs/fscache.c
fs/cifs/inode.c
fs/cifs/misc.c
fs/cifs/smb2inode.c
fs/cifs/smb2ops.c
fs/cifs/smb2pdu.c
fs/cifs/trace.h

index b401339f6e738a390891ec99ace9047400bce649..ca8d7cf2a14735af0a806012bd0307fd25aedbae 100644 (file)
@@ -160,7 +160,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
                if (rc == -EREMCHG) {
                        tcon->need_reconnect = true;
                        pr_warn_once("server share %s deleted\n",
-                                    tcon->treeName);
+                                    tcon->tree_name);
                }
                goto oshr_exit;
        }
index c05477e28cffa698868655e24142aaf0e52f83a6..90850da390aebe4858df736b7f61b4a664e4d0ff 100644 (file)
@@ -87,7 +87,7 @@ static void cifs_debug_tcon(struct seq_file *m, struct cifs_tcon *tcon)
 {
        __u32 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
 
-       seq_printf(m, "%s Mounts: %d ", tcon->treeName, tcon->tc_count);
+       seq_printf(m, "%s Mounts: %d ", tcon->tree_name, tcon->tc_count);
        if (tcon->nativeFileSystem)
                seq_printf(m, "Type: %s ", tcon->nativeFileSystem);
        seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x\n\tPathComponentMax: %d Status: %d",
@@ -601,7 +601,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
                list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
                        list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
                                i++;
-                               seq_printf(m, "\n%d) %s", i, tcon->treeName);
+                               seq_printf(m, "\n%d) %s", i, tcon->tree_name);
                                if (tcon->need_reconnect)
                                        seq_puts(m, "\tDISCONNECTED ");
                                seq_printf(m, "\nSMBs: %d",
index ee4ea2b60c0fba8930b9edf62377ea098437b2fa..d44808263cfba74fb8aa299f9682e902e19c6191 100644 (file)
@@ -108,8 +108,8 @@ do {                                                                        \
 #define cifs_tcon_dbg_func(ratefunc, type, fmt, ...)                   \
 do {                                                                   \
        const char *tn = "";                                            \
-       if (tcon && tcon->treeName)                                     \
-               tn = tcon->treeName;                                    \
+       if (tcon && tcon->tree_name)                                    \
+               tn = tcon->tree_name;                                   \
        if ((type) & FYI && cifsFYI & CIFS_INFO) {                      \
                pr_debug_ ## ratefunc("%s: %s " fmt,                    \
                                      __FILE__, tn, ##__VA_ARGS__);     \
@@ -150,7 +150,7 @@ do {                                                                        \
 #define cifs_tcon_dbg(type, fmt, ...)                                  \
 do {                                                                   \
        if (0)                                                          \
-               pr_debug("%s " fmt, tcon->treeName, ##__VA_ARGS__);     \
+               pr_debug("%s " fmt, tcon->tree_name, ##__VA_ARGS__);    \
 } while (0)
 
 #define cifs_info(fmt, ...)                                            \
index 1e4c7cc5287f0317933fbf5ff49d5eb7864e7029..7233c6a7e6d70b03336737d8acc5bb302d3067d2 100644 (file)
@@ -256,23 +256,23 @@ static struct cifs_swn_reg *cifs_find_swn_reg(struct cifs_tcon *tcon)
        const char *share_name;
        const char *net_name;
 
-       net_name = extract_hostname(tcon->treeName);
+       net_name = extract_hostname(tcon->tree_name);
        if (IS_ERR(net_name)) {
                int ret;
 
                ret = PTR_ERR(net_name);
                cifs_dbg(VFS, "%s: failed to extract host name from target '%s': %d\n",
-                               __func__, tcon->treeName, ret);
+                               __func__, tcon->tree_name, ret);
                return ERR_PTR(-EINVAL);
        }
 
-       share_name = extract_sharename(tcon->treeName);
+       share_name = extract_sharename(tcon->tree_name);
        if (IS_ERR(share_name)) {
                int ret;
 
                ret = PTR_ERR(share_name);
                cifs_dbg(VFS, "%s: failed to extract share name from target '%s': %d\n",
-                               __func__, tcon->treeName, ret);
+                               __func__, tcon->tree_name, ret);
                kfree(net_name);
                return ERR_PTR(-EINVAL);
        }
@@ -335,14 +335,14 @@ static struct cifs_swn_reg *cifs_get_swn_reg(struct cifs_tcon *tcon)
                goto fail;
        }
 
-       reg->net_name = extract_hostname(tcon->treeName);
+       reg->net_name = extract_hostname(tcon->tree_name);
        if (IS_ERR(reg->net_name)) {
                ret = PTR_ERR(reg->net_name);
                cifs_dbg(VFS, "%s: failed to extract host name from target: %d\n", __func__, ret);
                goto fail_idr;
        }
 
-       reg->share_name = extract_sharename(tcon->treeName);
+       reg->share_name = extract_sharename(tcon->tree_name);
        if (IS_ERR(reg->share_name)) {
                ret = PTR_ERR(reg->share_name);
                cifs_dbg(VFS, "%s: failed to extract share name from target: %d\n", __func__, ret);
index ae7f571a7dba2c4c497b22f4a2b7fefc55388de4..ad606f648bdc8ffa262dce6821c820e3f9cb6eaa 100644 (file)
@@ -1149,7 +1149,7 @@ struct cifs_tcon {
        struct list_head openFileList;
        spinlock_t open_file_lock; /* protects list above */
        struct cifs_ses *ses;   /* pointer to session associated with */
-       char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */
+       char tree_name[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */
        char *nativeFileSystem;
        char *password;         /* for share-level security */
        __u32 tid;              /* The 4 byte tree id */
index 7ae6f2c08153e63b17cc19262fad12562a53cecd..ad81d7d43eafbfb7a47585a33659927cc85b9041 100644 (file)
@@ -1940,7 +1940,8 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
        spin_unlock(&ses->ses_lock);
 
        cifs_dbg(FYI, "%s: ses_count=%d\n", __func__, ses->ses_count);
-       cifs_dbg(FYI, "%s: ses ipc: %s\n", __func__, ses->tcon_ipc ? ses->tcon_ipc->treeName : "NONE");
+       cifs_dbg(FYI,
+                "%s: ses ipc: %s\n", __func__, ses->tcon_ipc ? ses->tcon_ipc->tree_name : "NONE");
 
        spin_lock(&cifs_tcp_ses_lock);
        if (--ses->ses_count > 0) {
@@ -2293,7 +2294,7 @@ static int match_tcon(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)
 {
        if (tcon->status == TID_EXITING)
                return 0;
-       if (strncmp(tcon->treeName, ctx->UNC, MAX_TREE_SIZE))
+       if (strncmp(tcon->tree_name, ctx->UNC, MAX_TREE_SIZE))
                return 0;
        if (tcon->seal != ctx->seal)
                return 0;
@@ -3989,7 +3990,7 @@ CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
                }
                bcc_ptr += length + 1;
                bytes_left -= (length + 1);
-               strscpy(tcon->treeName, tree, sizeof(tcon->treeName));
+               strscpy(tcon->tree_name, tree, sizeof(tcon->tree_name));
 
                /* mostly informational -- no need to fail on error here */
                kfree(tcon->nativeFileSystem);
@@ -4197,7 +4198,7 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid)
        ctx->local_nls = cifs_sb->local_nls;
        ctx->linux_uid = fsuid;
        ctx->cred_uid = fsuid;
-       ctx->UNC = master_tcon->treeName;
+       ctx->UNC = master_tcon->tree_name;
        ctx->retry = master_tcon->retry;
        ctx->nocase = master_tcon->nocase;
        ctx->nohandlecache = master_tcon->nohandlecache;
@@ -4663,7 +4664,7 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
        /* If it is not dfs or there was no cached dfs referral, then reconnect to same share */
        if (!server->current_fullpath ||
            dfs_cache_noreq_find(server->current_fullpath + 1, &ref, &tl)) {
-               rc = ops->tree_connect(xid, tcon->ses, tcon->treeName, tcon, cifs_sb->local_nls);
+               rc = ops->tree_connect(xid, tcon->ses, tcon->tree_name, tcon, cifs_sb->local_nls);
                goto out;
        }
 
@@ -4707,7 +4708,7 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
        tcon->status = TID_IN_TCON;
        spin_unlock(&tcon->tc_lock);
 
-       rc = ops->tree_connect(xid, tcon->ses, tcon->treeName, tcon, nlsc);
+       rc = ops->tree_connect(xid, tcon->ses, tcon->tree_name, tcon, nlsc);
        if (rc) {
                spin_lock(&tcon->tc_lock);
                if (tcon->status == TID_IN_TCON)
index a9b6c3eba6de505ab1786a10c8f4d5383f020a40..e70915ad754100364c62e509357f412d1b49f9e9 100644 (file)
@@ -98,7 +98,7 @@ static struct cifs_ses *find_ipc_from_server_path(struct cifs_ses **ses, const c
 
        get_ipc_unc(path, unc, sizeof(unc));
        for (; *ses; ses++) {
-               if (!strcasecmp(unc, (*ses)->tcon_ipc->treeName))
+               if (!strcasecmp(unc, (*ses)->tcon_ipc->tree_name))
                        return *ses;
        }
        return ERR_PTR(-ENOENT);
index 08f7392716e2f31dd1941a15e24be4c74d13c548..f58869306309ff3cc139709a2ec4435ffe24e381 100644 (file)
@@ -50,7 +50,7 @@ cifs_build_path_to_root(struct smb3_fs_context *ctx, struct cifs_sb_info *cifs_s
        }
 
        if (add_treename)
-               dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1);
+               dfsplen = strnlen(tcon->tree_name, MAX_TREE_SIZE + 1);
        else
                dfsplen = 0;
 
@@ -59,7 +59,7 @@ cifs_build_path_to_root(struct smb3_fs_context *ctx, struct cifs_sb_info *cifs_s
                return full_path;
 
        if (dfsplen)
-               memcpy(full_path, tcon->treeName, dfsplen);
+               memcpy(full_path, tcon->tree_name, dfsplen);
        full_path[dfsplen] = CIFS_DIR_SEP(cifs_sb);
        memcpy(full_path + dfsplen + 1, ctx->prepath, pplen);
        convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb));
@@ -93,7 +93,7 @@ build_path_from_dentry_optional_prefix(struct dentry *direntry, void *page,
                return ERR_PTR(-ENOMEM);
 
        if (prefix)
-               dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1);
+               dfsplen = strnlen(tcon->tree_name, MAX_TREE_SIZE + 1);
        else
                dfsplen = 0;
 
@@ -123,7 +123,7 @@ build_path_from_dentry_optional_prefix(struct dentry *direntry, void *page,
        }
        if (dfsplen) {
                s -= dfsplen;
-               memcpy(s, tcon->treeName, dfsplen);
+               memcpy(s, tcon->tree_name, dfsplen);
                if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) {
                        int i;
                        for (i = 0; i < dfsplen; i++) {
index 23ef56f55ce509d149923ae218d1f6dabd8f1da1..a1751b95631845151b1e0b8663238eaadc97b56b 100644 (file)
@@ -45,7 +45,7 @@ int cifs_fscache_get_super_cookie(struct cifs_tcon *tcon)
 
        memset(&key, 0, sizeof(key));
 
-       sharename = extract_sharename(tcon->treeName);
+       sharename = extract_sharename(tcon->tree_name);
        if (IS_ERR(sharename)) {
                cifs_dbg(FYI, "%s: couldn't extract sharename\n", __func__);
                return -EINVAL;
index bac08c20f559bccbba51f3ae960c9fedd92a1271..3784d3a880536cf3f8b243bfea71a396fd14a10b 100644 (file)
@@ -913,7 +913,7 @@ cifs_set_fattr_ino(int xid,
                } else {
                        /* make an ino by hashing the UNC */
                        fattr->cf_flags |= CIFS_FATTR_FAKE_ROOT_INO;
-                       fattr->cf_uniqueid = simple_hashstr(tcon->treeName);
+                       fattr->cf_uniqueid = simple_hashstr(tcon->tree_name);
                }
        }
 }
index c6679398fff9f100b1aac53908fc558e24661290..f42812e4c2cda690d0032204b09bbba07277dc32 100644 (file)
@@ -525,7 +525,7 @@ cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb)
                cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM;
                cifs_sb->mnt_cifs_serverino_autodisabled = true;
                cifs_dbg(VFS, "Autodisabling the use of server inode numbers on %s\n",
-                        tcon ? tcon->treeName : "new server");
+                        tcon ? tcon->tree_name : "new server");
                cifs_dbg(VFS, "The server doesn't seem to support them properly or the files might be on different servers (DFS)\n");
                cifs_dbg(VFS, "Hardlinks will not be recognized on this mount. Consider mounting with the \"noserverino\" option to silence this message.\n");
 
@@ -1328,7 +1328,7 @@ int cifs_dfs_query_info_nonascii_quirk(const unsigned int xid,
        char *treename, *dfspath, sep;
        int treenamelen, linkpathlen, rc;
 
-       treename = tcon->treeName;
+       treename = tcon->tree_name;
        /* MS-DFSC: All paths in REQ_GET_DFS_REFERRAL and RESP_GET_DFS_REFERRAL
         * messages MUST be encoded with exactly one leading backslash, not two
         * leading backslashes.
index b83f59051b26f984f742338d6746f97865e4b9f7..bb3e3d5a0cdac91ba378e7cb84743a62363f8462 100644 (file)
@@ -379,7 +379,7 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
 
        SMB2_open_free(&rqst[0]);
        if (rc == -EREMCHG) {
-               pr_warn_once("server share %s deleted\n", tcon->treeName);
+               pr_warn_once("server share %s deleted\n", tcon->tree_name);
                tcon->need_reconnect = true;
        }
 
index 421be43af42533d2e254157b74ec0c166c6ff310..f590a9cb6a1a24c96121bfd599631546062ba382 100644 (file)
@@ -1327,7 +1327,7 @@ SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon,
                        CIFSMaxBufSize, (char **)&res_key, &ret_data_len);
 
        if (rc == -EOPNOTSUPP) {
-               pr_warn_once("Server share %s does not support copy range\n", tcon->treeName);
+               pr_warn_once("Server share %s does not support copy range\n", tcon->tree_name);
                goto req_res_key_exit;
        } else if (rc) {
                cifs_tcon_dbg(VFS, "refcpy ioctl error %d getting resume key\n", rc);
@@ -2289,7 +2289,7 @@ smb2_is_network_name_deleted(char *buf, struct TCP_Server_Info *server)
                                spin_unlock(&tcon->tc_lock);
                                spin_unlock(&cifs_tcp_ses_lock);
                                pr_warn_once("Server share %s deleted.\n",
-                                            tcon->treeName);
+                                            tcon->tree_name);
                                return;
                        }
                }
@@ -2498,7 +2498,7 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon,
                if (rc == -EREMCHG) {
                        tcon->need_reconnect = true;
                        pr_warn_once("server share %s deleted\n",
-                                    tcon->treeName);
+                                    tcon->tree_name);
                }
                goto qic_exit;
        }
index 223056097b54f855ce57f552927fb1d91844d495..90ccac18f9f3fad055ef7b56328a12fa08bffb96 100644 (file)
@@ -1930,7 +1930,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
        tcon->capabilities = rsp->Capabilities; /* we keep caps little endian */
        tcon->maximal_access = le32_to_cpu(rsp->MaximalAccess);
        tcon->tid = le32_to_cpu(rsp->hdr.Id.SyncId.TreeId);
-       strscpy(tcon->treeName, tree, sizeof(tcon->treeName));
+       strscpy(tcon->tree_name, tree, sizeof(tcon->tree_name));
 
        if ((rsp->Capabilities & SMB2_SHARE_CAP_DFS) &&
            ((tcon->share_flags & SHI1005_FLAGS_DFS) == 0))
@@ -1973,6 +1973,7 @@ SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon)
        if (!ses || !(ses->server))
                return -EIO;
 
+       trace_smb3_tdis_enter(xid, tcon->tid, ses->Suid, tcon->tree_name);
        spin_lock(&ses->chan_lock);
        if ((tcon->need_reconnect) ||
            (CIFS_ALL_CHANS_NEED_RECONNECT(tcon->ses))) {
@@ -2004,8 +2005,11 @@ SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon)
        rc = cifs_send_recv(xid, ses, ses->server,
                            &rqst, &resp_buf_type, flags, &rsp_iov);
        cifs_small_buf_release(req);
-       if (rc)
+       if (rc) {
                cifs_stats_fail_inc(tcon, SMB2_TREE_DISCONNECT_HE);
+               trace_smb3_tdis_err(xid, tcon->tid, ses->Suid, rc);
+       }
+       trace_smb3_tdis_done(xid, tcon->tid, ses->Suid);
 
        return rc;
 }
@@ -2674,7 +2678,7 @@ int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
                req->hdr.Flags |= SMB2_FLAGS_DFS_OPERATIONS;
                rc = alloc_path_with_tree_prefix(&copy_path, &copy_size,
                                                 &name_len,
-                                                tcon->treeName, utf16_path);
+                                                tcon->tree_name, utf16_path);
                if (rc)
                        goto err_free_req;
 
@@ -2816,7 +2820,7 @@ SMB2_open_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
                req->hdr.Flags |= SMB2_FLAGS_DFS_OPERATIONS;
                rc = alloc_path_with_tree_prefix(&copy_path, &copy_size,
                                                 &name_len,
-                                                tcon->treeName, path);
+                                                tcon->tree_name, path);
                if (rc)
                        return rc;
                req->NameLength = cpu_to_le16(name_len * 2);
@@ -3011,7 +3015,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
                                    oparms->create_options, oparms->desired_access, rc);
                if (rc == -EREMCHG) {
                        pr_warn_once("server share %s deleted\n",
-                                    tcon->treeName);
+                                    tcon->tree_name);
                        tcon->need_reconnect = true;
                }
                goto creat_exit;
@@ -4429,7 +4433,7 @@ smb2_writev_callback(struct mid_q_entry *mid)
                                     wdata->bytes, wdata->result);
                if (wdata->result == -ENOSPC)
                        pr_warn_once("Out of space writing to %s\n",
-                                    tcon->treeName);
+                                    tcon->tree_name);
        } else
                trace_smb3_write_done(0 /* no xid */,
                                      wdata->cfile->fid.persistent_fid,
index 6b88dc2e364f54672ad66282f657019e5d2e7b35..110070ba8b04e3b3e4aa2315d1cfce1c933ea809 100644 (file)
@@ -372,6 +372,7 @@ DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_eof_enter);
 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(set_info_compound_enter);
 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(delete_enter);
 DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(mkdir_enter);
+DEFINE_SMB3_INF_COMPOUND_ENTER_EVENT(tdis_enter);
 
 
 DECLARE_EVENT_CLASS(smb3_inf_compound_done_class,
@@ -409,6 +410,7 @@ DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_eof_done);
 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(set_info_compound_done);
 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(delete_done);
 DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(mkdir_done);
+DEFINE_SMB3_INF_COMPOUND_DONE_EVENT(tdis_done);
 
 
 DECLARE_EVENT_CLASS(smb3_inf_compound_err_class,
@@ -451,6 +453,7 @@ DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_eof_err);
 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(set_info_compound_err);
 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(mkdir_err);
 DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(delete_err);
+DEFINE_SMB3_INF_COMPOUND_ERR_EVENT(tdis_err);
 
 /*
  * For logging SMB3 Status code and Command for responses which return errors