cifs: add a debug macto that prints \\server\share for errors
Subsystems (2)
PATCH 1/1 cifs: add a debug macto 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 <[email protected]>
--- fs/cifs/cifs_debug.h | 50 +++++++++++++++++++++++++++++++++++++++++------- fs/cifs/smb2ops.c | 54 ++++++++++++++++++++++++++-------------------------- fs/cifs/smb2pdu.c | 28 +++++++++++++-------------- fs/cifs/transport.c | 4 ++-- 4 files changed, 86 insertions(+), 50 deletions(-)
fs/cifs/cifs_debug.h +43 -7
@@ -82,15 +82,18 @@ do { \#define cifs_server_dbg_func (ratefunc, type, fmt, ...) \ do { \ + const char *sn = ""; \ + if (server && server->hostname) \ + sn = server->hostname; \ if ((type) & FYI && cifsFYI & CIFS_INFO) { \ - pr_debug_ ## ratefunc("%s: Server:%s " fmt, \ - __FILE__, server->hostname, ##__VA_ARGS__);\ + pr_debug_ ## ratefunc("%s: \\\\%s " fmt, \ + __FILE__, sn, ##__VA_ARGS__); \ } else if ((type) & VFS) { \ - pr_err_ ## ratefunc("CIFS VFS: Server:%s " fmt, \ - server->hostname, ##__VA_ARGS__); \ + pr_err_ ## ratefunc("CIFS VFS: \\\\%s " fmt, \ + sn, ##__VA_ARGS__); \ } else if ((type) & NOISY && (NOISY != 0)) { \ - pr_debug_ ## ratefunc("Server:%s " fmt, \ - server->hostname, ##__VA_ARGS__); \ + pr_debug_ ## ratefunc("\\\\%s " fmt, \ + sn, ##__VA_ARGS__); \ } \ } while (0)
@@ -104,6 +107,33 @@ do { \ type, fmt, ##__VA_ARGS__); \ } while (0) +#define cifs_tcon_dbg_func (ratefunc, type, fmt, ...) \ +do { \ + const char *tn = ""; \ + if (tcon && tcon->treeName) \ + tn = tcon->treeName; \ + if ((type) & FYI && cifsFYI & CIFS_INFO) { \ + pr_debug_ ## ratefunc("%s: %s " fmt, \ + __FILE__, tn, ##__VA_ARGS__); \ + } else if ((type) & VFS) { \ + pr_err_ ## ratefunc("CIFS VFS: %s " fmt, \ + tn, ##__VA_ARGS__); \ + } else if ((type) & NOISY && (NOISY != 0)) { \ + pr_debug_ ## ratefunc("%s " fmt, \ + tn, ##__VA_ARGS__); \ + } \ +} while (0) + +#define cifs_tcon_dbg (type, fmt, ...) \ +do { \ + if ((type) & ONCE) \ + cifs_tcon_dbg_func(once, \ + type, fmt, ##__VA_ARGS__); \ + else \ + cifs_tcon_dbg_func(ratelimited, \ + type, fmt, ##__VA_ARGS__); \ +} while (0) +/* * debug OFF * ---------
@@ -118,10 +148,16 @@ do { \#define cifs_server_dbg (type, fmt, ...) \ do { \ if (0) \ - pr_debug("Server:%s " fmt, \ + pr_debug("\\\\%s " fmt, \ server->hostname, ##__VA_ARGS__); \ } while (0) +#define cifs_tcon_dbg (type, fmt, ...) \ +do { \ + if (0) \ + pr_debug("%s " fmt, tcon->treeName, ##__VA_ARGS__); \ +} while (0) +#define cifs_info (fmt, ...) \ do { \ pr_info("CIFS: "fmt, ##__VA_ARGS__); \
fs/cifs/smb2ops.c +27 -27
201 lines not on this page · raw message
fs/cifs/smb2pdu.c +14 -14
@@ -1019,7 +1019,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) }if (tcon->ses->session_flags &SMB2_SESSION_FLAG_IS_NULL ) -cifs_server_dbg (VFS ,"Unexpected null user (anonymous) auth flag sent by server\n" ); +cifs_tcon_dbg (VFS ,"Unexpected null user (anonymous) auth flag sent by server\n" ); pneg_inbuf =kmalloc (sizeof (*pneg_inbuf),GFP_NOFS );if (!pneg_inbuf)
@@ -1076,18 +1076,18 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)* Old Windows versions or Netapp SMB server can return * not supported error. Client should accept it. */ -cifs_server_dbg (VFS ,"Server does not support validate negotiate\n" ); +cifs_tcon_dbg (VFS ,"Server does not support validate negotiate\n" ); rc =0 ; goto out_free_inbuf; }else if (rc !=0 ) { -cifs_server_dbg (VFS ,"validate protocol negotiate failed: %d\n" , rc); +cifs_tcon_dbg (VFS ,"validate protocol negotiate failed: %d\n" , rc); rc = -EIO ; goto out_free_inbuf; } rc = -EIO ;if (rsplen !=sizeof (*pneg_rsp)) { -cifs_server_dbg (VFS ,"invalid protocol negotiate response size: %d\n" , +cifs_tcon_dbg (VFS ,"invalid protocol negotiate response size: %d\n" , rsplen);/* relax check since Mac returns max bufsize allowed on ioctl */
@@ -1114,7 +1114,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) goto out_free_rsp; vneg_out: -cifs_server_dbg (VFS ,"protocol revalidation - security settings mismatch\n" ); +cifs_tcon_dbg (VFS ,"protocol revalidation - security settings mismatch\n" ); out_free_rsp:kfree (pneg_rsp); out_free_inbuf:
@@ -1762,11 +1762,11 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,if ((rsp->Capabilities &SMB2_SHARE_CAP_DFS ) && ((tcon->share_flags &SHI1005_FLAGS_DFS ) ==0 )) -cifs_server_dbg (VFS ,"DFS capability contradicts DFS flag\n" ); +cifs_tcon_dbg (VFS ,"DFS capability contradicts DFS flag\n" );if (tcon->seal && !(server->capabilities &SMB2_GLOBAL_CAP_ENCRYPTION )) -cifs_server_dbg (VFS ,"Encryption is requested but not supported\n" ); +cifs_tcon_dbg (VFS ,"Encryption is requested but not supported\n" );init_copy_chunk_defaults (tcon);if (server->ops->validate_negotiate)
@@ -1779,7 +1779,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, tcon_error_exit:if (rsp && rsp->sync_hdr.Status ==STATUS_BAD_NETWORK_NAME ) { -cifs_server_dbg (VFS ,"BAD_NETWORK_NAME: %s\n" , tree); +cifs_tcon_dbg (VFS ,"BAD_NETWORK_NAME: %s\n" , tree); } goto tcon_exit; }
@@ -2812,14 +2812,14 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,if (*plen ==0 ) goto ioctl_exit;/* server returned no data */ else if (*plen > rsp_iov.iov_len || *plen >0xFF00 ) { -cifs_server_dbg (VFS ,"srv returned invalid ioctl length: %d\n" , *plen); +cifs_tcon_dbg (VFS ,"srv returned invalid ioctl length: %d\n" , *plen); *plen =0 ; rc = -EIO ; goto ioctl_exit; }if (rsp_iov.iov_len - *plen <le32_to_cpu (rsp->OutputOffset)) { -cifs_server_dbg (VFS ,"Malformed ioctl resp: len %d offset %d\n" , *plen, +cifs_tcon_dbg (VFS ,"Malformed ioctl resp: len %d offset %d\n" , *plen,le32_to_cpu (rsp->OutputOffset)); *plen =0 ; rc = -EIO ;
@@ -3110,7 +3110,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,if (!*data) { *data =kmalloc (*dlen,GFP_KERNEL );if (!*data) { -cifs_server_dbg (VFS , +cifs_tcon_dbg (VFS ,"Error %d allocating memory for acl\n" , rc); *dlen =0 ;
@@ -3505,7 +3505,7 @@ smb2_readv_callback(struct mid_q_entry *mid) rc =smb2_verify_signature (&rqst, server);if (rc) -cifs_server_dbg (VFS ,"SMB signature verification returned error = %d\n" , +cifs_tcon_dbg (VFS ,"SMB signature verification returned error = %d\n" , rc); }/* FIXME: should this be counted toward the initiating task? */
@@ -4095,7 +4095,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, info_buf_size =sizeof (SEARCH_ID_FULL_DIR_INFO ) -1 ;break ;default : -cifs_server_dbg (VFS ,"info level %u isn't supported\n" , +cifs_tcon_dbg (VFS ,"info level %u isn't supported\n" , srch_inf->info_level); rc = -EINVAL ; goto qdir_exit;
@@ -4186,7 +4186,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,else if (resp_buftype ==CIFS_SMALL_BUFFER ) srch_inf->smallBuf = true;else -cifs_server_dbg (VFS ,"illegal search buffer type\n" ); +cifs_tcon_dbg (VFS ,"illegal search buffer type\n" );trace_smb3_query_dir_done (xid, persistent_fid, tcon->tid, tcon->ses->Suid, index, srch_inf->entries_in_buffer);
fs/cifs/transport.c +2 -2
@@ -1403,7 +1403,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,use ses->maxReq */ if (len > CIFSMaxBufSize +MAX_CIFS_HDR_SIZE -4 ) { -cifs_server_dbg (VFS ,"Illegal length, greater than maximum frame, %d\n" , +cifs_tcon_dbg (VFS ,"Illegal length, greater than maximum frame, %d\n" , len);return -EIO ; }
@@ -1505,7 +1505,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,/* rcvd frame is ok */ if (out_buf ==NULL || midQ->mid_state !=MID_RESPONSE_RECEIVED ) { rc = -EIO ; -cifs_server_dbg (VFS ,"Bad MID state?\n" ); +cifs_tcon_dbg (VFS ,"Bad MID state?\n" ); goto out; }
Signature · 1 line
2.13.6