64
64
static const struct super_operations btrfs_super_ops ;
65
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
71
switch (errno ) {
72
72
case - EIO :
@@ -81,12 +81,6 @@ static const char *btrfs_decode_error(int errno, char nbuf[16])
81
81
case - EEXIST :
82
82
errstr = "Object already exists" ;
83
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
86
return errstr ;
@@ -122,7 +116,6 @@ static void btrfs_handle_error(struct btrfs_fs_info *fs_info)
122
116
* mounted writeable again, the device replace
123
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
128
unsigned int line , int errno , const char * fmt , ...)
136
129
{
137
130
struct super_block * sb = fs_info -> sb ;
138
- char nbuf [16 ];
139
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
137
if (errno == - EROFS && (sb -> s_flags & MS_RDONLY ))
146
138
return ;
147
139
148
- errstr = btrfs_decode_error (errno , nbuf );
140
+ errstr = btrfs_decode_error (errno );
149
141
if (fmt ) {
150
142
struct va_format vaf ;
151
143
va_list args ;
@@ -154,12 +146,12 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
154
146
vaf .fmt = fmt ;
155
147
vaf .va = & args ;
156
148
157
- printk (KERN_CRIT "BTRFS error (device %s) in %s:%d: %s (%pV)\n" ,
158
- sb -> s_id , function , line , errstr , & vaf );
149
+ printk (KERN_CRIT "BTRFS error (device %s) in %s:%d: errno=%d %s (%pV)\n" ,
150
+ sb -> s_id , function , line , errno , errstr , & vaf );
159
151
va_end (args );
160
152
} else {
161
- printk (KERN_CRIT "BTRFS error (device %s) in %s:%d: %s\n" ,
162
- sb -> s_id , function , line , errstr );
153
+ printk (KERN_CRIT "BTRFS error (device %s) in %s:%d: errno=%d %s\n" ,
154
+ sb -> s_id , function , line , errno , errstr );
163
155
}
164
156
165
157
/* Don't go through full error handling during mount */
@@ -248,17 +240,23 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
248
240
struct btrfs_root * root , const char * function ,
249
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
251
trans -> aborted = errno ;
253
252
/* Nothing used. The other threads that have joined this
254
253
* transaction may be able to continue. */
255
254
if (!trans -> blocks_used ) {
256
- char nbuf [16 ];
257
255
const char * errstr ;
258
256
259
- errstr = btrfs_decode_error (errno , nbuf );
257
+ errstr = btrfs_decode_error (errno );
260
258
btrfs_printk (root -> fs_info ,
261
- "%s:%d: Aborting unused transaction(%s). \n" ,
259
+ "%s:%d: Aborting unused transaction (%s)\n" ,
262
260
function , line , errstr );
263
261
return ;
264
262
}
@@ -272,7 +270,6 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
272
270
void __btrfs_panic (struct btrfs_fs_info * fs_info , const char * function ,
273
271
unsigned int line , int errno , const char * fmt , ...)
274
272
{
275
- char nbuf [16 ];
276
273
char * s_id = "<unknown>" ;
277
274
const char * errstr ;
278
275
struct va_format vaf = { .fmt = fmt };
@@ -284,13 +281,13 @@ void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
284
281
va_start (args , fmt );
285
282
vaf .va = & args ;
286
283
287
- errstr = btrfs_decode_error (errno , nbuf );
284
+ errstr = btrfs_decode_error (errno );
288
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" ,
290
- s_id , function , line , & vaf , errstr );
286
+ panic (KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (errno=%d %s)\n" ,
287
+ s_id , function , line , & vaf , errno , errstr );
291
288
292
- printk (KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (%s)\n" ,
293
- s_id , function , line , & vaf , errstr );
289
+ printk (KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (errno=%d %s)\n" ,
290
+ s_id , function , line , & vaf , errno , errstr );
294
291
va_end (args );
295
292
/* Caller calls BUG() */
296
293
}
0 commit comments