CIFS: Info-level log support, print message when attempting mount.
Subsystems (2)
v3 cover CIFS: Info-level log support, print message when attempting mount.
Hi Steve,
Quoted 1 line
From our conversation over v2, I came out with this v3 patch, which I broke
in two commits:
* The first commit in cifs_debug.h, creating the cifs_info() function.
- The aim of this commit is to allow to the developer to be able to print informational-level data without having to use pr_info, pr_notice etc, in line with other filesystems.
. One interesting and noteworthy feature of cifs_info() is that it is
transparent to the CIFS_DEBUG config state, either in "y" or "n".
. Also, by using KERN_INFO level, it can be safely filtered by a
maintainer / administrator, without cluttering their log monitors, since this is a low level alert.
- I took the liberty to not add it inside the existing pr_debug, because of the eventual need of some developer to print stuff that should be printed not only in CIFS_DEBUG mode (as there are plenty of pr_notice scattered over the code).
- Also, this is not a debug but a info message, so i liked cifs_info()
more ;-)
- I saw plenty of pr_notice() in CIFS code, but I resisted the urge to convert them to cifs_info().
* The second commit contains the code printing a cifs_info() when attempting a CIFS mount operation.
Appreciate your review.
V3: Created a new cifs_info() function, moved the mount attempt message to
cifs_info
V2: Created a loop to select the right cifs_dbg message to be printed,
considering the current system's scenario, in order to avoid a duplicate message or stripping out important information in debug.
Rodrigo Freire (2):
CIFS: Adds information-level logging function
CIFS: Print message when attempting a mount
fs/cifs/cifs_debug.h | 16 ++++++++++++++++ fs/cifs/cifsfs.c | 7 ++++++- fs/cifs/transport.c | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v3 1/2 CIFS: Adds information-level logging function
Currently, CIFS lacks a internal logging function that prints out data when CIFS_DEBUG=n. When CIFS_DEBUG=y, the only message level for CIFS events are KERN_ERR or KERN_DEBUG.
This patch creates cifs_info(), which is useful for printing non-critical event messges, at either CIFS_DEBUG state.
--- fs/cifs/cifs_debug.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
fs/cifs/cifs_debug.h +16 -0
@@ -47,6 +47,17 @@*/ #ifdef CONFIG_CIFS_DEBUG +/* Information level messages, minor events */ +#define cifs_info_func (ratefunc, fmt, ...) \ +do { \ + pr_info_ ## ratefunc("CIFS: " fmt, ##__VA_ARGS__); \ +} while (0) + +#define cifs_info (fmt, ...) \ +do { \ + cifs_info_func(ratelimited, fmt, ##__VA_ARGS__); \ +} while (0) +/* information message: e.g., configuration, major event */ #define cifs_dbg_func (ratefunc, type, fmt, ...) \ do { \
@@ -81,6 +92,11 @@if (0 ) \ pr_debug(fmt, ##__VA_ARGS__); \ } while (0) + +#define cifs_info (fmt, ...) \ +do { \ + pr_info("CIFS: "fmt, ##__VA_ARGS__); \ +} while (0)#endif #endif /* _H_CIFS_DEBUG */
Signature · 1 line
1.8.3.1
PATCH v3 2/2 CIFS: Print message when attempting a mount
In reply to Rodrigo FreireCurrently, no messages are printed when mounting a CIFS filesystem and no debug configuration is enabled.
However, a CIFS mount information is valuable when troubleshooting and/or forensic analyzing a system and finding out if was a CIFS endpoint mount attempted.
Other filesystems such as XFS, EXT* does issue a printk() when mounting their filesystems.
A terse log message is printed only if cifsFYI is not enabled. Otherwise, the default full debug message is printed.
In order to not clutter and classify correctly the event messages, these are logged as KERN_INFO level.
Sample mount operations:
[root@corinthians ~]# mount -o user=administrator //172.25.250.18/c$ /mnt (non-existent system)
[root@corinthians ~]# mount -o user=administrator //172.25.250.19/c$ /mnt (Valid system)
Kernel message log for the mount operations:
[ 450.464543] CIFS: Attempting to mount //172.25.250.18/c$ [ 456.478186] CIFS VFS: Error connecting to socket. Aborting operation. [ 456.478381] CIFS VFS: cifs_mount failed w/return code = -113 [ 467.688866] CIFS: Attempting to mount //172.25.250.19/c$
--- fs/cifs/cifsfs.c | 7 ++++++- fs/cifs/transport.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-)
fs/cifs/cifsfs.c +6 -1
@@ -707,7 +707,12 @@ static int cifs_set_super(struct super_block *sb, void *data)struct cifs_mnt_data mnt_data;struct dentry *root; -cifs_dbg (FYI ,"Devname: %s flags: %d\n" , dev_name, flags); +/* Prints in Kernel / CIFS log the attempted mount operation * +* IF CIFS_DEBUG && cifs_FYI */ +if (cifsFYI) +cifs_dbg (FYI ,"Devname: %s flags: %d\n" , dev_name, flags); +else +cifs_info ("Attempting to mount %s\n" , dev_name); volume_info =cifs_get_volume_info ((char *)data, dev_name, is_smb3);if (IS_ERR (volume_info))
fs/cifs/transport.c +1 -1
@@ -128,7 +128,7 @@ void cifs_mid_q_entry_release(struct mid_q_entry *midEntry)if (cifsFYI &CIFS_TIMER ) {pr_debug (" CIFS slow rsp: cmd %d mid %llu" , midEntry->command, midEntry->mid); -pr_info (" A: 0x%lx S: 0x%lx R: 0x%lx\n" , +cifs_info (" A: 0x%lx S: 0x%lx R: 0x%lx\n" , now - midEntry->when_alloc, now - midEntry->when_sent, now - midEntry->when_received);
Signature · 1 line
1.8.3.1
Steve French
AppliedMerged into cifs-2.6.git for-next
Made a trivial tab/space correction in the patch (pointed out by checkpatch) and then added a trivial followon patch to address a comment/style (trivial)
issue pointed out by checkpatch and to add a little more detailed comments about generally when to use each debug function. If any objections let me know.
Quoted 48 lines · Rodrigo Freire
Hi Steve,
From our conversation over v2, I came out with this v3 patch, which I broke in two commits:* The first commit in
cifs_debug.h, creating thecifs_info()function.
- The aim of this commit is to allow to the developer to be able to print informational-level data without having to usepr_info,pr_noticeetc, in line with other filesystems.
. One interesting and noteworthy feature ofcifs_info()is that it is
transparent to theCIFS_DEBUGconfig state, either in "y" or "n".
. Also, by usingKERN_INFOlevel, it can be safely filtered by a
maintainer / administrator, without cluttering their log monitors, since this is a low level alert.
- I took the liberty to not add it inside the existingpr_debug, because of the eventual need of some developer to print stuff that should be printed not only inCIFS_DEBUGmode (as there are plenty ofpr_noticescattered over the code).
- Also, this is not a debug but a info message, so i likedcifs_info()more ;-)- I saw plenty of
pr_notice()in CIFS code, but I resisted the urge to convert them tocifs_info().* The second commit contains the code printing a
cifs_info()when attempting a CIFS mount operation.Appreciate your review.
V3: Created a new
cifs_info()function, moved the mount attempt message to
cifs_infoV2: Created a loop to select the right
cifs_dbgmessage to be printed,
considering the current system's scenario, in order to avoid a duplicate message or stripping out important information in debug.Rodrigo Freire (2):
CIFS: Adds information-level logging function
CIFS: Print message when attempting a mountfs/cifs/cifs_debug.h | 16 ++++++++++++++++ fs/cifs/cifsfs.c | 7 ++++++- fs/cifs/transport.c | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-)--
1.8.3.1
Signature · 3 lines
Thanks, Steve
From 4c939344f94a273a1eab89cf58f74c9ad68a8a8d Mon Sep 17 00:00:00 2001
From: Steve French <[email protected]>
Date: Sun, 7 Oct 2018 13:52:18 -0500
Subject: [PATCH] cifs: minor clarification in comments
Clarify meaning (in comments) meaning of various options for debug messages in cifs.ko. Also fixed trivial formatting/style issue with previous patch.
--- fs/cifs/cifs_debug.h | 12 ++++++++++++ fs/cifs/cifsfs.c | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-)
fs/cifs/cifs_debug.h +12 -0
@@ -47,6 +47,18 @@ extern int cifsFYI;*/ #ifdef CONFIG_CIFS_DEBUG + +/* +* When adding tracepoints and debug messages we have various choices. +* Some considerations: +* +* Use cifs_dbg(VFS, ...) for things we always want logged, and the user to see +* cifs_info(...) slightly less important, admin can filter via loglevel > 6 +* cifs_dbg(FYI, ...) minor debugging messages, off by default +* trace_smb3_* ftrace functions are preferred for complex debug messages +* intended for developers or experienced admins, off by default +*/ +/* Information level messages, minor events */ #define cifs_info_func (ratefunc, fmt, ...) \ do { \
fs/cifs/cifsfs.c +4 -2
@@ -717,8 +717,10 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,struct cifs_mnt_data mnt_data;struct dentry *root; -/* Prints in Kernel / CIFS log the attempted mount operation * -* IF CIFS_DEBUG && cifs_FYI */ +/* +* Prints in Kernel / CIFS log the attempted mount operation +* If CIFS_DEBUG && cifs_FYI +*/ if (cifsFYI)cifs_dbg (FYI ,"Devname: %s flags: %d\n" , dev_name, flags);else
Signature · 1 line
2.17.1
Thanks Steve! Sorry for overlooking it, whoops.
One more question; what’s your/community opinion on rewriting the existing pr_notice to the new cifs_info?
I could happily retrofit it.
Have a great week!
- RF
Sent from a mobile device
Quoted 68 lines · Steve French
Merged into cifs-2.6.git for-next
Made a trivial tab/space correction in the patch (pointed out by checkpatch) and then added a trivial followon patch to address a comment/style (trivial)
issue pointed out by checkpatch and to add a little more detailed comments about generally when to use each debug function. If any objections let me know.Quoted 49 lines · Rodrigo Freire
Hi Steve,
From our conversation over v2, I came out with this v3 patch, which I broke in two commits:* The first commit in
cifs_debug.h, creating thecifs_info()function.
- The aim of this commit is to allow to the developer to be able to print informational-level data without having to usepr_info,pr_noticeetc, in line with other filesystems.
. One interesting and noteworthy feature ofcifs_info()is that it is
transparent to theCIFS_DEBUGconfig state, either in "y" or "n".
. Also, by usingKERN_INFOlevel, it can be safely filtered by a
maintainer / administrator, without cluttering their log monitors, since this is a low level alert.
- I took the liberty to not add it inside the existingpr_debug, because of the eventual need of some developer to print stuff that should be printed not only inCIFS_DEBUGmode (as there are plenty ofpr_noticescattered over the code).
- Also, this is not a debug but a info message, so i likedcifs_info()more ;-)
- I saw plenty ofpr_notice()in CIFS code, but I resisted the urge to convert them tocifs_info().* The second commit contains the code printing a
cifs_info()when attempting a CIFS mount operation.Appreciate your review.
V3: Created a new
cifs_info()function, moved the mount attempt message to
cifs_infoV2: Created a loop to select the right
cifs_dbgmessage to be printed,
considering the current system's scenario, in order to avoid a duplicate message or stripping out important information in debug.Rodrigo Freire (2):
CIFS: Adds information-level logging function
CIFS: Print message when attempting a mountfs/cifs/cifs_debug.h | 16 ++++++++++++++++ fs/cifs/cifsfs.c | 7 ++++++- fs/cifs/transport.c | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-)--
1.8.3.1Signature · 4 lines
Thanks, Steve <0001-cifs-minor-clarification-in-comments.patch>
Quoted 6 lines · Rodrigo Freire
Thanks Steve! Sorry for overlooking it, whoops.
One more question; what’s your/community opinion on rewriting the existing
pr_noticeto the newcifs_info?I could happily retrofit it.
I don't have a strong opinion. The four callers could be changed, but my gut reaction
is that it is a much higher priority to add useful dynamic tracepoints (ftrace ie trace-cmd)
to cifs to make it easier to debug real customer problems that are currently awkward to
debug. By comparison, even ext4 has over 100 dynamic tracepoints, but larger
file systems like XFS has 500 (!), and nfs (including SunRPC) has about 100.
My guess is that going from our current 28 dynamic trace points (in cifs.ko) to double
that (at least) will happen as developers add tracepoints to help them debug real
problems (and of course it will help developers working on future problems even more ...)
Quoted 24 lines
Quoted 24 lines · Steve French
Merged into cifs-2.6.git for-next
Made a trivial tab/space correction in the patch (pointed out by checkpatch) and then added a trivial followon patch to address a comment/style (trivial)
issue pointed out by checkpatch and to add a little more detailed comments about generally when to use each debug function. If any objections let me know.Quoted 12 lines · Rodrigo Freire
Hi Steve,
From our conversation over v2, I came out with this v3 patch, which I broke in two commits:* The first commit in
cifs_debug.h, creating thecifs_info()function.
- The aim of this commit is to allow to the developer to be able to print informational-level data without having to usepr_info,pr_noticeetc, in line with other filesystems.
. One interesting and noteworthy feature ofcifs_info()is that it is
transparent to theCIFS_DEBUGconfig state, either in "y" or "n".
<snip>
Signature · 3 lines
Thanks, Steve