Commit 87c1b497 authored by Fabian Frederick's avatar Fabian Frederick Committed by Linus Torvalds

ntfs: logging clean-up

- Convert spinlock/static array to va_format (inspired by Joe Perches
  help on previous logging patches).

- Convert printk(KERN_ERR to pr_warn in __ntfs_warning.

- Convert printk(KERN_ERR to pr_err in __ntfs_error.

- Convert printk(KERN_DEBUG to pr_debug in __ntfs_debug.  (Note that
  __ntfs_debug is still guarded by #if DEBUG)

- Improve !DEBUG to parse all arguments (Joe Perches).

- Sparse pr_foo() conversions in super.c

NTFS, NTFS-fs prefixes as well as 'warning' and 'error' were removed :
pr_foo() automatically adds module name and error level is already
specified.
Signed-off-by: default avatarFabian Frederick <fabf@skynet.be>
Cc: Anton Altaparmakov <anton@tuxera.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2b3a8fd7
...@@ -18,16 +18,9 @@ ...@@ -18,16 +18,9 @@
* distribution in the file COPYING); if not, write to the Free Software * distribution in the file COPYING); if not, write to the Free Software
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include "debug.h" #include "debug.h"
/*
* A static buffer to hold the error string being displayed and a spinlock
* to protect concurrent accesses to it.
*/
static char err_buf[1024];
static DEFINE_SPINLOCK(err_buf_lock);
/** /**
* __ntfs_warning - output a warning to the syslog * __ntfs_warning - output a warning to the syslog
* @function: name of function outputting the warning * @function: name of function outputting the warning
...@@ -50,6 +43,7 @@ static DEFINE_SPINLOCK(err_buf_lock); ...@@ -50,6 +43,7 @@ static DEFINE_SPINLOCK(err_buf_lock);
void __ntfs_warning(const char *function, const struct super_block *sb, void __ntfs_warning(const char *function, const struct super_block *sb,
const char *fmt, ...) const char *fmt, ...)
{ {
struct va_format vaf;
va_list args; va_list args;
int flen = 0; int flen = 0;
...@@ -59,17 +53,15 @@ void __ntfs_warning(const char *function, const struct super_block *sb, ...@@ -59,17 +53,15 @@ void __ntfs_warning(const char *function, const struct super_block *sb,
#endif #endif
if (function) if (function)
flen = strlen(function); flen = strlen(function);
spin_lock(&err_buf_lock);
va_start(args, fmt); va_start(args, fmt);
vsnprintf(err_buf, sizeof(err_buf), fmt, args); vaf.fmt = fmt;
va_end(args); vaf.va = &args;
if (sb) if (sb)
printk(KERN_ERR "NTFS-fs warning (device %s): %s(): %s\n", pr_warn("(device %s): %s(): %pV\n",
sb->s_id, flen ? function : "", err_buf); sb->s_id, flen ? function : "", &vaf);
else else
printk(KERN_ERR "NTFS-fs warning: %s(): %s\n", pr_warn("%s(): %pV\n", flen ? function : "", &vaf);
flen ? function : "", err_buf); va_end(args);
spin_unlock(&err_buf_lock);
} }
/** /**
...@@ -94,6 +86,7 @@ void __ntfs_warning(const char *function, const struct super_block *sb, ...@@ -94,6 +86,7 @@ void __ntfs_warning(const char *function, const struct super_block *sb,
void __ntfs_error(const char *function, const struct super_block *sb, void __ntfs_error(const char *function, const struct super_block *sb,
const char *fmt, ...) const char *fmt, ...)
{ {
struct va_format vaf;
va_list args; va_list args;
int flen = 0; int flen = 0;
...@@ -103,17 +96,15 @@ void __ntfs_error(const char *function, const struct super_block *sb, ...@@ -103,17 +96,15 @@ void __ntfs_error(const char *function, const struct super_block *sb,
#endif #endif
if (function) if (function)
flen = strlen(function); flen = strlen(function);
spin_lock(&err_buf_lock);
va_start(args, fmt); va_start(args, fmt);
vsnprintf(err_buf, sizeof(err_buf), fmt, args); vaf.fmt = fmt;
va_end(args); vaf.va = &args;
if (sb) if (sb)
printk(KERN_ERR "NTFS-fs error (device %s): %s(): %s\n", pr_err("(device %s): %s(): %pV\n",
sb->s_id, flen ? function : "", err_buf); sb->s_id, flen ? function : "", &vaf);
else else
printk(KERN_ERR "NTFS-fs error: %s(): %s\n", pr_err("%s(): %pV\n", flen ? function : "", &vaf);
flen ? function : "", err_buf); va_end(args);
spin_unlock(&err_buf_lock);
} }
#ifdef DEBUG #ifdef DEBUG
...@@ -124,6 +115,7 @@ int debug_msgs = 0; ...@@ -124,6 +115,7 @@ int debug_msgs = 0;
void __ntfs_debug (const char *file, int line, const char *function, void __ntfs_debug (const char *file, int line, const char *function,
const char *fmt, ...) const char *fmt, ...)
{ {
struct va_format vaf;
va_list args; va_list args;
int flen = 0; int flen = 0;
...@@ -131,13 +123,11 @@ void __ntfs_debug (const char *file, int line, const char *function, ...@@ -131,13 +123,11 @@ void __ntfs_debug (const char *file, int line, const char *function,
return; return;
if (function) if (function)
flen = strlen(function); flen = strlen(function);
spin_lock(&err_buf_lock);
va_start(args, fmt); va_start(args, fmt);
vsnprintf(err_buf, sizeof(err_buf), fmt, args); vaf.fmt = fmt;
vaf.va = &args;
pr_debug("(%s, %d): %s(): %pV", file, line, flen ? function : "", &vaf);
va_end(args); va_end(args);
printk(KERN_DEBUG "NTFS-fs DEBUG (%s, %d): %s(): %s\n", file, line,
flen ? function : "", err_buf);
spin_unlock(&err_buf_lock);
} }
/* Dump a runlist. Caller has to provide synchronisation for @rl. */ /* Dump a runlist. Caller has to provide synchronisation for @rl. */
...@@ -149,12 +139,12 @@ void ntfs_debug_dump_runlist(const runlist_element *rl) ...@@ -149,12 +139,12 @@ void ntfs_debug_dump_runlist(const runlist_element *rl)
if (!debug_msgs) if (!debug_msgs)
return; return;
printk(KERN_DEBUG "NTFS-fs DEBUG: Dumping runlist (values in hex):\n"); pr_debug("Dumping runlist (values in hex):\n");
if (!rl) { if (!rl) {
printk(KERN_DEBUG "Run list not present.\n"); pr_debug("Run list not present.\n");
return; return;
} }
printk(KERN_DEBUG "VCN LCN Run length\n"); pr_debug("VCN LCN Run length\n");
for (i = 0; ; i++) { for (i = 0; ; i++) {
LCN lcn = (rl + i)->lcn; LCN lcn = (rl + i)->lcn;
...@@ -163,13 +153,13 @@ void ntfs_debug_dump_runlist(const runlist_element *rl) ...@@ -163,13 +153,13 @@ void ntfs_debug_dump_runlist(const runlist_element *rl)
if (index > -LCN_ENOENT - 1) if (index > -LCN_ENOENT - 1)
index = 3; index = 3;
printk(KERN_DEBUG "%-16Lx %s %-16Lx%s\n", pr_debug("%-16Lx %s %-16Lx%s\n",
(long long)(rl + i)->vcn, lcn_str[index], (long long)(rl + i)->vcn, lcn_str[index],
(long long)(rl + i)->length, (long long)(rl + i)->length,
(rl + i)->length ? "" : (rl + i)->length ? "" :
" (runlist end)"); " (runlist end)");
} else } else
printk(KERN_DEBUG "%-16Lx %-16Lx %-16Lx%s\n", pr_debug("%-16Lx %-16Lx %-16Lx%s\n",
(long long)(rl + i)->vcn, (long long)(rl + i)->vcn,
(long long)(rl + i)->lcn, (long long)(rl + i)->lcn,
(long long)(rl + i)->length, (long long)(rl + i)->length,
......
...@@ -48,7 +48,12 @@ extern void ntfs_debug_dump_runlist(const runlist_element *rl); ...@@ -48,7 +48,12 @@ extern void ntfs_debug_dump_runlist(const runlist_element *rl);
#else /* !DEBUG */ #else /* !DEBUG */
#define ntfs_debug(f, a...) do {} while (0) #define ntfs_debug(fmt, ...) \
do { \
if (0) \
no_printk(fmt, ##__VA_ARGS__); \
} while (0)
#define ntfs_debug_dump_runlist(rl) do {} while (0) #define ntfs_debug_dump_runlist(rl) do {} while (0)
#endif /* !DEBUG */ #endif /* !DEBUG */
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
* distribution in the file COPYING); if not, write to the Free Software * distribution in the file COPYING); if not, write to the Free Software
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -1896,7 +1897,7 @@ static bool load_system_files(ntfs_volume *vol) ...@@ -1896,7 +1897,7 @@ static bool load_system_files(ntfs_volume *vol)
vol->minor_ver = vi->minor_ver; vol->minor_ver = vi->minor_ver;
ntfs_attr_put_search_ctx(ctx); ntfs_attr_put_search_ctx(ctx);
unmap_mft_record(NTFS_I(vol->vol_ino)); unmap_mft_record(NTFS_I(vol->vol_ino));
printk(KERN_INFO "NTFS volume version %i.%i.\n", vol->major_ver, pr_info("volume version %i.%i.\n", vol->major_ver,
vol->minor_ver); vol->minor_ver);
if (vol->major_ver < 3 && NVolSparseEnabled(vol)) { if (vol->major_ver < 3 && NVolSparseEnabled(vol)) {
ntfs_warning(vol->sb, "Disabling sparse support due to NTFS " ntfs_warning(vol->sb, "Disabling sparse support due to NTFS "
...@@ -3095,7 +3096,7 @@ static int __init init_ntfs_fs(void) ...@@ -3095,7 +3096,7 @@ static int __init init_ntfs_fs(void)
int err = 0; int err = 0;
/* This may be ugly but it results in pretty output so who cares. (-8 */ /* This may be ugly but it results in pretty output so who cares. (-8 */
printk(KERN_INFO "NTFS driver " NTFS_VERSION " [Flags: R/" pr_info("driver " NTFS_VERSION " [Flags: R/"
#ifdef NTFS_RW #ifdef NTFS_RW
"W" "W"
#else #else
...@@ -3115,16 +3116,15 @@ static int __init init_ntfs_fs(void) ...@@ -3115,16 +3116,15 @@ static int __init init_ntfs_fs(void)
sizeof(ntfs_index_context), 0 /* offset */, sizeof(ntfs_index_context), 0 /* offset */,
SLAB_HWCACHE_ALIGN, NULL /* ctor */); SLAB_HWCACHE_ALIGN, NULL /* ctor */);
if (!ntfs_index_ctx_cache) { if (!ntfs_index_ctx_cache) {
printk(KERN_CRIT "NTFS: Failed to create %s!\n", pr_crit("Failed to create %s!\n", ntfs_index_ctx_cache_name);
ntfs_index_ctx_cache_name);
goto ictx_err_out; goto ictx_err_out;
} }
ntfs_attr_ctx_cache = kmem_cache_create(ntfs_attr_ctx_cache_name, ntfs_attr_ctx_cache = kmem_cache_create(ntfs_attr_ctx_cache_name,
sizeof(ntfs_attr_search_ctx), 0 /* offset */, sizeof(ntfs_attr_search_ctx), 0 /* offset */,
SLAB_HWCACHE_ALIGN, NULL /* ctor */); SLAB_HWCACHE_ALIGN, NULL /* ctor */);
if (!ntfs_attr_ctx_cache) { if (!ntfs_attr_ctx_cache) {
printk(KERN_CRIT "NTFS: Failed to create %s!\n", pr_crit("NTFS: Failed to create %s!\n",
ntfs_attr_ctx_cache_name); ntfs_attr_ctx_cache_name);
goto actx_err_out; goto actx_err_out;
} }
...@@ -3132,8 +3132,7 @@ static int __init init_ntfs_fs(void) ...@@ -3132,8 +3132,7 @@ static int __init init_ntfs_fs(void)
(NTFS_MAX_NAME_LEN+1) * sizeof(ntfschar), 0, (NTFS_MAX_NAME_LEN+1) * sizeof(ntfschar), 0,
SLAB_HWCACHE_ALIGN, NULL); SLAB_HWCACHE_ALIGN, NULL);
if (!ntfs_name_cache) { if (!ntfs_name_cache) {
printk(KERN_CRIT "NTFS: Failed to create %s!\n", pr_crit("Failed to create %s!\n", ntfs_name_cache_name);
ntfs_name_cache_name);
goto name_err_out; goto name_err_out;
} }
...@@ -3141,8 +3140,7 @@ static int __init init_ntfs_fs(void) ...@@ -3141,8 +3140,7 @@ static int __init init_ntfs_fs(void)
sizeof(ntfs_inode), 0, sizeof(ntfs_inode), 0,
SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL); SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL);
if (!ntfs_inode_cache) { if (!ntfs_inode_cache) {
printk(KERN_CRIT "NTFS: Failed to create %s!\n", pr_crit("Failed to create %s!\n", ntfs_inode_cache_name);
ntfs_inode_cache_name);
goto inode_err_out; goto inode_err_out;
} }
...@@ -3151,15 +3149,14 @@ static int __init init_ntfs_fs(void) ...@@ -3151,15 +3149,14 @@ static int __init init_ntfs_fs(void)
SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
ntfs_big_inode_init_once); ntfs_big_inode_init_once);
if (!ntfs_big_inode_cache) { if (!ntfs_big_inode_cache) {
printk(KERN_CRIT "NTFS: Failed to create %s!\n", pr_crit("Failed to create %s!\n", ntfs_big_inode_cache_name);
ntfs_big_inode_cache_name);
goto big_inode_err_out; goto big_inode_err_out;
} }
/* Register the ntfs sysctls. */ /* Register the ntfs sysctls. */
err = ntfs_sysctl(1); err = ntfs_sysctl(1);
if (err) { if (err) {
printk(KERN_CRIT "NTFS: Failed to register NTFS sysctls!\n"); pr_crit("Failed to register NTFS sysctls!\n");
goto sysctl_err_out; goto sysctl_err_out;
} }
...@@ -3168,7 +3165,7 @@ static int __init init_ntfs_fs(void) ...@@ -3168,7 +3165,7 @@ static int __init init_ntfs_fs(void)
ntfs_debug("NTFS driver registered successfully."); ntfs_debug("NTFS driver registered successfully.");
return 0; /* Success! */ return 0; /* Success! */
} }
printk(KERN_CRIT "NTFS: Failed to register NTFS filesystem driver!\n"); pr_crit("Failed to register NTFS filesystem driver!\n");
/* Unregister the ntfs sysctls. */ /* Unregister the ntfs sysctls. */
ntfs_sysctl(0); ntfs_sysctl(0);
...@@ -3184,8 +3181,7 @@ static int __init init_ntfs_fs(void) ...@@ -3184,8 +3181,7 @@ static int __init init_ntfs_fs(void)
kmem_cache_destroy(ntfs_index_ctx_cache); kmem_cache_destroy(ntfs_index_ctx_cache);
ictx_err_out: ictx_err_out:
if (!err) { if (!err) {
printk(KERN_CRIT "NTFS: Aborting NTFS filesystem driver " pr_crit("Aborting NTFS filesystem driver registration...\n");
"registration...\n");
err = -ENOMEM; err = -ENOMEM;
} }
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment