Skip to content

Commit a0a3036

Browse files
JoePerchessmfrench
authored andcommitted
cifs: Standardize logging output
Use pr_fmt to standardize all logging for fs/cifs. Some logging output had no CIFS: specific prefix. Now all output has one of three prefixes: o CIFS: o CIFS: VFS: o Root-CIFS: Miscellanea: o Convert printks to pr_<level> o Neaten macro definitions o Remove embedded CIFS: prefixes from formats o Convert "illegal" to "invalid" o Coalesce formats o Add missing '\n' format terminations o Consolidate multiple cifs_dbg continuations into single calls o More consistent use of upper case first word output logging o Multiline statement argument alignment and wrapping Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 82e9367 commit a0a3036

20 files changed

Lines changed: 319 additions & 381 deletions

‎fs/cifs/cifs_debug.h‎

Lines changed: 69 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
#ifndef _H_CIFS_DEBUG
99
#define _H_CIFS_DEBUG
1010

11+
#ifdef pr_fmt
12+
#undef pr_fmt
13+
#endif
14+
15+
#define pr_fmt(fmt) "CIFS: " fmt
16+
1117
void cifs_dump_mem(char *label, void *data, int length);
1218
void cifs_dump_detail(void *buf, struct TCP_Server_Info *ptcp_info);
1319
void cifs_dump_mids(struct TCP_Server_Info *);
@@ -46,92 +52,81 @@ extern int cifsFYI;
4652
*/
4753

4854
/* Information level messages, minor events */
49-
#define cifs_info_func(ratefunc, fmt, ...) \
50-
do { \
51-
pr_info_ ## ratefunc("CIFS: " fmt, ##__VA_ARGS__); \
52-
} while (0)
55+
#define cifs_info_func(ratefunc, fmt, ...) \
56+
pr_info_ ## ratefunc(fmt, ##__VA_ARGS__)
5357

