5 #include <linux/time.h>
8 #include <linux/string.h>
13 static char error_buf[1024];
14 static char fmt_buf[1024];
15 static char off_buf[80];
17 static char *reiserfs_cpu_offset(
struct cpu_key *
key)
27 (
unsigned long long)cpu_key_k_offset(key));
35 version = le_key_version(key);
44 (
unsigned long long)le_key_k_offset(version, key));
65 version = le_key_version(key);
90 static void sprintf_cpu_key(
char *buf,
struct cpu_key *key)
94 key->
on_disk_key.k_objectid, reiserfs_cpu_offset(key),
104 "[offset=%d dir_id=%d objectid=%d location=%d state=%04x]",
112 static void sprintf_item_head(
char *buf,
struct item_head *ih)
118 sprintf(buf +
strlen(buf),
", item_len %d, item_location %d, "
119 "free_space(entry_count) %d",
134 static void sprintf_block_head(
char *buf,
struct buffer_head *bh)
136 sprintf(buf,
"level=%d, nr_items=%d, free_space=%d rdkey ",
140 static void sprintf_buffer_head(
char *buf,
struct buffer_head *bh)
145 "dev %s, size %zd, blocknr %llu, count %d, state 0x%lx, page %p, (%s, %s, %s)",
146 bdevname(bh->b_bdev, b), bh->b_size,
147 (
unsigned long long)bh->b_blocknr,
atomic_read(&(bh->b_count)),
148 bh->b_state, bh->b_page,
149 buffer_uptodate(bh) ?
"UPTODATE" :
"!UPTODATE",
150 buffer_dirty(bh) ?
"DIRTY" :
"CLEAN",
151 buffer_locked(bh) ?
"LOCKED" :
"UNLOCKED");
154 static void sprintf_disk_child(
char *buf,
struct disk_child *
dc)
160 static char *is_there_reiserfs_struct(
char *
fmt,
int *
what)
165 if (k[1] ==
'k' || k[1] ==
'K' || k[1] ==
'h' || k[1] ==
't' ||
166 k[1] ==
'z' || k[1] ==
'b' || k[1] ==
'y' || k[1] ==
'a') {
188 static void prepare_error_buf(
const char *fmt,
va_list args)
190 char *fmt1 = fmt_buf;
195 spin_lock(&error_lock);
199 while ((k = is_there_reiserfs_struct(fmt1, &what)) !=
NULL) {
220 sprintf_disk_child(p,
224 sprintf_block_head(p,
225 va_arg(args,
struct buffer_head *));
228 sprintf_buffer_head(p,
229 va_arg(args,
struct buffer_head *));
242 spin_unlock(&error_lock);
256 #define do_reiserfs_warning(fmt)\
259 va_start( args, fmt );\
260 prepare_error_buf( fmt, args );\
265 const char *
function,
const char *fmt, ...)
270 "%s\n", sb->
s_id,
id ?
id :
"",
id ?
" " :
"",
271 function, error_buf);
274 id ?
id :
"",
id ?
" " :
"",
function, error_buf);
283 sb->
s_id, error_buf);
289 static void reiserfs_printk(
const char *fmt, ...)
297 #ifdef CONFIG_REISERFS_CHECK
353 const char *
function,
const char *fmt, ...)
357 #ifdef CONFIG_REISERFS_CHECK
362 sb->
s_id,
id ?
id :
"",
id ?
" " :
"",
363 function, error_buf);
366 id ?
id :
"",
id ?
" " :
"",
function, error_buf);
370 const char *
function,
const char *fmt, ...)
381 sb->
s_id,
id,
function, error_buf);
384 sb->
s_id,
function, error_buf);
416 static int print_internal(
struct buffer_head *bh,
int first,
int last)
436 reiserfs_printk(
"INTERNAL NODE (%ld) contains %z\n", bh->b_blocknr, bh);
439 reiserfs_printk(
"PTR %d: %y ", from, dc);
443 reiserfs_printk(
"KEY %d: %k PTR %d: %y ", i, key, i + 1, dc);
451 static int print_leaf(
struct buffer_head *bh,
int print_mode,
int first,
469 (
"\n===================================================================\n");
470 reiserfs_printk(
"LEAF NODE (%ld) contains %z\n", bh->b_blocknr, bh);
473 reiserfs_printk(
"FIRST ITEM_KEY: %k, LAST ITEM KEY: %k\n",
474 &(ih->
ih_key), &((ih + nr - 1)->ih_key));
478 if (first < 0 || first > nr - 1)
483 if (last < 0 || last > nr)
490 (
"-------------------------------------------------------------------------------\n");
492 (
"|##| type | key | ilen | free_space | version | loc |\n");
493 for (i = from; i < to; i++, ih++) {
495 (
"-------------------------------------------------------------------------------\n");
496 reiserfs_printk(
"|%2d| %h |\n", i, ih);
497 if (print_mode & PRINT_LEAF_ITEMS)
502 (
"===================================================================\n");
520 static int print_super_block(
struct buffer_head *bh)
524 int skipped, data_blocks;
539 printk(
"%s\'s super block is in block %llu\n",
bdevname(bh->b_bdev, b),
540 (
unsigned long long)bh->b_blocknr);
541 printk(
"Reiserfs version %s\n", version);
548 skipped = bh->b_blocknr;
553 (
"Busy blocks (skipped %d, bitmaps - %d, journal (or reserved) blocks - %d\n"
554 "1 super block, %d data blocks\n", skipped,
sb_bmap_nr(rs),
562 printk(
"Hash function \"%s\"\n",
569 static int print_desc_block(
struct buffer_head *bh)
577 printk(
"Desc block %llu (j_trans_id %d, j_mount_id %d, j_len %d)",
590 printk(
"print_block: buffer is NULL\n");
597 first =
va_arg(args,
int);
599 if (print_leaf(bh, mode, first, last))
600 if (print_internal(bh, first, last))
601 if (print_super_block(bh))
602 if (print_desc_block(bh))
604 (
"Block %llu contains unformatted data\n",
605 (
unsigned long long)bh->b_blocknr);
610 static char print_tb_buf[2048];
617 struct buffer_head *tbSh, *tbFh;
624 "MODE=%c, ITEM_POS=%d POS_IN_ITEM=%d\n"
625 "=====================================================================\n"
626 "* h * S * L * R * F * FL * FR * CFL * CFR *\n",
627 REISERFS_SB(tb->
tb_sb)->s_do_balance,
643 "* %d * %3lld(%2d) * %3lld(%2d) * %3lld(%2d) * %5lld * %5lld * %5lld * %5lld * %5lld *\n",
645 (tbSh) ? (
long long)(tbSh->b_blocknr) : (-1
LL),
647 (tb->
L[h]) ? (
long long)(tb->
L[h]->b_blocknr) : (-1
LL),
649 (tb->
R[h]) ? (
long long)(tb->
R[h]->b_blocknr) : (-1
LL),
651 (tbFh) ? (
long long)(tbFh->b_blocknr) : (-1
LL),
652 (tb->
FL[h]) ? (
long long)(tb->
FL[h]->
654 (tb->
FR[h]) ? (
long long)(tb->
FR[h]->
656 (tb->
CFL[h]) ? (
long long)(tb->
CFL[h]->
658 (tb->
CFR[h]) ? (
long long)(tb->
CFR[h]->
659 b_blocknr) : (-1
LL));
663 "=====================================================================\n"
664 "* h * size * ln * lb * rn * rb * blkn * s0 * s1 * s1b * s2 * s2b * curb * lk * rk *\n"
665 "* 0 * %4d * %2d * %2d * %2d * %2d * %4d * %2d * %2d * %3d * %2d * %3d * %4d * %2d * %2d *\n",
676 "* %d * %4d * %2d * * %2d * * %2d *\n",
682 "=====================================================================\n"
689 "%p (%llu %d)%s", tb->
FEB[
i],
696 "======================== the end ====================================\n");
701 printk(
"%s\n%s", mes, print_tb_buf);
704 static void check_leaf_block_head(
struct buffer_head *bh)
720 static void check_internal_block_head(
struct buffer_head *bh)
745 check_leaf_block_head(bh);
754 check_internal_block_head(bh);