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

cifs: add a debug macro that prints \\server\share for errors

Where we have a tcon available we can log \\server\share as part
of the message. Only do this for the VFS log level.

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Ronnie Sahlberg and committed by
Steve French
3175eb9b 46f17d17

+86 -50
+43 -7
fs/cifs/cifs_debug.h
··· 82 82 83 83 #define cifs_server_dbg_func(ratefunc, type, fmt, ...) \ 84 84 do { \ 85 + const char *sn = ""; \ 86 + if (server && server->hostname) \ 87 + sn = server->hostname; \ 85 88 if ((type) & FYI && cifsFYI & CIFS_INFO) { \ 86 - pr_debug_ ## ratefunc("%s: Server:%s " fmt, \ 87 - __FILE__, server->hostname, ##__VA_ARGS__);\ 89 + pr_debug_ ## ratefunc("%s: \\\\%s " fmt, \ 90 + __FILE__, sn, ##__VA_ARGS__); \ 88 91 } else if ((type) & VFS) { \ 89 - pr_err_ ## ratefunc("CIFS VFS: Server:%s " fmt, \ 90 - server->hostname, ##__VA_ARGS__); \ 92 + pr_err_ ## ratefunc("CIFS VFS: \\\\%s " fmt, \ 93 + sn, ##__VA_ARGS__); \ 91 94 } else if ((type) & NOISY && (NOISY != 0)) { \ 92 - pr_debug_ ## ratefunc("Server:%s " fmt, \ 93 - server->hostname, ##__VA_ARGS__); \ 95 + pr_debug_ ## ratefunc("\\\\%s " fmt, \ 96 + sn, ##__VA_ARGS__); \ 94 97 } \ 95 98 } while (0) 96 99 ··· 104 101 type, fmt, ##__VA_ARGS__); \ 105 102 else \ 106 103 cifs_server_dbg_func(ratelimited, \ 104 + type, fmt, ##__VA_ARGS__); \ 105 + } while (0) 106 + 107 + #define cifs_tcon_dbg_func(ratefunc, type, fmt, ...) \ 108 + do { \ 109 + const char *tn = ""; \ 110 + if (tcon && tcon->treeName) \ 111 + tn = tcon->treeName; \ 112 + if ((type) & FYI && cifsFYI & CIFS_INFO) { \ 113 + pr_debug_ ## ratefunc("%s: %s " fmt, \ 114 + __FILE__, tn, ##__VA_ARGS__); \ 115 + } else if ((type) & VFS) { \ 116 + pr_err_ ## ratefunc("CIFS VFS: %s " fmt, \ 117 + tn, ##__VA_ARGS__); \ 118 + } else if ((type) & NOISY && (NOISY != 0)) { \ 119 + pr_debug_ ## ratefunc("%s " fmt, \ 120 + tn, ##__VA_ARGS__); \ 121 + } \ 122 + } while (0) 123 + 124 + #define cifs_tcon_dbg(type, fmt, ...) \ 125 + do { \ 126 + if ((type) & ONCE) \ 127 + cifs_tcon_dbg_func(once, \ 128 + type, fmt, ##__VA_ARGS__); \ 129 + else \ 130 + cifs_tcon_dbg_func(ratelimited, \ 107 131 type, fmt, ##__VA_ARGS__); \ 108 132 } while (0) 109 133 ··· 148 118 #define cifs_server_dbg(type, fmt, ...) \ 149 119 do { \ 150 120 if (0) \ 151 - pr_debug("Server:%s " fmt, \ 121 + pr_debug("\\\\%s " fmt, \ 152 122 server->hostname, ##__VA_ARGS__); \ 123 + } while (0) 124 + 125 + #define cifs_tcon_dbg(type, fmt, ...) \ 126 + do { \ 127 + if (0) \ 128 + pr_debug("%s " fmt, tcon->treeName, ##__VA_ARGS__); \ 153 129 } while (0) 154 130 155 131 #define cifs_info(fmt, ...) \
+27 -27
fs/cifs/smb2ops.c
··· 109 109 /* change_conf hasn't been executed */ 110 110 break; 111 111 case 0: 112 - cifs_dbg(VFS, "Possible client or server bug - zero credits\n"); 112 + cifs_server_dbg(VFS, "Possible client or server bug - zero credits\n"); 113 113 break; 114 114 case 1: 115 - cifs_dbg(VFS, "disabling echoes and oplocks\n"); 115 + cifs_server_dbg(VFS, "disabling echoes and oplocks\n"); 116 116 break; 117 117 case 2: 118 118 cifs_dbg(FYI, "disabling oplocks\n"); ··· 230 230 231 231 if (server->reconnect_instance != credits->instance) { 232 232 spin_unlock(&server->req_lock); 233 - cifs_dbg(VFS, "trying to return %d credits to old session\n", 233 + cifs_server_dbg(VFS, "trying to return %d credits to old session\n", 234 234 credits->value - new_val); 235 235 return -EAGAIN; 236 236 } ··· 270 270 __u64 wire_mid = le64_to_cpu(shdr->MessageId); 271 271 272 272 if (shdr->ProtocolId == SMB2_TRANSFORM_PROTO_NUM) { 273 - cifs_dbg(VFS, "Encrypted frame parsing not supported yet\n"); 273 + cifs_server_dbg(VFS, "Encrypted frame parsing not supported yet\n"); 274 274 return NULL; 275 275 } 276 276 ··· 294 294 #ifdef CONFIG_CIFS_DEBUG2 295 295 struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; 296 296 297 - cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n", 297 + cifs_server_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n", 298 298 shdr->Command, shdr->Status, shdr->Flags, shdr->MessageId, 299 299 shdr->ProcessId); 300 - cifs_dbg(VFS, "smb buf %p len %u\n", buf, 300 + cifs_server_dbg(VFS, "smb buf %p len %u\n", buf, 301 301 server->ops->calc_smb_size(buf, server)); 302 302 #endif 303 303 } ··· 576 576 "server does not support query network interfaces\n"); 577 577 goto out; 578 578 } else if (rc != 0) { 579 - cifs_dbg(VFS, "error %d on ioctl to get interface list\n", rc); 579 + cifs_tcon_dbg(VFS, "error %d on ioctl to get interface list\n", rc); 580 580 goto out; 581 581 } 582 582 ··· 1330 1330 (char **)&res_key, &ret_data_len); 1331 1331 1332 1332 if (rc) { 1333 - cifs_dbg(VFS, "refcpy ioctl error %d getting resume key\n", rc); 1333 + cifs_tcon_dbg(VFS, "refcpy ioctl error %d getting resume key\n", rc); 1334 1334 goto req_res_key_exit; 1335 1335 } 1336 1336 if (ret_data_len < sizeof(struct resume_key_req)) { 1337 - cifs_dbg(VFS, "Invalid refcopy resume key length\n"); 1337 + cifs_tcon_dbg(VFS, "Invalid refcopy resume key length\n"); 1338 1338 rc = -EINVAL; 1339 1339 goto req_res_key_exit; 1340 1340 } ··· 1486 1486 qi.input_buffer_length, 1487 1487 qi.output_buffer_length, buffer); 1488 1488 } else { /* unknown flags */ 1489 - cifs_dbg(VFS, "invalid passthru query flags: 0x%x\n", qi.flags); 1489 + cifs_tcon_dbg(VFS, "invalid passthru query flags: 0x%x\n", qi.flags); 1490 1490 rc = -EINVAL; 1491 1491 } 1492 1492 ··· 1613 1613 if (rc == 0) { 1614 1614 if (ret_data_len != 1615 1615 sizeof(struct copychunk_ioctl_rsp)) { 1616 - cifs_dbg(VFS, "invalid cchunk response size\n"); 1616 + cifs_tcon_dbg(VFS, "invalid cchunk response size\n"); 1617 1617 rc = -EIO; 1618 1618 goto cchunk_out; 1619 1619 } ··· 1627 1627 */ 1628 1628 if (le32_to_cpu(retbuf->TotalBytesWritten) > 1629 1629 le32_to_cpu(pcchunk->Length)) { 1630 - cifs_dbg(VFS, "invalid copy chunk response\n"); 1630 + cifs_tcon_dbg(VFS, "invalid copy chunk response\n"); 1631 1631 rc = -EIO; 1632 1632 goto cchunk_out; 1633 1633 } 1634 1634 if (le32_to_cpu(retbuf->ChunksWritten) != 1) { 1635 - cifs_dbg(VFS, "invalid num chunks written\n"); 1635 + cifs_tcon_dbg(VFS, "invalid num chunks written\n"); 1636 1636 rc = -EIO; 1637 1637 goto cchunk_out; 1638 1638 } ··· 2422 2422 2423 2423 if (rc) { 2424 2424 if ((rc != -ENOENT) && (rc != -EOPNOTSUPP)) 2425 - cifs_dbg(VFS, "ioctl error in %s rc=%d\n", __func__, rc); 2425 + cifs_tcon_dbg(VFS, "ioctl error in %s rc=%d\n", __func__, rc); 2426 2426 goto out; 2427 2427 } 2428 2428 ··· 2431 2431 nls_codepage, remap, search_name, 2432 2432 true /* is_unicode */); 2433 2433 if (rc) { 2434 - cifs_dbg(VFS, "parse error in %s rc=%d\n", __func__, rc); 2434 + cifs_tcon_dbg(VFS, "parse error in %s rc=%d\n", __func__, rc); 2435 2435 goto out; 2436 2436 } 2437 2437 ··· 2661 2661 2662 2662 if (plen + le32_to_cpu(ioctl_rsp->OutputOffset) > 2663 2663 rsp_iov[1].iov_len) { 2664 - cifs_dbg(VFS, "srv returned invalid ioctl len: %d\n", 2664 + cifs_tcon_dbg(VFS, "srv returned invalid ioctl len: %d\n", 2665 2665 plen); 2666 2666 rc = -EIO; 2667 2667 goto querty_exit; ··· 3614 3614 3615 3615 rc = smb2_get_enc_key(server, tr_hdr->SessionId, enc, key); 3616 3616 if (rc) { 3617 - cifs_dbg(VFS, "%s: Could not get %scryption key\n", __func__, 3617 + cifs_server_dbg(VFS, "%s: Could not get %scryption key\n", __func__, 3618 3618 enc ? "en" : "de"); 3619 3619 return 0; 3620 3620 } 3621 3621 3622 3622 rc = smb3_crypto_aead_allocate(server); 3623 3623 if (rc) { 3624 - cifs_dbg(VFS, "%s: crypto alloc failed\n", __func__); 3624 + cifs_server_dbg(VFS, "%s: crypto alloc failed\n", __func__); 3625 3625 return rc; 3626 3626 } 3627 3627 ··· 3629 3629 server->secmech.ccmaesdecrypt; 3630 3630 rc = crypto_aead_setkey(tfm, key, SMB3_SIGN_KEY_SIZE); 3631 3631 if (rc) { 3632 - cifs_dbg(VFS, "%s: Failed to set aead key %d\n", __func__, rc); 3632 + cifs_server_dbg(VFS, "%s: Failed to set aead key %d\n", __func__, rc); 3633 3633 return rc; 3634 3634 } 3635 3635 3636 3636 rc = crypto_aead_setauthsize(tfm, SMB2_SIGNATURE_SIZE); 3637 3637 if (rc) { 3638 - cifs_dbg(VFS, "%s: Failed to set authsize %d\n", __func__, rc); 3638 + cifs_server_dbg(VFS, "%s: Failed to set authsize %d\n", __func__, rc); 3639 3639 return rc; 3640 3640 } 3641 3641 3642 3642 req = aead_request_alloc(tfm, GFP_KERNEL); 3643 3643 if (!req) { 3644 - cifs_dbg(VFS, "%s: Failed to alloc aead request\n", __func__); 3644 + cifs_server_dbg(VFS, "%s: Failed to alloc aead request\n", __func__); 3645 3645 return -ENOMEM; 3646 3646 } 3647 3647 ··· 3652 3652 3653 3653 sg = init_sg(num_rqst, rqst, sign); 3654 3654 if (!sg) { 3655 - cifs_dbg(VFS, "%s: Failed to init sg\n", __func__); 3655 + cifs_server_dbg(VFS, "%s: Failed to init sg\n", __func__); 3656 3656 rc = -ENOMEM; 3657 3657 goto free_req; 3658 3658 } ··· 3660 3660 iv_len = crypto_aead_ivsize(tfm); 3661 3661 iv = kzalloc(iv_len, GFP_KERNEL); 3662 3662 if (!iv) { 3663 - cifs_dbg(VFS, "%s: Failed to alloc iv\n", __func__); 3663 + cifs_server_dbg(VFS, "%s: Failed to alloc iv\n", __func__); 3664 3664 rc = -ENOMEM; 3665 3665 goto free_sg; 3666 3666 } ··· 3902 3902 bool use_rdma_mr = false; 3903 3903 3904 3904 if (shdr->Command != SMB2_READ) { 3905 - cifs_dbg(VFS, "only big read responses are supported\n"); 3905 + cifs_server_dbg(VFS, "only big read responses are supported\n"); 3906 3906 return -ENOTSUPP; 3907 3907 } 3908 3908 ··· 4148 4148 } 4149 4149 4150 4150 if (*num_mids >= MAX_COMPOUND) { 4151 - cifs_dbg(VFS, "too many PDUs in compound\n"); 4151 + cifs_server_dbg(VFS, "too many PDUs in compound\n"); 4152 4152 return -1; 4153 4153 } 4154 4154 bufs[*num_mids] = buf; ··· 4194 4194 4195 4195 if (pdu_length < sizeof(struct smb2_transform_hdr) + 4196 4196 sizeof(struct smb2_sync_hdr)) { 4197 - cifs_dbg(VFS, "Transform message is too small (%u)\n", 4197 + cifs_server_dbg(VFS, "Transform message is too small (%u)\n", 4198 4198 pdu_length); 4199 4199 cifs_reconnect(server); 4200 4200 wake_up(&server->response_q); ··· 4202 4202 } 4203 4203 4204 4204 if (pdu_length < orig_len + sizeof(struct smb2_transform_hdr)) { 4205 - cifs_dbg(VFS, "Transform message is broken\n"); 4205 + cifs_server_dbg(VFS, "Transform message is broken\n"); 4206 4206 cifs_reconnect(server); 4207 4207 wake_up(&server->response_q); 4208 4208 return -ECONNABORTED;
+14 -14
fs/cifs/smb2pdu.c
··· 1019 1019 } 1020 1020 1021 1021 if (tcon->ses->session_flags & SMB2_SESSION_FLAG_IS_NULL) 1022 - cifs_server_dbg(VFS, "Unexpected null user (anonymous) auth flag sent by server\n"); 1022 + cifs_tcon_dbg(VFS, "Unexpected null user (anonymous) auth flag sent by server\n"); 1023 1023 1024 1024 pneg_inbuf = kmalloc(sizeof(*pneg_inbuf), GFP_NOFS); 1025 1025 if (!pneg_inbuf) ··· 1076 1076 * Old Windows versions or Netapp SMB server can return 1077 1077 * not supported error. Client should accept it. 1078 1078 */ 1079 - cifs_server_dbg(VFS, "Server does not support validate negotiate\n"); 1079 + cifs_tcon_dbg(VFS, "Server does not support validate negotiate\n"); 1080 1080 rc = 0; 1081 1081 goto out_free_inbuf; 1082 1082 } else if (rc != 0) { 1083 - cifs_server_dbg(VFS, "validate protocol negotiate failed: %d\n", rc); 1083 + cifs_tcon_dbg(VFS, "validate protocol negotiate failed: %d\n", rc); 1084 1084 rc = -EIO; 1085 1085 goto out_free_inbuf; 1086 1086 } 1087 1087 1088 1088 rc = -EIO; 1089 1089 if (rsplen != sizeof(*pneg_rsp)) { 1090 - cifs_server_dbg(VFS, "invalid protocol negotiate response size: %d\n", 1090 + cifs_tcon_dbg(VFS, "invalid protocol negotiate response size: %d\n", 1091 1091 rsplen); 1092 1092 1093 1093 /* relax check since Mac returns max bufsize allowed on ioctl */ ··· 1114 1114 goto out_free_rsp; 1115 1115 1116 1116 vneg_out: 1117 - cifs_server_dbg(VFS, "protocol revalidation - security settings mismatch\n"); 1117 + cifs_tcon_dbg(VFS, "protocol revalidation - security settings mismatch\n"); 1118 1118 out_free_rsp: 1119 1119 kfree(pneg_rsp); 1120 1120 out_free_inbuf: ··· 1762 1762 1763 1763 if ((rsp->Capabilities & SMB2_SHARE_CAP_DFS) && 1764 1764 ((tcon->share_flags & SHI1005_FLAGS_DFS) == 0)) 1765 - cifs_server_dbg(VFS, "DFS capability contradicts DFS flag\n"); 1765 + cifs_tcon_dbg(VFS, "DFS capability contradicts DFS flag\n"); 1766 1766 1767 1767 if (tcon->seal && 1768 1768 !(server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION)) 1769 - cifs_server_dbg(VFS, "Encryption is requested but not supported\n"); 1769 + cifs_tcon_dbg(VFS, "Encryption is requested but not supported\n"); 1770 1770 1771 1771 init_copy_chunk_defaults(tcon); 1772 1772 if (server->ops->validate_negotiate) ··· 1779 1779 1780 1780 tcon_error_exit: 1781 1781 if (rsp && rsp->sync_hdr.Status == STATUS_BAD_NETWORK_NAME) { 1782 - cifs_server_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree); 1782 + cifs_tcon_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree); 1783 1783 } 1784 1784 goto tcon_exit; 1785 1785 } ··· 2812 2812 if (*plen == 0) 2813 2813 goto ioctl_exit; /* server returned no data */ 2814 2814 else if (*plen > rsp_iov.iov_len || *plen > 0xFF00) { 2815 - cifs_server_dbg(VFS, "srv returned invalid ioctl length: %d\n", *plen); 2815 + cifs_tcon_dbg(VFS, "srv returned invalid ioctl length: %d\n", *plen); 2816 2816 *plen = 0; 2817 2817 rc = -EIO; 2818 2818 goto ioctl_exit; 2819 2819 } 2820 2820 2821 2821 if (rsp_iov.iov_len - *plen < le32_to_cpu(rsp->OutputOffset)) { 2822 - cifs_server_dbg(VFS, "Malformed ioctl resp: len %d offset %d\n", *plen, 2822 + cifs_tcon_dbg(VFS, "Malformed ioctl resp: len %d offset %d\n", *plen, 2823 2823 le32_to_cpu(rsp->OutputOffset)); 2824 2824 *plen = 0; 2825 2825 rc = -EIO; ··· 3110 3110 if (!*data) { 3111 3111 *data = kmalloc(*dlen, GFP_KERNEL); 3112 3112 if (!*data) { 3113 - cifs_server_dbg(VFS, 3113 + cifs_tcon_dbg(VFS, 3114 3114 "Error %d allocating memory for acl\n", 3115 3115 rc); 3116 3116 *dlen = 0; ··· 3505 3505 3506 3506 rc = smb2_verify_signature(&rqst, server); 3507 3507 if (rc) 3508 - cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n", 3508 + cifs_tcon_dbg(VFS, "SMB signature verification returned error = %d\n", 3509 3509 rc); 3510 3510 } 3511 3511 /* FIXME: should this be counted toward the initiating task? */ ··· 4095 4095 info_buf_size = sizeof(SEARCH_ID_FULL_DIR_INFO) - 1; 4096 4096 break; 4097 4097 default: 4098 - cifs_server_dbg(VFS, "info level %u isn't supported\n", 4098 + cifs_tcon_dbg(VFS, "info level %u isn't supported\n", 4099 4099 srch_inf->info_level); 4100 4100 rc = -EINVAL; 4101 4101 goto qdir_exit; ··· 4186 4186 else if (resp_buftype == CIFS_SMALL_BUFFER) 4187 4187 srch_inf->smallBuf = true; 4188 4188 else 4189 - cifs_server_dbg(VFS, "illegal search buffer type\n"); 4189 + cifs_tcon_dbg(VFS, "illegal search buffer type\n"); 4190 4190 4191 4191 trace_smb3_query_dir_done(xid, persistent_fid, tcon->tid, 4192 4192 tcon->ses->Suid, index, srch_inf->entries_in_buffer);
+2 -2
fs/cifs/transport.c
··· 1403 1403 use ses->maxReq */ 1404 1404 1405 1405 if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { 1406 - cifs_server_dbg(VFS, "Illegal length, greater than maximum frame, %d\n", 1406 + cifs_tcon_dbg(VFS, "Illegal length, greater than maximum frame, %d\n", 1407 1407 len); 1408 1408 return -EIO; 1409 1409 } ··· 1505 1505 /* rcvd frame is ok */ 1506 1506 if (out_buf == NULL || midQ->mid_state != MID_RESPONSE_RECEIVED) { 1507 1507 rc = -EIO; 1508 - cifs_server_dbg(VFS, "Bad MID state?\n"); 1508 + cifs_tcon_dbg(VFS, "Bad MID state?\n"); 1509 1509 goto out; 1510 1510 } 1511 1511