Skip to content

Commit

Permalink
[CIFS] cifs: Rename cERROR and cFYI to cifs_dbg
Browse files Browse the repository at this point in the history
It's not obvious from reading the macro names that these macros
are for debugging.  Convert the names to a single more typical
kernel style cifs_dbg macro.

	cERROR(1, ...)   -> cifs_dbg(VFS, ...)
	cFYI(1, ...)     -> cifs_dbg(FYI, ...)
	cFYI(DBG2, ...)  -> cifs_dbg(NOISY, ...)

Move the terminating format newline from the macro to the call site.

Add CONFIG_CIFS_DEBUG function cifs_vfs_err to emit the
"CIFS VFS: " prefix for VFS messages.

Size is reduced ~ 1% when CONFIG_CIFS_DEBUG is set (default y)

$ size fs/cifs/cifs.ko*
   text    data     bss     dec     hex filename
 265245	   2525	    132	 267902	  4167e	fs/cifs/cifs.ko.new
 268359    2525     132  271016   422a8 fs/cifs/cifs.ko.old

Other miscellaneous changes around these conversions:

o Miscellaneous typo fixes
o Add terminating \n's to almost all formats and remove them
  from the macros to be more kernel style like.  A few formats
  previously had defective \n's
o Remove unnecessary OOM messages as kmalloc() calls dump_stack
o Coalesce formats to make grep easier,
  added missing spaces when coalescing formats
o Use %s, __func__ instead of embedded function name
o Removed unnecessary "cifs: " prefixes
o Convert kzalloc with multiply to kcalloc
o Remove unused cifswarn macro

Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: Jeff Layton <[email protected]>
Signed-off-by: Steve French <[email protected]>
  • Loading branch information
JoePerches authored and smfrench committed May 5, 2013
1 parent f7f7c18 commit f96637b
Show file tree
Hide file tree
Showing 36 changed files with 1,223 additions and 1,227 deletions.
40 changes: 20 additions & 20 deletions fs/cifs/asn1.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,11 @@ decode_negTokenInit(unsigned char *security_blob, int length,

/* GSSAPI header */
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
cFYI(1, "Error decoding negTokenInit header");
cifs_dbg(FYI, "Error decoding negTokenInit header\n");
return 0;
} else if ((cls != ASN1_APL) || (con != ASN1_CON)
|| (tag != ASN1_EOC)) {
cFYI(1, "cls = %d con = %d tag = %d", cls, con, tag);
cifs_dbg(FYI, "cls = %d con = %d tag = %d\n", cls, con, tag);
return 0;
}

Expand All @@ -531,68 +531,68 @@ decode_negTokenInit(unsigned char *security_blob, int length,

/* SPNEGO OID not present or garbled -- bail out */
if (!rc) {
cFYI(1, "Error decoding negTokenInit header");
cifs_dbg(FYI, "Error decoding negTokenInit header\n");
return 0;
}

/* SPNEGO */
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
cFYI(1, "Error decoding negTokenInit");
cifs_dbg(FYI, "Error decoding negTokenInit\n");
return 0;
} else if ((cls != ASN1_CTX) || (con != ASN1_CON)
|| (tag != ASN1_EOC)) {
cFYI(1, "cls = %d con = %d tag = %d end = %p (%d) exit 0",
cls, con, tag, end, *end);
cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p (%d) exit 0\n",
cls, con, tag, end, *end);
return 0;
}

/* negTokenInit */
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
cFYI(1, "Error decoding negTokenInit");
cifs_dbg(FYI, "Error decoding negTokenInit\n");
return 0;
} else if ((cls != ASN1_UNI) || (con != ASN1_CON)
|| (tag != ASN1_SEQ)) {
cFYI(1, "cls = %d con = %d tag = %d end = %p (%d) exit 1",
cls, con, tag, end, *end);
cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p (%d) exit 1\n",
cls, con, tag, end, *end);
return 0;
}

