aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/prints.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/reiserfs/prints.c')
-rw-r--r--fs/reiserfs/prints.c134
1 files changed, 79 insertions, 55 deletions
diff --git a/fs/reiserfs/prints.c b/fs/reiserfs/prints.c
index 740bb8c0c1a..536eacaeb71 100644
--- a/fs/reiserfs/prints.c
+++ b/fs/reiserfs/prints.c
@@ -157,19 +157,16 @@ static void sprintf_disk_child(char *buf, struct disk_child *dc)
157 dc_size(dc)); 157 dc_size(dc));
158} 158}
159 159
160static char *is_there_reiserfs_struct(char *fmt, int *what, int *skip) 160static char *is_there_reiserfs_struct(char *fmt, int *what)
161{ 161{
162 char *k = fmt; 162 char *k = fmt;
163 163
164 *skip = 0;
165
166 while ((k = strchr(k, '%')) != NULL) { 164 while ((k = strchr(k, '%')) != NULL) {
167 if (k[1] == 'k' || k[1] == 'K' || k[1] == 'h' || k[1] == 't' || 165 if (k[1] == 'k' || k[1] == 'K' || k[1] == 'h' || k[1] == 't' ||
168 k[1] == 'z' || k[1] == 'b' || k[1] == 'y' || k[1] == 'a') { 166 k[1] == 'z' || k[1] == 'b' || k[1] == 'y' || k[1] == 'a') {
169 *what = k[1]; 167 *what = k[1];
170 break; 168 break;
171 } 169 }
172 (*skip)++;
173 k++; 170 k++;
174 } 171 }
175 return k; 172 return k;
@@ -181,30 +178,29 @@ static char *is_there_reiserfs_struct(char *fmt, int *what, int *skip)
181 appropriative printk. With this reiserfs_warning you can use format 178 appropriative printk. With this reiserfs_warning you can use format
182 specification for complex structures like you used to do with 179 specification for complex structures like you used to do with
183 printfs for integers, doubles and pointers. For instance, to print 180 printfs for integers, doubles and pointers. For instance, to print
184 out key structure you have to write just: 181 out key structure you have to write just:
185 reiserfs_warning ("bad key %k", key); 182 reiserfs_warning ("bad key %k", key);
186 instead of 183 instead of
187 printk ("bad key %lu %lu %lu %lu", key->k_dir_id, key->k_objectid, 184 printk ("bad key %lu %lu %lu %lu", key->k_dir_id, key->k_objectid,
188 key->k_offset, key->k_uniqueness); 185 key->k_offset, key->k_uniqueness);
189*/ 186*/
190 187static DEFINE_SPINLOCK(error_lock);
191static void prepare_error_buf(const char *fmt, va_list args) 188static void prepare_error_buf(const char *fmt, va_list args)
192{ 189{
193 char *fmt1 = fmt_buf; 190 char *fmt1 = fmt_buf;
194 char *k; 191 char *k;
195 char *p = error_buf; 192 char *p = error_buf;
196 int i, j, what, skip; 193 int what;
194
195 spin_lock(&error_lock);
197 196
198 strcpy(fmt1, fmt); 197 strcpy(fmt1, fmt);
199 198
200 while ((k = is_there_reiserfs_struct(fmt1, &what, &skip)) != NULL) { 199 while ((k = is_there_reiserfs_struct(fmt1, &what)) != NULL) {
201 *k = 0; 200 *k = 0;
202 201
203 p += vsprintf(p, fmt1, args); 202 p += vsprintf(p, fmt1, args);
204 203
205 for (i = 0; i < skip; i++)
206 j = va_arg(args, int);
207
208 switch (what) { 204 switch (what) {
209 case 'k': 205 case 'k':
210 sprintf_le_key(p, va_arg(args, struct reiserfs_key *)); 206 sprintf_le_key(p, va_arg(args, struct reiserfs_key *));
@@ -243,15 +239,16 @@ static void prepare_error_buf(const char *fmt, va_list args)
243 fmt1 = k + 2; 239 fmt1 = k + 2;
244 } 240 }
245 vsprintf(p, fmt1, args); 241 vsprintf(p, fmt1, args);
242 spin_unlock(&error_lock);
246 243
247} 244}
248 245
249/* in addition to usual conversion specifiers this accepts reiserfs 246/* in addition to usual conversion specifiers this accepts reiserfs
250 specific conversion specifiers: 247 specific conversion specifiers:
251 %k to print little endian key, 248 %k to print little endian key,
252 %K to print cpu key, 249 %K to print cpu key,
253 %h to print item_head, 250 %h to print item_head,
254 %t to print directory entry 251 %t to print directory entry
255 %z to print block head (arg must be struct buffer_head * 252 %z to print block head (arg must be struct buffer_head *
256 %b to print buffer_head 253 %b to print buffer_head
257*/ 254*/
@@ -264,14 +261,17 @@ static void prepare_error_buf(const char *fmt, va_list args)
264 va_end( args );\ 261 va_end( args );\
265} 262}
266 263
267void reiserfs_warning(struct super_block *sb, const char *fmt, ...) 264void __reiserfs_warning(struct super_block *sb, const char *id,
265 const char *function, const char *fmt, ...)
268{ 266{
269 do_reiserfs_warning(fmt); 267 do_reiserfs_warning(fmt);
270 if (sb) 268 if (sb)
271 printk(KERN_WARNING "ReiserFS: %s: warning: %s\n", 269 printk(KERN_WARNING "REISERFS warning (device %s): %s%s%s: "
272 reiserfs_bdevname(sb), error_buf); 270 "%s\n", sb->s_id, id ? id : "", id ? " " : "",
271 function, error_buf);
273 else 272 else
274 printk(KERN_WARNING "ReiserFS: warning: %s\n", error_buf); 273 printk(KERN_WARNING "REISERFS warning: %s%s%s: %s\n",
274 id ? id : "", id ? " " : "", function, error_buf);
275} 275}
276 276
277/* No newline.. reiserfs_info calls can be followed by printk's */ 277/* No newline.. reiserfs_info calls can be followed by printk's */
@@ -279,10 +279,10 @@ void reiserfs_info(struct super_block *sb, const char *fmt, ...)
279{ 279{
280 do_reiserfs_warning(fmt); 280 do_reiserfs_warning(fmt);
281 if (sb) 281 if (sb)
282 printk(KERN_NOTICE "ReiserFS: %s: %s", 282 printk(KERN_NOTICE "REISERFS (device %s): %s",
283 reiserfs_bdevname(sb), error_buf); 283 sb->s_id, error_buf);
284 else 284 else
285 printk(KERN_NOTICE "ReiserFS: %s", error_buf); 285 printk(KERN_NOTICE "REISERFS %s:", error_buf);
286} 286}
287 287
288/* No newline.. reiserfs_printk calls can be followed by printk's */ 288/* No newline.. reiserfs_printk calls can be followed by printk's */
@@ -297,10 +297,10 @@ void reiserfs_debug(struct super_block *s, int level, const char *fmt, ...)
297#ifdef CONFIG_REISERFS_CHECK 297#ifdef CONFIG_REISERFS_CHECK
298 do_reiserfs_warning(fmt); 298 do_reiserfs_warning(fmt);
299 if (s) 299 if (s)
300 printk(KERN_DEBUG "ReiserFS: %s: %s\n", 300 printk(KERN_DEBUG "REISERFS debug (device %s): %s\n",
301 reiserfs_bdevname(s), error_buf); 301 s->s_id, error_buf);
302 else 302 else
303 printk(KERN_DEBUG "ReiserFS: %s\n", error_buf); 303 printk(KERN_DEBUG "REISERFS debug: %s\n", error_buf);
304#endif 304#endif
305} 305}
306 306
@@ -314,17 +314,17 @@ void reiserfs_debug(struct super_block *s, int level, const char *fmt, ...)
314 maintainer-errorid. Don't bother with reusing errorids, there are 314 maintainer-errorid. Don't bother with reusing errorids, there are
315 lots of numbers out there. 315 lots of numbers out there.
316 316
317 Example: 317 Example:
318 318
319 reiserfs_panic( 319 reiserfs_panic(
320 p_sb, "reiser-29: reiserfs_new_blocknrs: " 320 p_sb, "reiser-29: reiserfs_new_blocknrs: "
321 "one of search_start or rn(%d) is equal to MAX_B_NUM," 321 "one of search_start or rn(%d) is equal to MAX_B_NUM,"
322 "which means that we are optimizing location based on the bogus location of a temp buffer (%p).", 322 "which means that we are optimizing location based on the bogus location of a temp buffer (%p).",
323 rn, bh 323 rn, bh
324 ); 324 );
325 325
326 Regular panic()s sometimes clear the screen before the message can 326 Regular panic()s sometimes clear the screen before the message can
327 be read, thus the need for the while loop. 327 be read, thus the need for the while loop.
328 328
329 Numbering scheme for panic used by Vladimir and Anatoly( Hans completely ignores this scheme, and considers it 329 Numbering scheme for panic used by Vladimir and Anatoly( Hans completely ignores this scheme, and considers it
330 pointless complexity): 330 pointless complexity):
@@ -353,14 +353,46 @@ void reiserfs_debug(struct super_block *s, int level, const char *fmt, ...)
353extern struct tree_balance *cur_tb; 353extern struct tree_balance *cur_tb;
354#endif 354#endif
355 355
356void reiserfs_panic(struct super_block *sb, const char *fmt, ...) 356void __reiserfs_panic(struct super_block *sb, const char *id,
357 const char *function, const char *fmt, ...)
357{ 358{
358 do_reiserfs_warning(fmt); 359 do_reiserfs_warning(fmt);
359 360
361#ifdef CONFIG_REISERFS_CHECK
360 dump_stack(); 362 dump_stack();
363#endif
364 if (sb)
365 panic(KERN_WARNING "REISERFS panic (device %s): %s%s%s: %s\n",
366 sb->s_id, id ? id : "", id ? " " : "",
367 function, error_buf);
368 else
369 panic(KERN_WARNING "REISERFS panic: %s%s%s: %s\n",
370 id ? id : "", id ? " " : "", function, error_buf);
371}
372
373void __reiserfs_error(struct super_block *sb, const char *id,
374 const char *function, const char *fmt, ...)
375{
376 do_reiserfs_warning(fmt);
361 377
362 panic(KERN_EMERG "REISERFS: panic (device %s): %s\n", 378 BUG_ON(sb == NULL);
363 reiserfs_bdevname(sb), error_buf); 379
380 if (reiserfs_error_panic(sb))
381 __reiserfs_panic(sb, id, function, error_buf);
382
383 if (id && id[0])
384 printk(KERN_CRIT "REISERFS error (device %s): %s %s: %s\n",
385 sb->s_id, id, function, error_buf);
386 else
387 printk(KERN_CRIT "REISERFS error (device %s): %s: %s\n",
388 sb->s_id, function, error_buf);
389
390 if (sb->s_flags & MS_RDONLY)
391 return;
392
393 reiserfs_info(sb, "Remounting filesystem read-only\n");
394 sb->s_flags |= MS_RDONLY;
395 reiserfs_abort_journal(sb, -EIO);
364} 396}
365 397
366void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...) 398void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...)
@@ -368,18 +400,18 @@ void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...)
368 do_reiserfs_warning(fmt); 400 do_reiserfs_warning(fmt);
369 401
370 if (reiserfs_error_panic(sb)) { 402 if (reiserfs_error_panic(sb)) {
371 panic(KERN_CRIT "REISERFS: panic (device %s): %s\n", 403 panic(KERN_CRIT "REISERFS panic (device %s): %s\n", sb->s_id,
372 reiserfs_bdevname(sb), error_buf); 404 error_buf);
373 } 405 }
374 406
375 if (sb->s_flags & MS_RDONLY) 407 if (reiserfs_is_journal_aborted(SB_JOURNAL(sb)))
376 return; 408 return;
377 409
378 printk(KERN_CRIT "REISERFS: abort (device %s): %s\n", 410 printk(KERN_CRIT "REISERFS abort (device %s): %s\n", sb->s_id,
379 reiserfs_bdevname(sb), error_buf); 411 error_buf);
380 412
381 sb->s_flags |= MS_RDONLY; 413 sb->s_flags |= MS_RDONLY;
382 reiserfs_journal_abort(sb, errno); 414 reiserfs_abort_journal(sb, errno);
383} 415}
384 416
385/* this prints internal nodes (4 keys/items in line) (dc_number, 417/* this prints internal nodes (4 keys/items in line) (dc_number,
@@ -681,12 +713,10 @@ static void check_leaf_block_head(struct buffer_head *bh)
681 blkh = B_BLK_HEAD(bh); 713 blkh = B_BLK_HEAD(bh);
682 nr = blkh_nr_item(blkh); 714 nr = blkh_nr_item(blkh);
683 if (nr > (bh->b_size - BLKH_SIZE) / IH_SIZE) 715 if (nr > (bh->b_size - BLKH_SIZE) / IH_SIZE)
684 reiserfs_panic(NULL, 716 reiserfs_panic(NULL, "vs-6010", "invalid item number %z",
685 "vs-6010: check_leaf_block_head: invalid item number %z",
686 bh); 717 bh);
687 if (blkh_free_space(blkh) > bh->b_size - BLKH_SIZE - IH_SIZE * nr) 718 if (blkh_free_space(blkh) > bh->b_size - BLKH_SIZE - IH_SIZE * nr)
688 reiserfs_panic(NULL, 719 reiserfs_panic(NULL, "vs-6020", "invalid free space %z",
689 "vs-6020: check_leaf_block_head: invalid free space %z",
690 bh); 720 bh);
691 721
692} 722}
@@ -697,21 +727,15 @@ static void check_internal_block_head(struct buffer_head *bh)
697 727
698 blkh = B_BLK_HEAD(bh); 728 blkh = B_BLK_HEAD(bh);
699 if (!(B_LEVEL(bh) > DISK_LEAF_NODE_LEVEL && B_LEVEL(bh) <= MAX_HEIGHT)) 729 if (!(B_LEVEL(bh) > DISK_LEAF_NODE_LEVEL && B_LEVEL(bh) <= MAX_HEIGHT))
700 reiserfs_panic(NULL, 730 reiserfs_panic(NULL, "vs-6025", "invalid level %z", bh);
701 "vs-6025: check_internal_block_head: invalid level %z",
702 bh);
703 731
704 if (B_NR_ITEMS(bh) > (bh->b_size - BLKH_SIZE) / IH_SIZE) 732 if (B_NR_ITEMS(bh) > (bh->b_size - BLKH_SIZE) / IH_SIZE)
705 reiserfs_panic(NULL, 733 reiserfs_panic(NULL, "vs-6030", "invalid item number %z", bh);
706 "vs-6030: check_internal_block_head: invalid item number %z",
707 bh);
708 734
709 if (B_FREE_SPACE(bh) != 735 if (B_FREE_SPACE(bh) !=
710 bh->b_size - BLKH_SIZE - KEY_SIZE * B_NR_ITEMS(bh) - 736 bh->b_size - BLKH_SIZE - KEY_SIZE * B_NR_ITEMS(bh) -
711 DC_SIZE * (B_NR_ITEMS(bh) + 1)) 737 DC_SIZE * (B_NR_ITEMS(bh) + 1))
712 reiserfs_panic(NULL, 738 reiserfs_panic(NULL, "vs-6040", "invalid free space %z", bh);
713 "vs-6040: check_internal_block_head: invalid free space %z",
714 bh);
715 739
716} 740}
717 741