6464static const struct super_operations btrfs_super_ops ;
6565static struct file_system_type btrfs_fs_type ;
6666
67- static const char * btrfs_decode_error (int errno , char nbuf [ 16 ] )
67+ static const char * btrfs_decode_error (int errno )
6868{
69- char * errstr = NULL ;
69+ char * errstr = "unknown" ;
7070
7171 switch (errno ) {
7272 case - EIO :
@@ -81,12 +81,6 @@ static const char *btrfs_decode_error(int errno, char nbuf[16])
8181 case - EEXIST :
8282 errstr = "Object already exists" ;
8383 break ;
84- default :
85- if (nbuf ) {
86- if (snprintf (nbuf , 16 , "error %d" , - errno ) >= 0 )
87- errstr = nbuf ;
88- }
89- break ;
9084 }
9185
9286 return errstr ;
@@ -122,7 +116,6 @@ static void btrfs_handle_error(struct btrfs_fs_info *fs_info)
122116 * mounted writeable again, the device replace
123117 * operation continues.
124118 */
125- // WARN_ON(1);
126119 }
127120}
128121
@@ -135,7 +128,6 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
135128 unsigned int line , int errno , const char * fmt , ...)
136129{
137130 struct super_block * sb = fs_info -> sb ;
138- char nbuf [16 ];
139131 const char * errstr ;
140132
141133 /*
@@ -145,7 +137,7 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
145137 if (errno == - EROFS && (sb -> s_flags & MS_RDONLY ))
146138 return ;
147139
148- errstr = btrfs_decode_error (errno , nbuf );
140+ errstr = btrfs_decode_error (errno );
149141 if (fmt ) {
150142 struct va_format vaf ;
151143 va_list args ;
@@ -154,12 +146,12 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
154146 vaf .fmt = fmt ;
155147 vaf .va = & args ;
156148
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 );
159151 va_end (args );
160152 } 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 );
163155 }
164156
165157 /* Don't go through full error handling during mount */
@@ -248,17 +240,23 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
248240 struct btrfs_root * root , const char * function ,
249241 unsigned int line , int errno )
250242{
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+ }
252251 trans -> aborted = errno ;
253252 /* Nothing used. The other threads that have joined this
254253 * transaction may be able to continue. */
255254 if (!trans -> blocks_used ) {
256- char nbuf [16 ];
257255 const char * errstr ;
258256
259- errstr = btrfs_decode_error (errno , nbuf );
257+ errstr = btrfs_decode_error (errno );
260258 btrfs_printk (root -> fs_info ,
261- "%s:%d: Aborting unused transaction(%s). \n" ,
259+ "%s:%d: Aborting unused transaction (%s)\n" ,
262260 function , line , errstr );
263261 return ;
264262 }
@@ -272,7 +270,6 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
272270void __btrfs_panic (struct btrfs_fs_info * fs_info , const char * function ,
273271 unsigned int line , int errno , const char * fmt , ...)
274272{
275- char nbuf [16 ];
276273 char * s_id = "<unknown>" ;
277274 const char * errstr ;
278275 struct va_format vaf = { .fmt = fmt };
@@ -284,13 +281,13 @@ void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
284281 va_start (args , fmt );
285282 vaf .va = & args ;
286283
287- errstr = btrfs_decode_error (errno , nbuf );
284+ errstr = btrfs_decode_error (errno );
288285 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 );
291288
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 );
294291 va_end (args );
295292 /* Caller calls BUG() */
296293}
0 commit comments