/* sequence */
if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
cFYI(1, "Error decoding 2nd part of negTokenInit");
cifs_dbg(FYI, "Error decoding 2nd part of negTokenInit\n");
return 0;
} else if ((cls != ASN1_CTX) || (con != ASN1_CON)
|| (tag != ASN1_EOC)) {
cFYI(1, "cls = %d con = %d tag = %d end = %p (%d) exit 0",
cls, con, tag, end, *end);
cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p (%d) exit 0\n",
cls, con, tag, end, *end);
return 0;
}

/* sequence of */
if (asn1_header_decode
(&ctx, &sequence_end, &cls, &con, &tag) == 0) {
cFYI(1, "Error decoding 2nd part of negTokenInit");
cifs_dbg(FYI, "Error decoding 2nd part of negTokenInit\n");
return 0;
} else if ((cls != ASN1_UNI) || (con != ASN1_CON)
|| (tag != ASN1_SEQ)) {
cFYI(1, "cls = %d con = %d tag = %d end = %p (%d) exit 1",
cls, con, tag, end, *end);
cifs_dbg(FYI, "cls = %d con = %d tag = %d end = %p (%d) exit 1\n",
cls, con, tag, end, *end);
return 0;
}

/* list of security mechanisms */
while (!asn1_eoc_decode(&ctx, sequence_end)) {
rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
if (!rc) {
cFYI(1, "Error decoding negTokenInit hdr exit2");
cifs_dbg(FYI, "Error decoding negTokenInit hdr exit2\n");
return 0;
}
if ((tag == ASN1_OJI) && (con == ASN1_PRI)) {
if (asn1_oid_decode(&ctx, end, &oid, &oidlen)) {

cFYI(1, "OID len = %d oid = 0x%lx 0x%lx "
"0x%lx 0x%lx", oidlen, *oid,
*(oid + 1), *(oid + 2), *(oid + 3));
cifs_dbg(FYI, "OID len = %d oid = 0x%lx 0x%lx 0x%lx 0x%lx\n",
oidlen, *oid, *(oid + 1), *(oid + 2),
*(oid + 3));

if (compare_oid(oid, oidlen, MSKRB5_OID,
MSKRB5_OID_LEN))
Expand All @@ -610,7 +610,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
kfree(oid);
}
} else {
cFYI(1, "Should be an oid what is going on?");
cifs_dbg(FYI, "Should be an oid what is going on?\n");
}
}

Expand Down
6 changes: 3 additions & 3 deletions fs/cifs/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static uint16_t cifs_server_get_key(const void *cookie_netfs_data,
break;

default:
cERROR(1, "Unknown network family '%d'", sa->sa_family);
cifs_dbg(VFS, "Unknown network family '%d'\n", sa->sa_family);
key_len = 0;
break;
}
Expand Down Expand Up @@ -152,7 +152,7 @@ static uint16_t cifs_super_get_key(const void *cookie_netfs_data, void *buffer,

sharename = extract_sharename(tcon->treeName);
if (IS_ERR(sharename)) {
cFYI(1, "%s: couldn't extract sharename", __func__);
cifs_dbg(FYI, "%s: couldn't extract sharename\n", __func__);
sharename = NULL;
return 0;
}
Expand Down Expand Up @@ -302,7 +302,7 @@ static void cifs_fscache_inode_now_uncached(void *cookie_netfs_data)
pagevec_init(&pvec, 0);
first = 0;

cFYI(1, "%s: cifs inode 0x%p now uncached", __func__, cifsi);
cifs_dbg(FYI, "%s: cifs inode 0x%p now uncached\n", __func__, cifsi);

for (;;) {
nr_pages = pagevec_lookup(&pvec,
Expand Down
67 changes: 42 additions & 25 deletions fs/cifs/cifs_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,32 @@ cifs_dump_mem(char *label, void *data, int length)
}
}

#ifdef CONFIG_CIFS_DEBUG
void cifs_vfs_err(const char *fmt, ...)
{
struct va_format vaf;
va_list args;

va_start(args, fmt);

vaf.fmt = fmt;
vaf.va = &args;

printk(KERN_ERR "CIFS VFS: %pV", &vaf);

va_end(args);
}
#endif

void cifs_dump_detail(void *buf)
{
#ifdef CONFIG_CIFS_DEBUG2
struct smb_hdr *smb = (struct smb_hdr *)buf;

cERROR(1, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d",
smb->Command, smb->Status.CifsError,
smb->Flags, smb->Flags2, smb->Mid, smb->Pid);
cERROR(1, "smb buf %p len %u", smb, smbCalcSize(smb));
cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d\n",
smb->Command, smb->Status.CifsError,
smb->Flags, smb->Flags2, smb->Mid, smb->Pid);
cifs_dbg(VFS, "smb buf %p len %u\n", smb, smbCalcSize(smb));
#endif /* CONFIG_CIFS_DEBUG2 */
}

