diff options
author | Jeff Mahoney <jeffm@suse.com> | 2009-03-30 14:02:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-03-30 15:16:36 -0400 |
commit | 45b03d5e8e674eb6555b767e1c8eb40b671ff892 (patch) | |
tree | d74acd1be7f5102143df960e8cd692aadcc437df /fs/reiserfs/stree.c | |
parent | 1d889d9958490888b3fad1d486145d9a03559cbc (diff) |
reiserfs: rework reiserfs_warning
ReiserFS warnings can be somewhat inconsistent.
In some cases:
* a unique identifier may be associated with it
* the function name may be included
* the device may be printed separately
This patch aims to make warnings more consistent. reiserfs_warning() prints
the device name, so printing it a second time is not required. The function
name for a warning is always helpful in debugging, so it is now automatically
inserted into the output. Hans has stated that every warning should have
a unique identifier. Some cases lack them, others really shouldn't have them.
reiserfs_warning() now expects an id associated with each message. In the
rare case where one isn't needed, "" will suffice.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/reiserfs/stree.c')
-rw-r--r-- | fs/reiserfs/stree.c | 107 |
1 files changed, 50 insertions, 57 deletions
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c index abbc64dcc8d4..f328d27a19d5 100644 --- a/fs/reiserfs/stree.c +++ b/fs/reiserfs/stree.c | |||
@@ -444,23 +444,24 @@ static int is_leaf(char *buf, int blocksize, struct buffer_head *bh) | |||
444 | 444 | ||
445 | blkh = (struct block_head *)buf; | 445 | blkh = (struct block_head *)buf; |
446 | if (blkh_level(blkh) != DISK_LEAF_NODE_LEVEL) { | 446 | if (blkh_level(blkh) != DISK_LEAF_NODE_LEVEL) { |
447 | reiserfs_warning(NULL, | 447 | reiserfs_warning(NULL, "reiserfs-5080", |
448 | "is_leaf: this should be caught earlier"); | 448 | "this should be caught earlier"); |
449 | return 0; | 449 | return 0; |
450 | } | 450 | } |
451 | 451 | ||
452 | nr = blkh_nr_item(blkh); | 452 | nr = blkh_nr_item(blkh); |
453 | if (nr < 1 || nr > ((blocksize - BLKH_SIZE) / (IH_SIZE + MIN_ITEM_LEN))) { | 453 | if (nr < 1 || nr > ((blocksize - BLKH_SIZE) / (IH_SIZE + MIN_ITEM_LEN))) { |
454 | /* item number is too big or too small */ | 454 | /* item number is too big or too small */ |
455 | reiserfs_warning(NULL, "is_leaf: nr_item seems wrong: %z", bh); | 455 | reiserfs_warning(NULL, "reiserfs-5081", |
456 | "nr_item seems wrong: %z", bh); | ||
456 | return 0; | 457 | return 0; |
457 | } | 458 | } |
458 | ih = (struct item_head *)(buf + BLKH_SIZE) + nr - 1; | 459 | ih = (struct item_head *)(buf + BLKH_SIZE) + nr - 1; |
459 | used_space = BLKH_SIZE + IH_SIZE * nr + (blocksize - ih_location(ih)); | 460 | used_space = BLKH_SIZE + IH_SIZE * nr + (blocksize - ih_location(ih)); |
460 | if (used_space != blocksize - blkh_free_space(blkh)) { | 461 | if (used_space != blocksize - blkh_free_space(blkh)) { |
461 | /* free space does not match to calculated amount of use space */ | 462 | /* free space does not match to calculated amount of use space */ |
462 | reiserfs_warning(NULL, "is_leaf: free space seems wrong: %z", | 463 | reiserfs_warning(NULL, "reiserfs-5082", |
463 | bh); | 464 | "free space seems wrong: %z", bh); |
464 | return 0; | 465 | return 0; |
465 | } | 466 | } |
466 | // FIXME: it is_leaf will hit performance too much - we may have | 467 | // FIXME: it is_leaf will hit performance too much - we may have |
@@ -471,29 +472,29 @@ static int is_leaf(char *buf, int blocksize, struct buffer_head *bh) | |||
471 | prev_location = blocksize; | 472 | prev_location = blocksize; |
472 | for (i = 0; i < nr; i++, ih++) { | 473 | for (i = 0; i < nr; i++, ih++) { |
473 | if (le_ih_k_type(ih) == TYPE_ANY) { | 474 | if (le_ih_k_type(ih) == TYPE_ANY) { |
474 | reiserfs_warning(NULL, | 475 | reiserfs_warning(NULL, "reiserfs-5083", |
475 | "is_leaf: wrong item type for item %h", | 476 | "wrong item type for item %h", |
476 | ih); | 477 | ih); |
477 | return 0; | 478 | return 0; |
478 | } | 479 | } |
479 | if (ih_location(ih) >= blocksize | 480 | if (ih_location(ih) >= blocksize |
480 | || ih_location(ih) < IH_SIZE * nr) { | 481 | || ih_location(ih) < IH_SIZE * nr) { |
481 | reiserfs_warning(NULL, | 482 | reiserfs_warning(NULL, "reiserfs-5084", |
482 | "is_leaf: item location seems wrong: %h", | 483 | "item location seems wrong: %h", |
483 | ih); | 484 | ih); |
484 | return 0; | 485 | return 0; |
485 | } | 486 | } |
486 | if (ih_item_len(ih) < 1 | 487 | if (ih_item_len(ih) < 1 |
487 | || ih_item_len(ih) > MAX_ITEM_LEN(blocksize)) { | 488 | || ih_item_len(ih) > MAX_ITEM_LEN(blocksize)) { |
488 | reiserfs_warning(NULL, | 489 | reiserfs_warning(NULL, "reiserfs-5085", |
489 | "is_leaf: item length seems wrong: %h", | 490 | "item length seems wrong: %h", |
490 | ih); | 491 | ih); |
491 | return 0; | 492 | return 0; |
492 | } | 493 | } |
493 | if (prev_location - ih_location(ih) != ih_item_len(ih)) { | 494 | if (prev_location - ih_location(ih) != ih_item_len(ih)) { |
494 | reiserfs_warning(NULL, | 495 | reiserfs_warning(NULL, "reiserfs-5086", |
495 | "is_leaf: item location seems wrong (second one): %h", | 496 | "item location seems wrong " |
496 | ih); | 497 | "(second one): %h", ih); |
497 | return 0; | 498 | return 0; |
498 | } | 499 | } |
499 | prev_location = ih_location(ih); | 500 | prev_location = ih_location(ih); |
@@ -514,24 +515,23 @@ static int is_internal(char *buf, int blocksize, struct buffer_head *bh) | |||
514 | nr = blkh_level(blkh); | 515 | nr = blkh_level(blkh); |
515 | if (nr <= DISK_LEAF_NODE_LEVEL || nr > MAX_HEIGHT) { | 516 | if (nr <= DISK_LEAF_NODE_LEVEL || nr > MAX_HEIGHT) { |
516 | /* this level is not possible for internal nodes */ | 517 | /* this level is not possible for internal nodes */ |
517 | reiserfs_warning(NULL, | 518 | reiserfs_warning(NULL, "reiserfs-5087", |
518 | "is_internal: this should be caught earlier"); | 519 | "this should be caught earlier"); |
519 | return 0; | 520 | return 0; |
520 | } | 521 | } |
521 | 522 | ||
522 | nr = blkh_nr_item(blkh); | 523 | nr = blkh_nr_item(blkh); |
523 | if (nr > (blocksize - BLKH_SIZE - DC_SIZE) / (KEY_SIZE + DC_SIZE)) { | 524 | if (nr > (blocksize - BLKH_SIZE - DC_SIZE) / (KEY_SIZE + DC_SIZE)) { |
524 | /* for internal which is not root we might check min number of keys */ | 525 | /* for internal which is not root we might check min number of keys */ |
525 | reiserfs_warning(NULL, | 526 | reiserfs_warning(NULL, "reiserfs-5088", |
526 | "is_internal: number of key seems wrong: %z", | 527 | "number of key seems wrong: %z", bh); |
527 | bh); | ||
528 | return 0; | 528 | return 0; |
529 | } | 529 | } |
530 | 530 | ||
531 | used_space = BLKH_SIZE + KEY_SIZE * nr + DC_SIZE * (nr + 1); | 531 | used_space = BLKH_SIZE + KEY_SIZE * nr + DC_SIZE * (nr + 1); |
532 | if (used_space != blocksize - blkh_free_space(blkh)) { | 532 | if (used_space != blocksize - blkh_free_space(blkh)) { |
533 | reiserfs_warning(NULL, | 533 | reiserfs_warning(NULL, "reiserfs-5089", |
534 | "is_internal: free space seems wrong: %z", bh); | 534 | "free space seems wrong: %z", bh); |
535 | return 0; | 535 | return 0; |
536 | } | 536 | } |
537 | // one may imagine much more checks | 537 | // one may imagine much more checks |
@@ -543,8 +543,8 @@ static int is_internal(char *buf, int blocksize, struct buffer_head *bh) | |||
543 | static int is_tree_node(struct buffer_head *bh, int level) | 543 | static int is_tree_node(struct buffer_head *bh, int level) |
544 | { | 544 | { |
545 | if (B_LEVEL(bh) != level) { | 545 | if (B_LEVEL(bh) != level) { |
546 | reiserfs_warning(NULL, | 546 | reiserfs_warning(NULL, "reiserfs-5090", "node level %d does " |
547 | "is_tree_node: node level %d does not match to the expected one %d", | 547 | "not match to the expected one %d", |
548 | B_LEVEL(bh), level); | 548 | B_LEVEL(bh), level); |
549 | return 0; | 549 | return 0; |
550 | } | 550 | } |
@@ -645,9 +645,9 @@ int search_by_key(struct super_block *p_s_sb, const struct cpu_key *p_s_key, /* | |||
645 | 645 | ||
646 | #ifdef CONFIG_REISERFS_CHECK | 646 | #ifdef CONFIG_REISERFS_CHECK |
647 | if (!(++n_repeat_counter % 50000)) | 647 | if (!(++n_repeat_counter % 50000)) |
648 | reiserfs_warning(p_s_sb, "PAP-5100: search_by_key: %s:" | 648 | reiserfs_warning(p_s_sb, "PAP-5100", |
649 | "there were %d iterations of while loop " | 649 | "%s: there were %d iterations of " |
650 | "looking for key %K", | 650 | "while loop looking for key %K", |
651 | current->comm, n_repeat_counter, | 651 | current->comm, n_repeat_counter, |
652 | p_s_key); | 652 | p_s_key); |
653 | #endif | 653 | #endif |
@@ -721,9 +721,9 @@ int search_by_key(struct super_block *p_s_sb, const struct cpu_key *p_s_key, /* | |||
721 | // make sure, that the node contents look like a node of | 721 | // make sure, that the node contents look like a node of |
722 | // certain level | 722 | // certain level |
723 | if (!is_tree_node(p_s_bh, expected_level)) { | 723 | if (!is_tree_node(p_s_bh, expected_level)) { |
724 | reiserfs_warning(p_s_sb, "vs-5150: search_by_key: " | 724 | reiserfs_warning(p_s_sb, "vs-5150", |
725 | "invalid format found in block %ld. Fsck?", | 725 | "invalid format found in block %ld. " |
726 | p_s_bh->b_blocknr); | 726 | "Fsck?", p_s_bh->b_blocknr); |
727 | pathrelse(p_s_search_path); | 727 | pathrelse(p_s_search_path); |
728 | return IO_ERROR; | 728 | return IO_ERROR; |
729 | } | 729 | } |
@@ -1227,8 +1227,7 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct treepath | |||
1227 | if (n_ret_value == IO_ERROR) | 1227 | if (n_ret_value == IO_ERROR) |
1228 | break; | 1228 | break; |
1229 | if (n_ret_value == FILE_NOT_FOUND) { | 1229 | if (n_ret_value == FILE_NOT_FOUND) { |
1230 | reiserfs_warning(p_s_sb, | 1230 | reiserfs_warning(p_s_sb, "vs-5340", |
1231 | "vs-5340: reiserfs_delete_item: " | ||
1232 | "no items of the file %K found", | 1231 | "no items of the file %K found", |
1233 | p_s_item_key); | 1232 | p_s_item_key); |
1234 | break; | 1233 | break; |
@@ -1338,10 +1337,9 @@ void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th, | |||
1338 | while (1) { | 1337 | while (1) { |
1339 | retval = search_item(th->t_super, &cpu_key, &path); | 1338 | retval = search_item(th->t_super, &cpu_key, &path); |
1340 | if (retval == IO_ERROR) { | 1339 | if (retval == IO_ERROR) { |
1341 | reiserfs_warning(th->t_super, | 1340 | reiserfs_warning(th->t_super, "vs-5350", |
1342 | "vs-5350: reiserfs_delete_solid_item: " | 1341 | "i/o failure occurred trying " |
1343 | "i/o failure occurred trying to delete %K", | 1342 | "to delete %K", &cpu_key); |
1344 | &cpu_key); | ||
1345 | break; | 1343 | break; |
1346 | } | 1344 | } |
1347 | if (retval != ITEM_FOUND) { | 1345 | if (retval != ITEM_FOUND) { |
@@ -1355,9 +1353,8 @@ void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th, | |||
1355 | GET_GENERATION_NUMBER(le_key_k_offset | 1353 | GET_GENERATION_NUMBER(le_key_k_offset |
1356 | (le_key_version(key), | 1354 | (le_key_version(key), |
1357 | key)) == 1)) | 1355 | key)) == 1)) |
1358 | reiserfs_warning(th->t_super, | 1356 | reiserfs_warning(th->t_super, "vs-5355", |
1359 | "vs-5355: reiserfs_delete_solid_item: %k not found", | 1357 | "%k not found", key); |
1360 | key); | ||
1361 | break; | 1358 | break; |
1362 | } | 1359 | } |
1363 | if (!tb_init) { | 1360 | if (!tb_init) { |
@@ -1389,8 +1386,7 @@ void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th, | |||
1389 | break; | 1386 | break; |
1390 | } | 1387 | } |
1391 | // IO_ERROR, NO_DISK_SPACE, etc | 1388 | // IO_ERROR, NO_DISK_SPACE, etc |
1392 | reiserfs_warning(th->t_super, | 1389 | reiserfs_warning(th->t_super, "vs-5360", |
1393 | "vs-5360: reiserfs_delete_solid_item: " | ||
1394 | "could not delete %K due to fix_nodes failure", | 1390 | "could not delete %K due to fix_nodes failure", |
1395 | &cpu_key); | 1391 | &cpu_key); |
1396 | unfix_nodes(&tb); | 1392 | unfix_nodes(&tb); |
@@ -1533,8 +1529,9 @@ static void indirect_to_direct_roll_back(struct reiserfs_transaction_handle *th, | |||
1533 | set_cpu_key_k_offset(&tail_key, | 1529 | set_cpu_key_k_offset(&tail_key, |
1534 | cpu_key_k_offset(&tail_key) - removed); | 1530 | cpu_key_k_offset(&tail_key) - removed); |
1535 | } | 1531 | } |
1536 | reiserfs_warning(inode->i_sb, | 1532 | reiserfs_warning(inode->i_sb, "reiserfs-5091", "indirect_to_direct " |
1537 | "indirect_to_direct_roll_back: indirect_to_direct conversion has been rolled back due to lack of disk space"); | 1533 | "conversion has been rolled back due to " |
1534 | "lack of disk space"); | ||
1538 | //mark_file_without_tail (inode); | 1535 | //mark_file_without_tail (inode); |
1539 | mark_inode_dirty(inode); | 1536 | mark_inode_dirty(inode); |
1540 | } | 1537 | } |
@@ -1639,8 +1636,7 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1639 | if (n_ret_value == POSITION_FOUND) | 1636 | if (n_ret_value == POSITION_FOUND) |
1640 | continue; | 1637 | continue; |
1641 | 1638 | ||
1642 | reiserfs_warning(p_s_sb, | 1639 | reiserfs_warning(p_s_sb, "PAP-5610", "item %K not found", |
1643 | "PAP-5610: reiserfs_cut_from_item: item %K not found", | ||
1644 | p_s_item_key); | 1640 | p_s_item_key); |
1645 | unfix_nodes(&s_cut_balance); | 1641 | unfix_nodes(&s_cut_balance); |
1646 | return (n_ret_value == IO_ERROR) ? -EIO : -ENOENT; | 1642 | return (n_ret_value == IO_ERROR) ? -EIO : -ENOENT; |
@@ -1654,7 +1650,8 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1654 | indirect_to_direct_roll_back(th, p_s_inode, p_s_path); | 1650 | indirect_to_direct_roll_back(th, p_s_inode, p_s_path); |
1655 | } | 1651 | } |
1656 | if (n_ret_value == NO_DISK_SPACE) | 1652 | if (n_ret_value == NO_DISK_SPACE) |
1657 | reiserfs_warning(p_s_sb, "NO_DISK_SPACE"); | 1653 | reiserfs_warning(p_s_sb, "reiserfs-5092", |
1654 | "NO_DISK_SPACE"); | ||
1658 | unfix_nodes(&s_cut_balance); | 1655 | unfix_nodes(&s_cut_balance); |
1659 | return -EIO; | 1656 | return -EIO; |
1660 | } | 1657 | } |
@@ -1743,8 +1740,7 @@ static void truncate_directory(struct reiserfs_transaction_handle *th, | |||
1743 | { | 1740 | { |
1744 | BUG_ON(!th->t_trans_id); | 1741 | BUG_ON(!th->t_trans_id); |
1745 | if (inode->i_nlink) | 1742 | if (inode->i_nlink) |
1746 | reiserfs_warning(inode->i_sb, | 1743 | reiserfs_warning(inode->i_sb, "vs-5655", "link count != 0"); |
1747 | "vs-5655: truncate_directory: link count != 0"); | ||
1748 | 1744 | ||
1749 | set_le_key_k_offset(KEY_FORMAT_3_5, INODE_PKEY(inode), DOT_OFFSET); | 1745 | set_le_key_k_offset(KEY_FORMAT_3_5, INODE_PKEY(inode), DOT_OFFSET); |
1750 | set_le_key_k_type(KEY_FORMAT_3_5, INODE_PKEY(inode), TYPE_DIRENTRY); | 1746 | set_le_key_k_type(KEY_FORMAT_3_5, INODE_PKEY(inode), TYPE_DIRENTRY); |
@@ -1797,16 +1793,14 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, struct inode *p | |||
1797 | search_for_position_by_key(p_s_inode->i_sb, &s_item_key, | 1793 | search_for_position_by_key(p_s_inode->i_sb, &s_item_key, |
1798 | &s_search_path); | 1794 | &s_search_path); |
1799 | if (retval == IO_ERROR) { | 1795 | if (retval == IO_ERROR) { |
1800 | reiserfs_warning(p_s_inode->i_sb, | 1796 | reiserfs_warning(p_s_inode->i_sb, "vs-5657", |
1801 | "vs-5657: reiserfs_do_truncate: " | ||
1802 | "i/o failure occurred trying to truncate %K", | 1797 | "i/o failure occurred trying to truncate %K", |
1803 | &s_item_key); | 1798 | &s_item_key); |
1804 | err = -EIO; | 1799 | err = -EIO; |
1805 | goto out; | 1800 | goto out; |
1806 | } | 1801 | } |
1807 | if (retval == POSITION_FOUND || retval == FILE_NOT_FOUND) { | 1802 | if (retval == POSITION_FOUND || retval == FILE_NOT_FOUND) { |
1808 | reiserfs_warning(p_s_inode->i_sb, | 1803 | reiserfs_warning(p_s_inode->i_sb, "PAP-5660", |
1809 | "PAP-5660: reiserfs_do_truncate: " | ||
1810 | "wrong result %d of search for %K", retval, | 1804 | "wrong result %d of search for %K", retval, |
1811 | &s_item_key); | 1805 | &s_item_key); |
1812 | 1806 | ||
@@ -1850,8 +1844,8 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, struct inode *p | |||
1850 | reiserfs_cut_from_item(th, &s_search_path, &s_item_key, | 1844 | reiserfs_cut_from_item(th, &s_search_path, &s_item_key, |
1851 | p_s_inode, page, n_new_file_size); | 1845 | p_s_inode, page, n_new_file_size); |
1852 | if (n_deleted < 0) { | 1846 | if (n_deleted < 0) { |
1853 | reiserfs_warning(p_s_inode->i_sb, | 1847 | reiserfs_warning(p_s_inode->i_sb, "vs-5665", |
1854 | "vs-5665: reiserfs_do_truncate: reiserfs_cut_from_item failed"); | 1848 | "reiserfs_cut_from_item failed"); |
1855 | reiserfs_check_path(&s_search_path); | 1849 | reiserfs_check_path(&s_search_path); |
1856 | return 0; | 1850 | return 0; |
1857 | } | 1851 | } |
@@ -2000,8 +1994,8 @@ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct tree | |||
2000 | goto error_out; | 1994 | goto error_out; |
2001 | } | 1995 | } |
2002 | if (retval == POSITION_FOUND) { | 1996 | if (retval == POSITION_FOUND) { |
2003 | reiserfs_warning(inode->i_sb, | 1997 | reiserfs_warning(inode->i_sb, "PAP-5710", |
2004 | "PAP-5710: reiserfs_paste_into_item: entry or pasted byte (%K) exists", | 1998 | "entry or pasted byte (%K) exists", |
2005 | p_s_key); | 1999 | p_s_key); |
2006 | retval = -EEXIST; | 2000 | retval = -EEXIST; |
2007 | goto error_out; | 2001 | goto error_out; |
@@ -2087,8 +2081,7 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th, struct treepath | |||
2087 | goto error_out; | 2081 | goto error_out; |
2088 | } | 2082 | } |
2089 | if (retval == ITEM_FOUND) { | 2083 | if (retval == ITEM_FOUND) { |
2090 | reiserfs_warning(th->t_super, | 2084 | reiserfs_warning(th->t_super, "PAP-5760", |
2091 | "PAP-5760: reiserfs_insert_item: " | ||
2092 | "key %K already exists in the tree", | 2085 | "key %K already exists in the tree", |
2093 | key); | 2086 | key); |
2094 | retval = -EEXIST; | 2087 | retval = -EEXIST; |