diff options
| author | Fabian Frederick <fabf@skynet.be> | 2014-04-07 18:36:53 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-07 19:35:49 -0400 |
| commit | 87c1b497c299e48e681f041de4dd6ce4831aaf75 (patch) | |
| tree | d91b138e1601db9e06377649515dc4aa4d3f8186 /fs/ntfs | |
| parent | 2b3a8fd735f86ebeb2b9d061054003000c36b654 (diff) | |
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: Fabian Frederick <fabf@skynet.be>
Cc: Anton Altaparmakov <anton@tuxera.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ntfs')
| -rw-r--r-- | fs/ntfs/debug.c | 58 | ||||
| -rw-r--r-- | fs/ntfs/debug.h | 7 | ||||
| -rw-r--r-- | fs/ntfs/super.c | 28 |
3 files changed, 42 insertions, 51 deletions
diff --git a/fs/ntfs/debug.c b/fs/ntfs/debug.c index 807150e2c2b9..dd6103cc93c1 100644 --- a/fs/ntfs/debug.c +++ b/fs/ntfs/debug.c | |||
| @@ -18,16 +18,9 @@ | |||
| 18 | * distribution in the file COPYING); if not, write to the Free Software | 18 | * distribution in the file COPYING); if not, write to the Free Software |
| 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ | 20 | */ |
| 21 | 21 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | |
| 22 | #include "debug.h" | 22 | #include "debug.h" |
| 23 | 23 | ||
| 24 | /* | ||
| 25 | * A static buffer to hold the error string being displayed and a spinlock | ||
| 26 | * to protect concurrent accesses to it. | ||
| 27 | */ | ||
| 28 | static char err_buf[1024]; | ||
| 29 | static DEFINE_SPINLOCK(err_buf_lock); | ||
| 30 | |||
| 31 | /** | 24 | /** |
| 32 | * __ntfs_warning - output a warning to the syslog | 25 | * __ntfs_warning - output a warning to the syslog |
| 33 | * @function: name of function outputting the warning | 26 | * @function: name of function outputting the warning |
| @@ -50,6 +43,7 @@ static DEFINE_SPINLOCK(err_buf_lock); | |||
| 50 | void __ntfs_warning(const char *function, const struct super_block *sb, | 43 | void __ntfs_warning(const char *function, const struct super_block *sb, |
| 51 | const char *fmt, ...) | 44 | const char *fmt, ...) |
| 52 | { | 45 | { |
| 46 | struct va_format vaf; | ||
| 53 | va_list args; | 47 | va_list args; |
| 54 | int flen = 0; | 48 | int flen = 0; |
| 55 | 49 | ||
| @@ -59,17 +53,15 @@ void __ntfs_warning(const char *function, const struct super_block *sb, | |||
| 59 | #endif | 53 | #endif |
| 60 | if (function) | 54 | if (function) |
| 61 | flen = strlen(function); | 55 | flen = strlen(function); |
| 62 | spin_lock(&err_buf_lock); | ||
| 63 | va_start(args, fmt); | 56 | va_start(args, fmt); |
| 64 | vsnprintf(err_buf, sizeof(err_buf), fmt, args); | 57 | vaf.fmt = fmt; |
| 65 | va_end(args); | 58 | vaf.va = &args; |
| 66 | if (sb) | 59 | if (sb) |
| 67 | printk(KERN_ERR "NTFS-fs warning (device %s): %s(): %s\n", | 60 | pr_warn("(device %s): %s(): %pV\n", |
| 68 | sb->s_id, flen ? function : "", err_buf); | 61 | sb->s_id, flen ? function : "", &vaf); |
| 69 | else | 62 | else |
| 70 | printk(KERN_ERR "NTFS-fs warning: %s(): %s\n", | 63 | pr_warn("%s(): %pV\n", flen ? function : "", &vaf); |
| 71 | flen ? function : "", err_buf); | 64 | va_end(args); |
| 72 | spin_unlock(&err_buf_lock); | ||
| 73 | } | 65 | } |
| 74 | 66 | ||
| 75 | /** | 67 | /** |
| @@ -94,6 +86,7 @@ void __ntfs_warning(const char *function, const struct super_block *sb, | |||
| 94 | void __ntfs_error(const char *function, const struct super_block *sb, | 86 | void __ntfs_error(const char *function, const struct super_block *sb, |
| 95 | const char *fmt, ...) | 87 | const char *fmt, ...) |
| 96 | { | 88 | { |
| 89 | struct va_format vaf; | ||
| 97 | va_list args; | 90 | va_list args; |
| 98 | int flen = 0; | 91 | int flen = 0; |
| 99 | 92 | ||
| @@ -103,17 +96,15 @@ void __ntfs_error(const char *function, const struct super_block *sb, | |||
| 103 | #endif | 96 | #endif |
| 104 | if (function) | 97 | if (function) |
| 105 | flen = strlen(function); | 98 | flen = strlen(function); |
| 106 | spin_lock(&err_buf_lock); | ||
| 107 | va_start(args, fmt); | 99 | va_start(args, fmt); |
| 108 | vsnprintf(err_buf, sizeof(err_buf), fmt, args); | 100 | vaf.fmt = fmt; |
| 109 | va_end(args); | 101 | vaf.va = &args; |
| 110 | if (sb) | 102 | if (sb) |
| 111 | printk(KERN_ERR "NTFS-fs error (device %s): %s(): %s\n", | 103 | pr_err("(device %s): %s(): %pV\n", |
| 112 | sb->s_id, flen ? function : "", err_buf); | 104 | sb->s_id, flen ? function : "", &vaf); |
| 113 | else | 105 | else |
| 114 | printk(KERN_ERR "NTFS-fs error: %s(): %s\n", | 106 | pr_err("%s(): %pV\n", flen ? function : "", &vaf); |
| 115 | flen ? function : "", err_buf); | 107 | va_end(args); |
| 116 | spin_unlock(&err_buf_lock); | ||
| 117 | } | 108 | } |
| 118 | 109 | ||
| 119 | #ifdef DEBUG | 110 | #ifdef DEBUG |
| @@ -124,6 +115,7 @@ int debug_msgs = 0; | |||
| 124 | void __ntfs_debug (const char *file, int line, const char *function, | 115 | void __ntfs_debug (const char *file, int line, const char *function, |
| 125 | const char *fmt, ...) | 116 | const char *fmt, ...) |
| 126 | { | 117 | { |
| 118 | struct va_format vaf; | ||
| 127 | va_list args; | 119 | va_list args; |
| 128 | int flen = 0; | 120 | int flen = 0; |
| 129 | 121 | ||
| @@ -131,13 +123,11 @@ void __ntfs_debug (const char *file, int line, const char *function, | |||
| 131 | return; | 123 | return; |
| 132 | if (function) | 124 | if (function) |
| 133 | flen = strlen(function); | 125 | flen = strlen(function); |
| 134 | spin_lock(&err_buf_lock); | ||
| 135 | va_start(args, fmt); | 126 | va_start(args, fmt); |
| 136 | vsnprintf(err_buf, sizeof(err_buf), fmt, args); | 127 | vaf.fmt = fmt; |
| 128 | vaf.va = &args; | ||
| 129 | pr_debug("(%s, %d): %s(): %pV", file, line, flen ? function : "", &vaf); | ||
| 137 | va_end(args); | 130 | va_end(args); |
| 138 | printk(KERN_DEBUG "NTFS-fs DEBUG (%s, %d): %s(): %s\n", file, line, | ||
| 139 | flen ? function : "", err_buf); | ||
| 140 | spin_unlock(&err_buf_lock); | ||
| 141 | } | 131 | } |
| 142 | 132 | ||
| 143 | /* Dump a runlist. Caller has to provide synchronisation for @rl. */ | 133 | /* Dump a runlist. Caller has to provide synchronisation for @rl. */ |
| @@ -149,12 +139,12 @@ void ntfs_debug_dump_runlist(const runlist_element *rl) | |||
| 149 | 139 | ||
| 150 | if (!debug_msgs) | 140 | if (!debug_msgs) |
| 151 | return; | 141 | return; |
| 152 | printk(KERN_DEBUG "NTFS-fs DEBUG: Dumping runlist (values in hex):\n"); | 142 | pr_debug("Dumping runlist (values in hex):\n"); |
| 153 | if (!rl) { | 143 | if (!rl) { |
| 154 | printk(KERN_DEBUG "Run list not present.\n"); | 144 | pr_debug("Run list not present.\n"); |
| 155 | return; | 145 | return; |
| 156 | } | 146 | } |
| 157 | printk(KERN_DEBUG "VCN LCN Run length\n"); | 147 | pr_debug("VCN LCN Run length\n"); |
| 158 | for (i = 0; ; i++) { | 148 | for (i = 0; ; i++) { |
| 159 | LCN lcn = (rl + i)->lcn; | 149 | LCN lcn = (rl + i)->lcn; |
| 160 | 150 | ||
| @@ -163,13 +153,13 @@ void ntfs_debug_dump_runlist(const runlist_element *rl) | |||
| 163 | 153 | ||
| 164 | if (index > -LCN_ENOENT - 1) | 154 | if (index > -LCN_ENOENT - 1) |
| 165 | index = 3; | 155 | index = 3; |
| 166 | printk(KERN_DEBUG "%-16Lx %s %-16Lx%s\n", | 156 | pr_debug("%-16Lx %s %-16Lx%s\n", |
| 167 | (long long)(rl + i)->vcn, lcn_str[index], | 157 | (long long)(rl + i)->vcn, lcn_str[index], |
| 168 | (long long)(rl + i)->length, | 158 | (long long)(rl + i)->length, |
| 169 | (rl + i)->length ? "" : | 159 | (rl + i)->length ? "" : |
| 170 | " (runlist end)"); | 160 | " (runlist end)"); |
| 171 | } else | 161 | } else |
| 172 | printk(KERN_DEBUG "%-16Lx %-16Lx %-16Lx%s\n", | 162 | pr_debug("%-16Lx %-16Lx %-16Lx%s\n", |
| 173 | (long long)(rl + i)->vcn, | 163 | (long long)(rl + i)->vcn, |
| 174 | (long long)(rl + i)->lcn, | 164 | (long long)(rl + i)->lcn, |
| 175 | (long long)(rl + i)->length, | 165 | (long long)(rl + i)->length, |
diff --git a/fs/ntfs/debug.h b/fs/ntfs/debug.h index 53c27eaf2307..61bf091e32a8 100644 --- a/fs/ntfs/debug.h +++ b/fs/ntfs/debug.h | |||
| @@ -48,7 +48,12 @@ extern void ntfs_debug_dump_runlist(const runlist_element *rl); | |||
| 48 | 48 | ||
| 49 | #else /* !DEBUG */ | 49 | #else /* !DEBUG */ |
| 50 | 50 | ||
| 51 | #define ntfs_debug(f, a...) do {} while (0) | 51 | #define ntfs_debug(fmt, ...) \ |
| 52 | do { \ | ||
| 53 | if (0) \ | ||
| 54 | no_printk(fmt, ##__VA_ARGS__); \ | ||
| 55 | } while (0) | ||
| 56 | |||
| 52 | #define ntfs_debug_dump_runlist(rl) do {} while (0) | 57 | #define ntfs_debug_dump_runlist(rl) do {} while (0) |
| 53 | 58 | ||
| 54 | #endif /* !DEBUG */ | 59 | #endif /* !DEBUG */ |
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index bd5610d48242..9de2491f2926 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | * distribution in the file COPYING); if not, write to the Free Software | 19 | * distribution in the file COPYING); if not, write to the Free Software |
| 20 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | */ | 21 | */ |
| 22 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 22 | 23 | ||
| 23 | #include <linux/stddef.h> | 24 | #include <linux/stddef.h> |
| 24 | #include <linux/init.h> | 25 | #include <linux/init.h> |
| @@ -1896,7 +1897,7 @@ get_ctx_vol_failed: | |||
| 1896 | vol->minor_ver = vi->minor_ver; | 1897 | vol->minor_ver = vi->minor_ver; |
| 1897 | ntfs_attr_put_search_ctx(ctx); | 1898 | ntfs_attr_put_search_ctx(ctx); |
| 1898 | unmap_mft_record(NTFS_I(vol->vol_ino)); | 1899 | unmap_mft_record(NTFS_I(vol->vol_ino)); |
| 1899 | printk(KERN_INFO "NTFS volume version %i.%i.\n", vol->major_ver, | 1900 | pr_info("volume version %i.%i.\n", vol->major_ver, |
| 1900 | vol->minor_ver); | 1901 | vol->minor_ver); |
| 1901 | if (vol->major_ver < 3 && NVolSparseEnabled(vol)) { | 1902 | if (vol->major_ver < 3 && NVolSparseEnabled(vol)) { |
| 1902 | ntfs_warning(vol->sb, "Disabling sparse support due to NTFS " | 1903 | ntfs_warning(vol->sb, "Disabling sparse support due to NTFS " |
| @@ -3095,7 +3096,7 @@ static int __init init_ntfs_fs(void) | |||
| 3095 | int err = 0; | 3096 | int err = 0; |
| 3096 | 3097 | ||
| 3097 | /* This may be ugly but it results in pretty output so who cares. (-8 */ | 3098 | /* This may be ugly but it results in pretty output so who cares. (-8 */ |
| 3098 | printk(KERN_INFO "NTFS driver " NTFS_VERSION " [Flags: R/" | 3099 | pr_info("driver " NTFS_VERSION " [Flags: R/" |
| 3099 | #ifdef NTFS_RW | 3100 | #ifdef NTFS_RW |
| 3100 | "W" | 3101 | "W" |
| 3101 | #else | 3102 | #else |
| @@ -3115,16 +3116,15 @@ static int __init init_ntfs_fs(void) | |||
| 3115 | sizeof(ntfs_index_context), 0 /* offset */, | 3116 | sizeof(ntfs_index_context), 0 /* offset */, |
| 3116 | SLAB_HWCACHE_ALIGN, NULL /* ctor */); | 3117 | SLAB_HWCACHE_ALIGN, NULL /* ctor */); |
| 3117 | if (!ntfs_index_ctx_cache) { | 3118 | if (!ntfs_index_ctx_cache) { |
| 3118 | printk(KERN_CRIT "NTFS: Failed to create %s!\n", | 3119 | pr_crit("Failed to create %s!\n", ntfs_index_ctx_cache_name); |
| 3119 | ntfs_index_ctx_cache_name); | ||
| 3120 | goto ictx_err_out; | 3120 | goto ictx_err_out; |
| 3121 | } | 3121 | } |
| 3122 | ntfs_attr_ctx_cache = kmem_cache_create(ntfs_attr_ctx_cache_name, | 3122 | ntfs_attr_ctx_cache = kmem_cache_create(ntfs_attr_ctx_cache_name, |
| 3123 | sizeof(ntfs_attr_search_ctx), 0 /* offset */, | 3123 | sizeof(ntfs_attr_search_ctx), 0 /* offset */, |
| 3124 | SLAB_HWCACHE_ALIGN, NULL /* ctor */); | 3124 | SLAB_HWCACHE_ALIGN, NULL /* ctor */); |
| 3125 | if (!ntfs_attr_ctx_cache) { | 3125 | if (!ntfs_attr_ctx_cache) { |
| 3126 | printk(KERN_CRIT "NTFS: Failed to create %s!\n", | 3126 | pr_crit("NTFS: Failed to create %s!\n", |
| 3127 | ntfs_attr_ctx_cache_name); | 3127 | ntfs_attr_ctx_cache_name); |
| 3128 | goto actx_err_out; | 3128 | goto actx_err_out; |
| 3129 | } | 3129 | } |
| 3130 | 3130 | ||
| @@ -3132,8 +3132,7 @@ static int __init init_ntfs_fs(void) | |||
| 3132 | (NTFS_MAX_NAME_LEN+1) * sizeof(ntfschar), 0, | 3132 | (NTFS_MAX_NAME_LEN+1) * sizeof(ntfschar), 0, |
| 3133 | SLAB_HWCACHE_ALIGN, NULL); | 3133 | SLAB_HWCACHE_ALIGN, NULL); |
| 3134 | if (!ntfs_name_cache) { | 3134 | if (!ntfs_name_cache) { |
| 3135 | printk(KERN_CRIT "NTFS: Failed to create %s!\n", | 3135 | pr_crit("Failed to create %s!\n", ntfs_name_cache_name); |
| 3136 | ntfs_name_cache_name); | ||
| 3137 | goto name_err_out; | 3136 | goto name_err_out; |
| 3138 | } | 3137 | } |
| 3139 | 3138 | ||
| @@ -3141,8 +3140,7 @@ static int __init init_ntfs_fs(void) | |||
| 3141 | sizeof(ntfs_inode), 0, | 3140 | sizeof(ntfs_inode), 0, |
| 3142 | SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL); | 3141 | SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL); |
| 3143 | if (!ntfs_inode_cache) { | 3142 | if (!ntfs_inode_cache) { |
| 3144 | printk(KERN_CRIT "NTFS: Failed to create %s!\n", | 3143 | pr_crit("Failed to create %s!\n", ntfs_inode_cache_name); |
| 3145 | ntfs_inode_cache_name); | ||
| 3146 | goto inode_err_out; | 3144 | goto inode_err_out; |
| 3147 | } | 3145 | } |
| 3148 | 3146 | ||
| @@ -3151,15 +3149,14 @@ static int __init init_ntfs_fs(void) | |||
| 3151 | SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, | 3149 | SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, |
| 3152 | ntfs_big_inode_init_once); | 3150 | ntfs_big_inode_init_once); |
| 3153 | if (!ntfs_big_inode_cache) { | 3151 | if (!ntfs_big_inode_cache) { |
| 3154 | printk(KERN_CRIT "NTFS: Failed to create %s!\n", | 3152 | pr_crit("Failed to create %s!\n", ntfs_big_inode_cache_name); |
| 3155 | ntfs_big_inode_cache_name); | ||
| 3156 | goto big_inode_err_out; | 3153 | goto big_inode_err_out; |
| 3157 | } | 3154 | } |
| 3158 | 3155 | ||
| 3159 | /* Register the ntfs sysctls. */ | 3156 | /* Register the ntfs sysctls. */ |
| 3160 | err = ntfs_sysctl(1); | 3157 | err = ntfs_sysctl(1); |
| 3161 | if (err) { | 3158 | if (err) { |
| 3162 | printk(KERN_CRIT "NTFS: Failed to register NTFS sysctls!\n"); | 3159 | pr_crit("Failed to register NTFS sysctls!\n"); |
| 3163 | goto sysctl_err_out; | 3160 | goto sysctl_err_out; |
| 3164 | } | 3161 | } |
| 3165 | 3162 | ||
| @@ -3168,7 +3165,7 @@ static int __init init_ntfs_fs(void) | |||
| 3168 | ntfs_debug("NTFS driver registered successfully."); | 3165 | ntfs_debug("NTFS driver registered successfully."); |
| 3169 | return 0; /* Success! */ | 3166 | return 0; /* Success! */ |
| 3170 | } | 3167 | } |
| 3171 | printk(KERN_CRIT "NTFS: Failed to register NTFS filesystem driver!\n"); | 3168 | pr_crit("Failed to register NTFS filesystem driver!\n"); |
| 3172 | 3169 | ||
| 3173 | /* Unregister the ntfs sysctls. */ | 3170 | /* Unregister the ntfs sysctls. */ |
| 3174 | ntfs_sysctl(0); | 3171 | ntfs_sysctl(0); |
| @@ -3184,8 +3181,7 @@ actx_err_out: | |||
| 3184 | kmem_cache_destroy(ntfs_index_ctx_cache); | 3181 | kmem_cache_destroy(ntfs_index_ctx_cache); |
| 3185 | ictx_err_out: | 3182 | ictx_err_out: |
| 3186 | if (!err) { | 3183 | if (!err) { |
| 3187 | printk(KERN_CRIT "NTFS: Aborting NTFS filesystem driver " | 3184 | pr_crit("Aborting NTFS filesystem driver registration...\n"); |
| 3188 | "registration...\n"); | ||
| 3189 | err = -ENOMEM; | 3185 | err = -ENOMEM; |
| 3190 | } | 3186 | } |
| 3191 | return err; | 3187 | return err; |