Expand All @@ -78,25 +95,25 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
if (server == NULL)
return;

cERROR(1, "Dump pending requests:");
cifs_dbg(VFS, "Dump pending requests:\n");
spin_lock(&GlobalMid_Lock);
list_for_each(tmp, &server->pending_mid_q) {
mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
cERROR(1, "State: %d Cmd: %d Pid: %d Cbdata: %p Mid %llu",
mid_entry->mid_state,
le16_to_cpu(mid_entry->command),
mid_entry->pid,
mid_entry->callback_data,
mid_entry->mid);
cifs_dbg(VFS, "State: %d Cmd: %d Pid: %d Cbdata: %p Mid %llu\n",
mid_entry->mid_state,
le16_to_cpu(mid_entry->command),
mid_entry->pid,
mid_entry->callback_data,
mid_entry->mid);
#ifdef CONFIG_CIFS_STATS2
cERROR(1, "IsLarge: %d buf: %p time rcv: %ld now: %ld",
mid_entry->large_buf,
mid_entry->resp_buf,
mid_entry->when_received,
jiffies);
cifs_dbg(VFS, "IsLarge: %d buf: %p time rcv: %ld now: %ld\n",
mid_entry->large_buf,
mid_entry->resp_buf,
mid_entry->when_received,
jiffies);
#endif /* STATS2 */
cERROR(1, "IsMult: %d IsEnd: %d", mid_entry->multiRsp,
mid_entry->multiEnd);
cifs_dbg(VFS, "IsMult: %d IsEnd: %d\n",
mid_entry->multiRsp, mid_entry->multiEnd);
if (mid_entry->resp_buf) {
cifs_dump_detail(mid_entry->resp_buf);
cifs_dump_mem("existing buf: ",
Expand Down Expand Up @@ -603,34 +620,34 @@ static ssize_t cifs_security_flags_proc_write(struct file *file,
global_secflags = CIFSSEC_MAX;
return count;
} else if (!isdigit(c)) {
cERROR(1, "invalid flag %c", c);
cifs_dbg(VFS, "invalid flag %c\n", c);
return -EINVAL;
}
}
/* else we have a number */

flags = simple_strtoul(flags_string, NULL, 0);

cFYI(1, "sec flags 0x%x", flags);
cifs_dbg(FYI, "sec flags 0x%x\n", flags);

if (flags <= 0) {
cERROR(1, "invalid security flags %s", flags_string);
cifs_dbg(VFS, "invalid security flags %s\n", flags_string);
return -EINVAL;
}

if (flags & ~CIFSSEC_MASK) {
cERROR(1, "attempt to set unsupported security flags 0x%x",
flags & ~CIFSSEC_MASK);
cifs_dbg(VFS, "attempt to set unsupported security flags 0x%x\n",
flags & ~CIFSSEC_MASK);
return -EINVAL;
}
/* flags look ok - update the global security flags for cifs module */
global_secflags = flags;
if (global_secflags & CIFSSEC_MUST_SIGN) {
/* requiring signing implies signing is allowed */
global_secflags |= CIFSSEC_MAY_SIGN;
cFYI(1, "packet signing now required");
cifs_dbg(FYI, "packet signing now required\n");
} else if ((global_secflags & CIFSSEC_MAY_SIGN) == 0) {
cFYI(1, "packet signing disabled");
cifs_dbg(FYI, "packet signing disabled\n");
}
/* BB should we turn on MAY flags for other MUST options? */
return count;
Expand Down
70 changes: 23 additions & 47 deletions fs/cifs/cifs_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,78 +25,54 @@
void cifs_dump_mem(char *label, void *data, int length);
void cifs_dump_detail(void *);
void cifs_dump_mids(struct TCP_Server_Info *);
#ifdef CONFIG_CIFS_DEBUG2
#define DBG2 2
#else
#define DBG2 0
#endif
extern int traceSMB; /* flag which enables the function below */
void dump_smb(void *, int);
#define CIFS_INFO 0x01
#define CIFS_RC 0x02
#define CIFS_TIMER 0x04

#define VFS 1
#define FYI 2
extern int cifsFYI;
#ifdef CONFIG_CIFS_DEBUG2
#define NOISY 4
#else
#define NOISY 0
#endif

/*
* debug ON
* --------
*/
#ifdef CONFIG_CIFS_DEBUG

/* information message: e.g., configuration, major event */
#define cifsfyi(fmt, ...) \
do { \
if (cifsFYI & CIFS_INFO) \
printk(KERN_DEBUG "%s: " fmt "\n", \
__FILE__, ##__VA_ARGS__); \
} while (0)

#define cFYI(set, fmt, ...) \
do { \
if (set) \
cifsfyi(fmt, ##__VA_ARGS__); \
} while (0)
__printf(1, 2) void cifs_vfs_err(const char *fmt, ...);

#define cifswarn(fmt, ...) \
printk(KERN_WARNING fmt "\n", ##__VA_ARGS__)

/* error event message: e.g., i/o error */
#define cifserror(fmt, ...) \
printk(KERN_ERR "CIFS VFS: " fmt "\n", ##__VA_ARGS__); \

#define cERROR(set, fmt, ...) \
/* information message: e.g., configuration, major event */
#define cifs_dbg(type, fmt, ...) \
do { \
if (set) \
cifserror(fmt, ##__VA_ARGS__); \
if (type == FYI) { \
if (cifsFYI & CIFS_INFO) { \
printk(KERN_DEBUG "%s: " fmt, \
__FILE__, ##__VA_ARGS__); \
} \
} else if (type == VFS) { \
cifs_vfs_err(fmt, ##__VA_ARGS__); \
} else if (type == NOISY && type != 0) { \
printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
} \
} while (0)

/*
* debug OFF
* ---------
*/
#else /* _CIFS_DEBUG */
#define cifsfyi(fmt, ...) \
#define cifs_dbg(type, fmt, ...) \
do { \
if (0) \
printk(KERN_DEBUG "%s: " fmt "\n", \
__FILE__, ##__VA_ARGS__); \
printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
} while (0)
#define cFYI(set, fmt, ...) \
do { \
if (0 && set) \
cifsfyi(fmt, ##__VA_ARGS__); \
} while (0)
#define cifserror(fmt, ...) \
do { \
if (0) \
printk(KERN_ERR "CIFS VFS: " fmt "\n", ##__VA_ARGS__); \
} while (0)
#define cERROR(set, fmt, ...) \
do { \
if (0 && set) \
cifserror(fmt, ##__VA_ARGS__); \
} while (0)
#endif /* _CIFS_DEBUG */
#endif

#endif /* _H_CIFS_DEBUG */
Loading

0 comments on commit f96637b

Please sign in to comment.