diff options
author | David Sterba <dsterba@suse.cz> | 2013-03-12 10:46:08 -0400 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-05-06 15:52:56 -0400 |
commit | 087488109afb4cc1bbdd3557779129c34045609a (patch) | |
tree | 7e5ef3a85226ac66261cbe2642c71151bb8f61b3 /fs/btrfs/super.c | |
parent | bbece8a3f00a02bbfc63531651fd70ef56c5e916 (diff) |
btrfs: clean up transaction abort messages
The transaction abort stacktrace is printed only once per module
lifetime, but we'd like to see it each time it happens per mounted
filesystem. Introduce a fs_state flag that records it.
Tweak the messages around abort:
* add error number to the first abort
* print the exact negative errno from btrfs_decode_error
* clean up btrfs_decode_error and callers
* no dots at the end of the messages
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r-- | fs/btrfs/super.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 8168ceca4754..7f00a91ccc10 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -64,9 +64,9 @@ | |||
64 | static const struct super_operations btrfs_super_ops; | 64 | static const struct super_operations btrfs_super_ops; |
65 | static struct file_system_type btrfs_fs_type; | 65 | static struct file_system_type btrfs_fs_type; |
66 | 66 | ||
67 | static const char *btrfs_decode_error(int errno, char nbuf[16]) | 67 | static const char *btrfs_decode_error(int errno) |
68 | { | 68 | { |
69 | char *errstr = NULL; | 69 | char *errstr = "unknown"; |
70 | 70 | ||
71 | switch (errno) { | 71 | switch (errno) { |
72 | case -EIO: | 72 | case -EIO: |
@@ -81,12 +81,6 @@ static const char *btrfs_decode_error(int errno, char nbuf[16]) | |||
81 | case -EEXIST: | 81 | case -EEXIST: |
82 | errstr = "Object already exists"; | 82 | errstr = "Object already exists"; |
83 | break; | 83 | break; |
84 | default: | ||
85 | if (nbuf) { | ||
86 | if (snprintf(nbuf, 16, "error %d", -errno) >= 0) | ||
87 | errstr = nbuf; | ||
88 | } | ||
89 | break; | ||
90 | } | 84 | } |
91 | 85 | ||
92 | return errstr; | 86 | return errstr; |
@@ -122,7 +116,6 @@ static void btrfs_handle_error(struct btrfs_fs_info *fs_info) | |||
122 | * mounted writeable again, the device replace | 116 | * mounted writeable again, the device replace |
123 | * operation continues. | 117 | * operation continues. |
124 | */ | 118 | */ |
125 | // WARN_ON(1); | ||
126 | } | 119 | } |
127 | } | 120 | } |
128 | 121 | ||
@@ -135,7 +128,6 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, | |||
135 | unsigned int line, int errno, const char *fmt, ...) | 128 | unsigned int line, int errno, const char *fmt, ...) |
136 | { | 129 | { |
137 | struct super_block *sb = fs_info->sb; | 130 | struct super_block *sb = fs_info->sb; |
138 | char nbuf[16]; | ||
139 | const char *errstr; | 131 | const char *errstr; |
140 | 132 | ||
141 | /* | 133 | /* |
@@ -145,7 +137,7 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, | |||
145 | if (errno == -EROFS && (sb->s_flags & MS_RDONLY)) | 137 | if (errno == -EROFS && (sb->s_flags & MS_RDONLY)) |
146 | return; | 138 | return; |
147 | 139 | ||
148 | errstr = btrfs_decode_error(errno, nbuf); | 140 | errstr = btrfs_decode_error(errno); |
149 | if (fmt) { | 141 | if (fmt) { |
150 | struct va_format vaf; | 142 | struct va_format vaf; |
151 | va_list args; | 143 | va_list args; |
@@ -154,12 +146,12 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, | |||
154 | vaf.fmt = fmt; | 146 | vaf.fmt = fmt; |
155 | vaf.va = &args; | 147 | vaf.va = &args; |
156 | 148 | ||
157 | printk(KERN_CRIT "BTRFS error (device %s) in %s:%d: %s (%pV)\n", | 149 | printk(KERN_CRIT "BTRFS error (device %s) in %s:%d: errno=%d %s (%pV)\n", |
158 | sb->s_id, function, line, errstr, &vaf); | 150 | sb->s_id, function, line, errno, errstr, &vaf); |
159 | va_end(args); | 151 | va_end(args); |
160 | } else { | 152 | } else { |
161 | printk(KERN_CRIT "BTRFS error (device %s) in %s:%d: %s\n", | 153 | printk(KERN_CRIT "BTRFS error (device %s) in %s:%d: errno=%d %s\n", |
162 | sb->s_id, function, line, errstr); | 154 | sb->s_id, function, line, errno, errstr); |
163 | } | 155 | } |
164 | 156 | ||
165 | /* Don't go through full error handling during mount */ | 157 | /* Don't go through full error handling during mount */ |
@@ -248,17 +240,23 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans, | |||
248 | struct btrfs_root *root, const char *function, | 240 | struct btrfs_root *root, const char *function, |
249 | unsigned int line, int errno) | 241 | unsigned int line, int errno) |
250 | { | 242 | { |
251 | WARN_ONCE(1, KERN_DEBUG "btrfs: Transaction aborted\n"); | 243 | /* |
244 | * Report first abort since mount | ||
245 | */ | ||
246 | if (!test_and_set_bit(BTRFS_FS_STATE_TRANS_ABORTED, | ||
247 | &root->fs_info->fs_state)) { | ||
248 | WARN(1, KERN_DEBUG "btrfs: Transaction aborted (error %d)\n", | ||
249 | errno); | ||
250 | } | ||
252 | trans->aborted = errno; | 251 | trans->aborted = errno; |
253 | /* Nothing used. The other threads that have joined this | 252 | /* Nothing used. The other threads that have joined this |
254 | * transaction may be able to continue. */ | 253 | * transaction may be able to continue. */ |
255 | if (!trans->blocks_used) { | 254 | if (!trans->blocks_used) { |
256 | char nbuf[16]; | ||
257 | const char *errstr; | 255 | const char *errstr; |
258 | 256 | ||
259 | errstr = btrfs_decode_error(errno, nbuf); | 257 | errstr = btrfs_decode_error(errno); |
260 | btrfs_printk(root->fs_info, | 258 | btrfs_printk(root->fs_info, |
261 | "%s:%d: Aborting unused transaction(%s).\n", | 259 | "%s:%d: Aborting unused transaction (%s)\n", |
262 | function, line, errstr); | 260 | function, line, errstr); |
263 | return; | 261 | return; |
264 | } | 262 | } |
@@ -272,7 +270,6 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans, | |||
272 | void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function, | 270 | void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function, |
273 | unsigned int line, int errno, const char *fmt, ...) | 271 | unsigned int line, int errno, const char *fmt, ...) |
274 | { | 272 | { |
275 | char nbuf[16]; | ||
276 | char *s_id = "<unknown>"; | 273 | char *s_id = "<unknown>"; |
277 | const char *errstr; | 274 | const char *errstr; |
278 | struct va_format vaf = { .fmt = fmt }; | 275 | struct va_format vaf = { .fmt = fmt }; |
@@ -284,13 +281,13 @@ void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function, | |||
284 | va_start(args, fmt); | 281 | va_start(args, fmt); |
285 | vaf.va = &args; | 282 | vaf.va = &args; |
286 | 283 | ||
287 | errstr = btrfs_decode_error(errno, nbuf); | 284 | errstr = btrfs_decode_error(errno); |
288 | if (fs_info && (fs_info->mount_opt & BTRFS_MOUNT_PANIC_ON_FATAL_ERROR)) | 285 | if (fs_info && (fs_info->mount_opt & BTRFS_MOUNT_PANIC_ON_FATAL_ERROR)) |
289 | panic(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (%s)\n", | 286 | panic(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (errno=%d %s)\n", |
290 | s_id, function, line, &vaf, errstr); | 287 | s_id, function, line, &vaf, errno, errstr); |
291 | 288 | ||
292 | printk(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (%s)\n", | 289 | printk(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (errno=%d %s)\n", |
293 | s_id, function, line, &vaf, errstr); | 290 | s_id, function, line, &vaf, errno, errstr); |
294 | va_end(args); | 291 | va_end(args); |
295 | /* Caller calls BUG() */ | 292 | /* Caller calls BUG() */ |
296 | } | 293 | } |