netfs: Restore selective debug mask handling
Subsystems (2)
PATCH 1/1 netfs: Restore selective debug mask handling
The netfs debug macros test only whether netfs_debug is nonzero. Consequently, selecting one debug point enables every entry, exit and general debug message.
Documentation/filesystems/caching/fscache.rst and the NETFS_DEBUG Kconfig help still describe /sys/module/netfs/parameters/debug as a bitmask of per-stream function entry, exit and general debugging points, and the fscache_*.c files still define FSCACHE_DEBUG_LEVEL, but nothing has decoded either since the mask handling was dropped when FS-Cache was folded into netfs.
Restore the per-level and per-point mask decoding. Files that do not define FSCACHE_DEBUG_LEVEL, which includes the netfs core, fall under the cache management stream, the same default the FS-Cache macros had.
--- fs/netfs/internal.h | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-)
fs/netfs/internal.h +29 -3
@@ -468,6 +468,32 @@ void fscache_create_volume(struct fscache_volume *volume, bool wait);#define kleave (FMT , ...) dbgprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__)#define kdebug (FMT , ...) dbgprintk(FMT, ##__VA_ARGS__) +#define FSCACHE_DEBUG_CACHE 0 +#define FSCACHE_DEBUG_COOKIE 1 +#define FSCACHE_DEBUG_OBJECT 2 +#define FSCACHE_DEBUG_OPERATION 3 + +#define FSCACHE_POINT_ENTER 1 +#define FSCACHE_POINT_LEAVE 2 +#define FSCACHE_POINT_DEBUG 4 + +#ifndef FSCACHE_DEBUG_LEVEL +#define FSCACHE_DEBUG_LEVEL CACHE +#endif + +/* +* Determine whether a particular optional debugging point should be logged. +* Three levels of indirection are needed to expand FSCACHE_DEBUG_LEVEL before +* joining it with its prefix. +*/ +#define ____do_kdebug (LEVEL ,POINT ) \ + unlikely(netfs_debug & \ + (FSCACHE_POINT_##POINT << (FSCACHE_DEBUG_ ## LEVEL * 3))) +#define ___do_kdebug (LEVEL ,POINT ) \ + ____do_kdebug(LEVEL, POINT) +#define __do_kdebug (POINT ) \ + ___do_kdebug(FSCACHE_DEBUG_LEVEL, POINT) +#ifdef __KDEBUG#define _enter (FMT , ...) kenter(FMT, ##__VA_ARGS__)#define _leave (FMT , ...) kleave(FMT, ##__VA_ARGS__)
@@ -476,19 +502,19 @@ void fscache_create_volume(struct fscache_volume *volume, bool wait);#elif defined(CONFIG_NETFS_DEBUG )#define _enter (FMT , ...) \ do { \ - if (netfs_debug) \ + if (__do_kdebug(ENTER)) \ kenter(FMT, ##__VA_ARGS__); \ } while (0)#define _leave (FMT , ...) \ do { \ - if (netfs_debug) \ + if (__do_kdebug(LEAVE)) \ kleave(FMT, ##__VA_ARGS__); \ } while (0)#define _debug (FMT , ...) \ do { \ - if (netfs_debug) \ + if (__do_kdebug(DEBUG)) \ kdebug(FMT, ##__VA_ARGS__); \ } while (0)
Signature · 1 line
2.53.0
Quoted 11 lines · Karl Mehltretter
The netfs debug macros test only whether
netfs_debugis nonzero. Consequently, selecting one debug point enables every entry, exit and general debug message.
Documentation/filesystems/caching/fscache.rstand theNETFS_DEBUGKconfighelp still describe/sys/module/netfs/parameters/debugas a bitmask of per-stream function entry, exit and general debugging points, and the fscache_*.c files still defineFSCACHE_DEBUG_LEVEL, but nothing has decoded either since the mask handling was dropped when FS-Cache was folded into netfs.
Quoted 7 lines
Restore the per-level and per-point mask decoding. Files that do not define
FSCACHE_DEBUG_LEVEL, which includes the netfs core, fall under the cache management stream, the same default the FS-Cache macros had.Fixes 915cd30cdea8 ("netfs, fscache: Combine fscache with netfs")Assisted-by LLMSigned-off-by Karl Mehltretter <[email protected]>
A friendly ping on this debug-mask fix.
Thanks,
Karl
Quoted 4 lines · Karl Mehltretter
The netfs debug macros test only whether
netfs_debugis nonzero. Consequently, selecting one debug point enables every entry, exit and general debug message.
Quoted 8 lines
Documentation/filesystems/caching/fscache.rstand theNETFS_DEBUGKconfighelp still describe/sys/module/netfs/parameters/debugas a bitmask of per-stream function entry, exit and general debugging points, and the fscache_*.c files still defineFSCACHE_DEBUG_LEVEL, but nothing has decoded either since the mask handling was dropped when FS-Cache was folded into netfs.[...]
Applied to the vfs.fixes branch of the vfs/vfs.git tree. Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.fixes
[1/1] netfs: Restore selective debug mask handling
https://git.kernel.org/vfs/vfs/c/35f4755ed06f