54-
#define cifs_info(fmt, ...) \
55-
do { \
56-
cifs_info_func(ratelimited, fmt, ##__VA_ARGS__); \
57-
} while (0)
58+
#define cifs_info(fmt, ...) \
59+
cifs_info_func(ratelimited, fmt, ##__VA_ARGS__)
5860

5961
/* information message: e.g., configuration, major event */
60-
#define cifs_dbg_func(ratefunc, type, fmt, ...) \
61-
do { \
62-
if ((type) & FYI && cifsFYI & CIFS_INFO) { \
63-
pr_debug_ ## ratefunc("%s: " \
64-
fmt, __FILE__, ##__VA_ARGS__); \
65-
} else if ((type) & VFS) { \
66-
pr_err_ ## ratefunc("CIFS VFS: " \
67-
fmt, ##__VA_ARGS__); \
68-
} else if ((type) & NOISY && (NOISY != 0)) { \
69-
pr_debug_ ## ratefunc(fmt, ##__VA_ARGS__); \
70-
} \
62+
#define cifs_dbg_func(ratefunc, type, fmt, ...) \
63+
do { \
64+
if ((type) & FYI && cifsFYI & CIFS_INFO) { \
65+
pr_debug_ ## ratefunc("%s: " fmt, \
66+
__FILE__, ##__VA_ARGS__); \
67+
} else if ((type) & VFS) { \
68+
pr_err_ ## ratefunc("VFS: " fmt, ##__VA_ARGS__); \
69+
} else if ((type) & NOISY && (NOISY != 0)) { \
70+
pr_debug_ ## ratefunc(fmt, ##__VA_ARGS__); \
71+
} \
7172
} while (0)
7273

73-
#define cifs_dbg(type, fmt, ...) \
74-
do { \
75-
if ((type) & ONCE) \
76-
cifs_dbg_func(once, \
77-
type, fmt, ##__VA_ARGS__); \
78-
else \
79-
cifs_dbg_func(ratelimited, \
80-
type, fmt, ##__VA_ARGS__); \
74+
#define cifs_dbg(type, fmt, ...) \
75+
do { \
76+
if ((type) & ONCE) \
77+
cifs_dbg_func(once, type, fmt, ##__VA_ARGS__); \
78+
else \
79+
cifs_dbg_func(ratelimited, type, fmt, ##__VA_ARGS__); \
8180
} while (0)
8281

83-
#define cifs_server_dbg_func(ratefunc, type, fmt, ...) \
84-
do { \
85-
const char *sn = ""; \
86-
if (server && server->hostname) \
87-
sn = server->hostname; \
88-
if ((type) & FYI && cifsFYI & CIFS_INFO) { \
89-
pr_debug_ ## ratefunc("%s: \\\\%s " fmt, \
90-
__FILE__, sn, ##__VA_ARGS__); \
91-
} else if ((type) & VFS) { \
92-
pr_err_ ## ratefunc("CIFS VFS: \\\\%s " fmt, \
93-
sn, ##__VA_ARGS__); \
94-
} else if ((type) & NOISY && (NOISY != 0)) { \
95-
pr_debug_ ## ratefunc("\\\\%s " fmt, \
96-
sn, ##__VA_ARGS__); \
97-
} \
82+
#define cifs_server_dbg_func(ratefunc, type, fmt, ...) \
83+
do { \
84+
const char *sn = ""; \
85+
if (server && server->hostname) \
86+
sn = server->hostname; \
87+
if ((type) & FYI && cifsFYI & CIFS_INFO) { \
88+
pr_debug_ ## ratefunc("%s: \\\\%s " fmt, \
89+
__FILE__, sn, ##__VA_ARGS__); \
90+
} else if ((type) & VFS) { \
91+
pr_err_ ## ratefunc("VFS: \\\\%s " fmt, \
92+
sn, ##__VA_ARGS__); \
93+
} else if ((type) & NOISY && (NOISY != 0)) { \
94+
pr_debug_ ## ratefunc("\\\\%s " fmt, \
95+
sn, ##__VA_ARGS__); \
96+
} \
9897
} while (0)
9998

100-
#define cifs_server_dbg(type, fmt, ...) \
101-
do { \
102-
if ((type) & ONCE) \
103-
cifs_server_dbg_func(once, \
104-
type, fmt, ##__VA_ARGS__); \
105-
else \
106-
cifs_server_dbg_func(ratelimited, \
107-
type, fmt, ##__VA_ARGS__); \
99+
#define cifs_server_dbg(type, fmt, ...) \
100+
do { \
101+
if ((type) & ONCE) \
102+
cifs_server_dbg_func(once, type, fmt, ##__VA_ARGS__); \
103+
else \
104+
cifs_server_dbg_func(ratelimited, type, fmt, \
105+
##__VA_ARGS__); \
108106
} while (0)
109107

110-
#define cifs_tcon_dbg_func(ratefunc, type, fmt, ...) \
111-
do { \
112-
const char *tn = ""; \
113-
if (tcon && tcon->treeName) \
114-
tn = tcon->treeName; \
115-
if ((type) & FYI && cifsFYI & CIFS_INFO) { \
116-
pr_debug_ ## ratefunc("%s: %s " fmt, \
117-
__FILE__, tn, ##__VA_ARGS__); \
118-
} else if ((type) & VFS) { \
119-
pr_err_ ## ratefunc("CIFS VFS: %s " fmt, \
120-
tn, ##__VA_ARGS__); \
121-
} else if ((type) & NOISY && (NOISY != 0)) { \
122-
pr_debug_ ## ratefunc("%s " fmt, \
123-
tn, ##__VA_ARGS__); \
124-
} \
108+
#define cifs_tcon_dbg_func(ratefunc, type, fmt, ...) \
109+
do { \
110+
const char *tn = ""; \
111+
if (tcon && tcon->treeName) \
112+
tn = tcon->treeName; \
113+
if ((type) & FYI && cifsFYI & CIFS_INFO) { \
114+
pr_debug_ ## ratefunc("%s: %s " fmt, \
115+
__FILE__, tn, ##__VA_ARGS__); \
116+
} else if ((type) & VFS) { \
117+
pr_err_ ## ratefunc("VFS: %s " fmt, tn, ##__VA_ARGS__); \
118+
} else if ((type) & NOISY && (NOISY != 0)) { \
119+
pr_debug_ ## ratefunc("%s " fmt, tn, ##__VA_ARGS__); \
120+
} \
125121
} while (0)
126122

127-
#define cifs_tcon_dbg(type, fmt, ...) \
128-
do { \
129-
if ((type) & ONCE) \
130-
cifs_tcon_dbg_func(once, \
131-
type, fmt, ##__VA_ARGS__); \
132-
else \
133-
cifs_tcon_dbg_func(ratelimited, \
134-
type, fmt, ##__VA_ARGS__); \
123+
#define cifs_tcon_dbg(type, fmt, ...) \
124+
do { \
125+
if ((type) & ONCE) \
126+
cifs_tcon_dbg_func(once, type, fmt, ##__VA_ARGS__); \
127+
else \
128+
cifs_tcon_dbg_func(ratelimited, type, fmt, \
129+
##__VA_ARGS__); \
135130
} while (0)
136131

137132
/*
@@ -159,9 +154,7 @@ do { \
159154
} while (0)
160155

161156
#define cifs_info(fmt, ...) \
162-
do { \
163-
pr_info("CIFS: "fmt, ##__VA_ARGS__); \
164-
} while (0)
157+
pr_info(fmt, ##__VA_ARGS__)
165158
#endif
166159

167160
#endif /* _H_CIFS_DEBUG */

‎fs/cifs/cifsencrypt.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
520520

521521
rc = crypto_shash_init(&ses->server->secmech.sdeschmacmd5->shash);
522522
if (rc) {
523-
cifs_dbg(VFS, "%s: could not init hmacmd5\n", __func__);
523+
cifs_dbg(VFS, "%s: Could not init hmacmd5\n", __func__);
524524
return rc;
525525
}
526526

@@ -624,7 +624,7 @@ CalcNTLMv2_response(const struct cifs_ses *ses, char *ntlmv2_hash)
624624

625625
rc = crypto_shash_init(&ses->server->secmech.sdeschmacmd5->shash);
626626
if (rc) {
627-
cifs_dbg(VFS, "%s: could not init hmacmd5\n", __func__);
627+
cifs_dbg(VFS, "%s: Could not init hmacmd5\n", __func__);
628628
return rc;
629629
}
630630

@@ -723,7 +723,7 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
723723
/* calculate ntlmv2_hash */
724724
rc = calc_ntlmv2_hash(ses, ntlmv2_hash, nls_cp);
725725
if (rc) {
726-
cifs_dbg(VFS, "could not get v2 hash rc %d\n", rc);
726+
cifs_dbg(VFS, "Could not get v2 hash rc %d\n", rc);
727727
goto unlock;
728728
}
729729

@@ -783,7 +783,7 @@ calc_seckey(struct cifs_ses *ses)
783783

784784
ctx_arc4 = kmalloc(sizeof(*ctx_arc4), GFP_KERNEL);
785785
if (!ctx_arc4) {
786-
cifs_dbg(VFS, "could not allocate arc4 context\n");
786+
cifs_dbg(VFS, "Could not allocate arc4 context\n");
787787
return -ENOMEM;
788788
}
789789

‎fs/cifs/cifsproto.h‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,25 @@ extern int smb_send(struct TCP_Server_Info *, struct smb_hdr *,
4545
unsigned int /* length */);
4646
extern unsigned int _get_xid(void);
4747
extern void _free_xid(unsigned int);
48-
#define get_xid() \
49-
({ \
48+
#define get_xid() \
49+
({ \
5050
unsigned int __xid = _get_xid(); \
51-
cifs_dbg(FYI, "CIFS VFS: in %s as Xid: %u with uid: %d\n", \
51+
cifs_dbg(FYI, "VFS: in %s as Xid: %u with uid: %d\n", \
5252
__func__, __xid, \
5353
from_kuid(&init_user_ns, current_fsuid())); \
54-
trace_smb3_enter(__xid, __func__); \
55-
__xid; \
54+
trace_smb3_enter(__xid, __func__); \
55+
__xid; \
5656
})
5757

58-
#define free_xid(curr_xid) \
59-
do { \
60-
_free_xid(curr_xid); \
61-
cifs_dbg(FYI, "CIFS VFS: leaving %s (xid = %u) rc = %d\n", \
62-
__func__, curr_xid, (int)rc); \
63-
if (rc) \
58+
#define free_xid(curr_xid) \
59+
do { \
60+
_free_xid(curr_xid); \
61+
cifs_dbg(FYI, "VFS: leaving %s (xid = %u) rc = %d\n", \
62+
__func__, curr_xid, (int)rc); \
63+
if (rc) \
6464
trace_smb3_exit_err(curr_xid, __func__, (int)rc); \
65-
else \
66-
trace_smb3_exit_done(curr_xid, __func__); \
65+
else \
66+
trace_smb3_exit_done(curr_xid, __func__); \
6767
} while (0)
6868
extern int init_cifs_idmap(void);
6969
extern void exit_cifs_idmap(void);

‎fs/cifs/cifsroot.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static int __init cifs_root_setup(char *line)
5656
/* len is strlen(unc) + '\0' */
5757
len = s - line + 1;
5858
if (len > sizeof(root_dev)) {
59-
printk(KERN_ERR "Root-CIFS: UNC path too long\n");
59+
pr_err("Root-CIFS: UNC path too long\n");
6060
return 1;
6161
}
6262
strlcpy(root_dev, line, len);
@@ -66,7 +66,7 @@ static int __init cifs_root_setup(char *line)
6666
sizeof(root_opts), "%s,%s",
6767
DEFAULT_MNT_OPTS, s + 1);
6868
if (n >= sizeof(root_opts)) {
69-
printk(KERN_ERR "Root-CIFS: mount options string too long\n");
69+
pr_err("Root-CIFS: mount options string too long\n");
7070
root_opts[sizeof(root_opts)-1] = '\0';
7171
return 1;
7272
}
@@ -83,7 +83,7 @@ __setup("cifsroot=", cifs_root_setup);
8383
int __init cifs_root_data(char **dev, char **opts)
8484
{
8585
if (!root_dev[0] || root_server_addr == htonl(INADDR_NONE)) {
86-
printk(KERN_ERR "Root-CIFS: no SMB server address\n");
86+
pr_err("Root-CIFS: no SMB server address\n");
8787
return -1;
8888
}
8989

‎fs/cifs/cifssmb.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
281281
(server->tcpStatus != CifsNeedReconnect),
282282
10 * HZ);
283283
if (rc < 0) {
284-
cifs_dbg(FYI, "%s: aborting reconnect due to a received"
285-
" signal by the process\n", __func__);
284+
cifs_dbg(FYI, "%s: aborting reconnect due to a received signal by the process\n",
285+
__func__);
286286
return -ERESTARTSYS;
287287
}
288288

@@ -343,7 +343,7 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
343343
cifs_dbg(FYI, "reconnect tcon rc = %d\n", rc);
344344

345345
if (rc) {
346-
printk_once(KERN_WARNING "reconnect tcon failed rc = %d\n", rc);
346+
pr_warn_once("reconnect tcon failed rc = %d\n", rc);
347347
goto out;
348348
}
349349

@@ -576,7 +576,7 @@ cifs_enable_signing(struct TCP_Server_Info *server, bool mnt_sign_required)
576576
/* If server requires signing, does client allow it? */
577577
if (srv_sign_required) {
578578
if (!mnt_sign_enabled) {
579-
cifs_dbg(VFS, "Server requires signing, but it's disabled in SecurityFlags!");
579+
cifs_dbg(VFS, "Server requires signing, but it's disabled in SecurityFlags!\n");
580580
return -ENOTSUPP;
581581
}
582582
server->sign = true;
@@ -585,14 +585,14 @@ cifs_enable_signing(struct TCP_Server_Info *server, bool mnt_sign_required)
585585
/* If client requires signing, does server allow it? */
586586
if (mnt_sign_required) {
587587
if (!srv_sign_enabled) {
588-
cifs_dbg(VFS, "Server does not support signing!");
588+
cifs_dbg(VFS, "Server does not support signing!\n");
589589
return -ENOTSUPP;
590590
}
591591
server->sign = true;
592592
}
593593

594594
if (cifs_rdma_enabled(server) && server->sign)
595-
cifs_dbg(VFS, "Signing is enabled, and RDMA read/write will be disabled");
595+
cifs_dbg(VFS, "Signing is enabled, and RDMA read/write will be disabled\n");
596596

597597
return 0;
598598
}
@@ -722,7 +722,7 @@ CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses)
722722
pSMB->hdr.Flags2 |= (SMBFLG2_UNICODE | SMBFLG2_ERR_STATUS);
723723

724724
if (should_set_ext_sec_flag(ses->sectype)) {
725-
cifs_dbg(FYI, "Requesting extended security.");
725+
cifs_dbg(FYI, "Requesting extended security\n");
726726
pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC;
727727
}
728728

@@ -3887,7 +3887,7 @@ CIFSGetExtAttr(const unsigned int xid, struct cifs_tcon *tcon,
38873887
struct file_chattr_info *pfinfo;
38883888
/* BB Do we need a cast or hash here ? */
38893889
if (count != 16) {
3890-
cifs_dbg(FYI, "Illegal size ret in GetExtAttr\n");
3890+
cifs_dbg(FYI, "Invalid size ret in GetExtAttr\n");
38913891
rc = -EIO;
38923892
goto GetExtAttrOut;
38933893
}
@@ -4263,7 +4263,7 @@ CIFSSMBQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
42634263
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
42644264
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
42654265
if (rc) {
4266-
cifs_dbg(FYI, "Send error in QFileInfo = %d", rc);
4266+
cifs_dbg(FYI, "Send error in QFileInfo = %d\n", rc);
42674267
} else { /* decode response */
42684268
rc = validate_t2((struct smb_t2_rsp *)pSMBr);
42694269

@@ -4430,7 +4430,7 @@ CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
44304430
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
44314431
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
44324432
if (rc) {
4433-
cifs_dbg(FYI, "Send error in UnixQFileInfo = %d", rc);
4433+
cifs_dbg(FYI, "Send error in UnixQFileInfo = %d\n", rc);
44344434
} else { /* decode response */
44354435
rc = validate_t2((struct smb_t2_rsp *)pSMBr);
44364436

@@ -4512,7 +4512,7 @@ CIFSSMBUnixQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
45124512
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
45134513
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
45144514
if (rc) {
4515-
cifs_dbg(FYI, "Send error in UnixQPathInfo = %d", rc);
4515+
cifs_dbg(FYI, "Send error in UnixQPathInfo = %d\n", rc);
45164516
} else { /* decode response */
45174517
rc = validate_t2((struct smb_t2_rsp *)pSMBr);
45184518

@@ -4932,7 +4932,7 @@ CIFSGetSrvInodeNumber(const unsigned int xid, struct cifs_tcon *tcon,
49324932
struct file_internal_info *pfinfo;
49334933
/* BB Do we need a cast or hash here ? */
49344934
if (count < 8) {
4935-
cifs_dbg(FYI, "Illegal size ret in QryIntrnlInf\n");
4935+
cifs_dbg(FYI, "Invalid size ret in QryIntrnlInf\n");
49364936
rc = -EIO;
49374937
goto GetInodeNumOut;
49384938
}

0 commit comments

Comments
 (0)