Commit 08748810 authored by David Sterba's avatar David Sterba Committed by Josef Bacik

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: default avatarDavid Sterba <dsterba@suse.cz>
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
parent bbece8a3
...@@ -340,6 +340,7 @@ static inline unsigned long btrfs_chunk_item_size(int num_stripes) ...@@ -340,6 +340,7 @@ static inline unsigned long btrfs_chunk_item_size(int num_stripes)
*/ */
#define BTRFS_FS_STATE_ERROR 0 #define BTRFS_FS_STATE_ERROR 0
#define BTRFS_FS_STATE_REMOUNTING 1 #define BTRFS_FS_STATE_REMOUNTING 1
#define BTRFS_FS_STATE_TRANS_ABORTED 2
/* Super block flags */ /* Super block flags */
/* Errors detected */ /* Errors detected */
......
...@@ -64,9 +64,9 @@ ...@@ -64,9 +64,9 @@
static const struct super_operations btrfs_super_ops; static const struct super_operations btrfs_super_ops;
static struct file_system_type btrfs_fs_type; static struct file_system_type btrfs_fs_type;
static const char *btrfs_decode_error(int errno, char nbuf[16]) static const char *btrfs_decode_error(int errno)
{ {
char *errstr = NULL; char *errstr = "unknown";
switch (errno) { switch (errno) {
case -EIO: case -EIO:
...@@ -81,12 +81,6 @@ static const char *btrfs_decode_error(int errno, char nbuf[16]) ...@@ -81,12 +81,6 @@ static const char *btrfs_decode_error(int errno, char nbuf[16])
case -EEXIST: case -EEXIST:
errstr = "Object already exists"; errstr = "Object already exists";
break; break;
default:
if (nbuf) {
if (snprintf(nbuf, 16, "error %d", -errno) >= 0)
errstr = nbuf;
}
break;
} }
return errstr; return errstr;
...@@ -122,7 +116,6 @@ static void btrfs_handle_error(struct btrfs_fs_info *fs_info) ...@@ -122,7 +116,6 @@ static void btrfs_handle_error(struct btrfs_fs_info *fs_info)
* mounted writeable again, the device replace * mounted writeable again, the device replace
* operation continues. * operation continues.
*/ */
// WARN_ON(1);
} }
} }
...@@ -135,7 +128,6 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, ...@@ -135,7 +128,6 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
unsigned int line, int errno, const char *fmt, ...) unsigned int line, int errno, const char *fmt, ...)
{ {
struct super_block *sb = fs_info->sb; struct super_block *sb = fs_info->sb;
char nbuf[16];
const char *errstr; const char *errstr;
/* /*
...@@ -145,7 +137,7 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, ...@@ -145,7 +137,7 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
if (errno == -EROFS && (sb->s_flags & MS_RDONLY)) if (errno == -EROFS && (sb->s_flags & MS_RDONLY))
return; return;
errstr = btrfs_decode_error(errno, nbuf); errstr = btrfs_decode_error(errno);
if (fmt) { if (fmt) {
struct va_format vaf; struct va_format vaf;
va_list args; va_list args;
...@@ -154,12 +146,12 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, ...@@ -154,12 +146,12 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
vaf.fmt = fmt; vaf.fmt = fmt;
vaf.va = &args; vaf.va = &args;
printk(KERN_CRIT "BTRFS error (device %s) in %s:%d: %s (%pV)\n", printk(KERN_CRIT "BTRFS error (device %s) in %s:%d: errno=%d %s (%pV)\n",
sb->s_id, function, line, errstr, &vaf); sb->s_id, function, line, errno, errstr, &vaf);
va_end(args); va_end(args);
} else { } else {
printk(KERN_CRIT "BTRFS error (device %s) in %s:%d: %s\n", printk(KERN_CRIT "BTRFS error (device %s) in %s:%d: errno=%d %s\n",
sb->s_id, function, line, errstr); sb->s_id, function, line, errno, errstr);
} }
/* Don't go through full error handling during mount */ /* Don't go through full error handling during mount */
...@@ -248,17 +240,23 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans, ...@@ -248,17 +240,23 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
struct btrfs_root *root, const char *function, struct btrfs_root *root, const char *function,
unsigned int line, int errno) unsigned int line, int errno)
{ {
WARN_ONCE(1, KERN_DEBUG "btrfs: Transaction aborted\n"); /*
* Report first abort since mount
*/
if (!test_and_set_bit(BTRFS_FS_STATE_TRANS_ABORTED,
&root->fs_info->fs_state)) {
WARN(1, KERN_DEBUG "btrfs: Transaction aborted (error %d)\n",
errno);
}
trans->aborted = errno; trans->aborted = errno;
/* Nothing used. The other threads that have joined this /* Nothing used. The other threads that have joined this
* transaction may be able to continue. */ * transaction may be able to continue. */
if (!trans->blocks_used) { if (!trans->blocks_used) {
char nbuf[16];
const char *errstr; const char *errstr;
errstr = btrfs_decode_error(errno, nbuf); errstr = btrfs_decode_error(errno);
btrfs_printk(root->fs_info, btrfs_printk(root->fs_info,
"%s:%d: Aborting unused transaction(%s).\n", "%s:%d: Aborting unused transaction (%s)\n",
function, line, errstr); function, line, errstr);
return; return;
} }
...@@ -272,7 +270,6 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans, ...@@ -272,7 +270,6 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function, void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
unsigned int line, int errno, const char *fmt, ...) unsigned int line, int errno, const char *fmt, ...)
{ {
char nbuf[16];
char *s_id = "<unknown>"; char *s_id = "<unknown>";
const char *errstr; const char *errstr;
struct va_format vaf = { .fmt = fmt }; struct va_format vaf = { .fmt = fmt };
...@@ -284,13 +281,13 @@ void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function, ...@@ -284,13 +281,13 @@ void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
va_start(args, fmt); va_start(args, fmt);
vaf.va = &args; vaf.va = &args;
errstr = btrfs_decode_error(errno, nbuf); errstr = btrfs_decode_error(errno);
if (fs_info && (fs_info->mount_opt & BTRFS_MOUNT_PANIC_ON_FATAL_ERROR)) if (fs_info && (fs_info->mount_opt & BTRFS_MOUNT_PANIC_ON_FATAL_ERROR))
panic(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (%s)\n", panic(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (errno=%d %s)\n",
s_id, function, line, &vaf, errstr); s_id, function, line, &vaf, errno, errstr);
printk(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (%s)\n", printk(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (errno=%d %s)\n",
s_id, function, line, &vaf, errstr); s_id, function, line, &vaf, errno, errstr);
va_end(args); va_end(args);
/* Caller calls BUG() */ /* Caller calls BUG() */
} }
......
...@@ -1808,7 +1808,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -1808,7 +1808,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
ret = btrfs_write_and_wait_transaction(trans, root); ret = btrfs_write_and_wait_transaction(trans, root);
if (ret) { if (ret) {
btrfs_error(root->fs_info, ret, btrfs_error(root->fs_info, ret,
"Error while writing out transaction."); "Error while writing out transaction");
mutex_unlock(&root->fs_info->tree_log_mutex); mutex_unlock(&root->fs_info->tree_log_mutex);
goto cleanup_transaction; goto cleanup_transaction;
} }
...@@ -1864,8 +1864,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -1864,8 +1864,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
btrfs_qgroup_free(root, trans->qgroup_reserved); btrfs_qgroup_free(root, trans->qgroup_reserved);
trans->qgroup_reserved = 0; trans->qgroup_reserved = 0;
} }
btrfs_printk(root->fs_info, "Skipping commit of aborted transaction.\n"); btrfs_printk(root->fs_info, "Skipping commit of aborted transaction\n");
// WARN_ON(1);
if (current->journal_info == trans) if (current->journal_info == trans)
current->journal_info = NULL; current->journal_info = NULL;
cleanup_transaction(trans, root, ret); cleanup_transaction(trans, root, ret);
......
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