Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3a9c210 authored by Jeff Mahoney's avatar Jeff Mahoney Committed by Linus Torvalds
Browse files

reiserfs: rework reiserfs_panic



ReiserFS panics 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: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 78b6513d
Loading
Loading
Loading
Loading
+35 −32
Original line number Diff line number Diff line
@@ -153,8 +153,8 @@ static int balance_leaf_when_delete(struct tree_balance *tb, int flag)

	default:
		print_cur_tb("12040");
		reiserfs_panic(tb->tb_sb,
			       "PAP-12040: balance_leaf_when_delete: unexpectable mode: %s(%d)",
		reiserfs_panic(tb->tb_sb, "PAP-12040",
			       "unexpected mode: %s(%d)",
			       (flag ==
				M_PASTE) ? "PASTE" : ((flag ==
						       M_INSERT) ? "INSERT" :
@@ -721,8 +721,9 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
				}
				break;
			default:	/* cases d and t */
				reiserfs_panic(tb->tb_sb,
					       "PAP-12130: balance_leaf: lnum > 0: unexpectable mode: %s(%d)",
				reiserfs_panic(tb->tb_sb, "PAP-12130",
					       "lnum > 0: unexpected mode: "
					       " %s(%d)",
					       (flag ==
						M_DELETE) ? "DELETE" : ((flag ==
									 M_CUT)
@@ -1134,8 +1135,8 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
			}
			break;
		default:	/* cases d and t */
			reiserfs_panic(tb->tb_sb,
				       "PAP-12175: balance_leaf: rnum > 0: unexpectable mode: %s(%d)",
			reiserfs_panic(tb->tb_sb, "PAP-12175",
				       "rnum > 0: unexpected mode: %s(%d)",
				       (flag ==
					M_DELETE) ? "DELETE" : ((flag ==
								 M_CUT) ? "CUT"
@@ -1165,8 +1166,8 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
		   not set correctly */
		if (tb->CFL[0]) {
			if (!tb->CFR[0])
				reiserfs_panic(tb->tb_sb,
					       "vs-12195: balance_leaf: CFR not initialized");
				reiserfs_panic(tb->tb_sb, "vs-12195",
					       "CFR not initialized");
			copy_key(B_N_PDELIM_KEY(tb->CFL[0], tb->lkey[0]),
				 B_N_PDELIM_KEY(tb->CFR[0], tb->rkey[0]));
			do_balance_mark_internal_dirty(tb, tb->CFL[0], 0);
@@ -1472,7 +1473,10 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
					    && (pos_in_item != ih_item_len(ih_check)
						|| tb->insert_size[0] <= 0))
						reiserfs_panic(tb->tb_sb,
							       "PAP-12235: balance_leaf: pos_in_item must be equal to ih_item_len");
							     "PAP-12235",
							     "pos_in_item "
							     "must be equal "
							     "to ih_item_len");
#endif				/* CONFIG_REISERFS_CHECK */

					leaf_mi =
@@ -1532,8 +1536,8 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
			}
			break;
		default:	/* cases d and t */
			reiserfs_panic(tb->tb_sb,
				       "PAP-12245: balance_leaf: blknum > 2: unexpectable mode: %s(%d)",
			reiserfs_panic(tb->tb_sb, "PAP-12245",
				       "blknum > 2: unexpected mode: %s(%d)",
				       (flag ==
					M_DELETE) ? "DELETE" : ((flag ==
								 M_CUT) ? "CUT"
@@ -1678,10 +1682,11 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
							print_cur_tb("12285");
							reiserfs_panic(tb->
								       tb_sb,
								       "PAP-12285: balance_leaf: insert_size must be 0 (%d)",
								       tb->
								       insert_size
								       [0]);
							    "PAP-12285",
							    "insert_size "
							    "must be 0 "
							    "(%d)",
							    tb->insert_size[0]);
						}
					}
#endif				/* CONFIG_REISERFS_CHECK */
@@ -1694,11 +1699,10 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
	if (flag == M_PASTE && tb->insert_size[0]) {
		print_cur_tb("12290");
		reiserfs_panic(tb->tb_sb,
			       "PAP-12290: balance_leaf: insert_size is still not 0 (%d)",
			       "PAP-12290", "insert_size is still not 0 (%d)",
			       tb->insert_size[0]);
	}
#endif				/* CONFIG_REISERFS_CHECK */

	return 0;
}				/* Leaf level of the tree is balanced (end of balance_leaf) */

@@ -1729,8 +1733,7 @@ struct buffer_head *get_FEB(struct tree_balance *tb)
			break;

	if (i == MAX_FEB_SIZE)
		reiserfs_panic(tb->tb_sb,
			       "vs-12300: get_FEB: FEB list is empty");
		reiserfs_panic(tb->tb_sb, "vs-12300", "FEB list is empty");

	bi.tb = tb;
	bi.bi_bh = first_b = tb->FEB[i];
@@ -1871,8 +1874,8 @@ static void check_internal_node(struct super_block *s, struct buffer_head *bh,
	for (i = 0; i <= B_NR_ITEMS(bh); i++, dc++) {
		if (!is_reusable(s, dc_block_number(dc), 1)) {
			print_cur_tb(mes);
			reiserfs_panic(s,
				       "PAP-12338: check_internal_node: invalid child pointer %y in %b",
			reiserfs_panic(s, "PAP-12338",
				       "invalid child pointer %y in %b",
				       dc, bh);
		}
	}
@@ -1894,9 +1897,10 @@ static int check_before_balancing(struct tree_balance *tb)
	int retval = 0;

	if (cur_tb) {
		reiserfs_panic(tb->tb_sb, "vs-12335: check_before_balancing: "
			       "suspect that schedule occurred based on cur_tb not being null at this point in code. "
			       "do_balance cannot properly handle schedule occurring while it runs.");
		reiserfs_panic(tb->tb_sb, "vs-12335", "suspect that schedule "
			       "occurred based on cur_tb not being null at "
			       "this point in code. do_balance cannot properly "
			       "handle schedule occurring while it runs.");
	}

	/* double check that buffers that we will modify are unlocked. (fix_nodes should already have
@@ -1928,8 +1932,8 @@ static void check_after_balance_leaf(struct tree_balance *tb)
		    dc_size(B_N_CHILD
			    (tb->FL[0], get_left_neighbor_position(tb, 0)))) {
			print_cur_tb("12221");
			reiserfs_panic(tb->tb_sb,
				       "PAP-12355: check_after_balance_leaf: shift to left was incorrect");
			reiserfs_panic(tb->tb_sb, "PAP-12355",
				       "shift to left was incorrect");
		}
	}
	if (tb->rnum[0]) {
@@ -1938,8 +1942,8 @@ static void check_after_balance_leaf(struct tree_balance *tb)
		    dc_size(B_N_CHILD
			    (tb->FR[0], get_right_neighbor_position(tb, 0)))) {
			print_cur_tb("12222");
			reiserfs_panic(tb->tb_sb,
				       "PAP-12360: check_after_balance_leaf: shift to right was incorrect");
			reiserfs_panic(tb->tb_sb, "PAP-12360",
				       "shift to right was incorrect");
		}
	}
	if (PATH_H_PBUFFER(tb->tb_path, 1) &&
@@ -1964,8 +1968,7 @@ static void check_after_balance_leaf(struct tree_balance *tb)
					 (PATH_H_PBUFFER(tb->tb_path, 1),
					  PATH_H_POSITION(tb->tb_path, 1))),
				 right);
		reiserfs_panic(tb->tb_sb,
			       "PAP-12365: check_after_balance_leaf: S is incorrect");
		reiserfs_panic(tb->tb_sb, "PAP-12365", "S is incorrect");
	}
}

@@ -2100,8 +2103,8 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
	tb->need_balance_dirty = 0;

	if (FILESYSTEM_CHANGED_TB(tb)) {
		reiserfs_panic(tb->tb_sb,
			       "clm-6000: do_balance, fs generation has changed\n");
		reiserfs_panic(tb->tb_sb, "clm-6000", "fs generation has "
			       "changed");
	}
	/* if we have no real work to do  */
	if (!tb->insert_size[0]) {
+35 −33
Original line number Diff line number Diff line
@@ -135,8 +135,7 @@ static void create_virtual_node(struct tree_balance *tb, int h)
		vn->vn_free_ptr +=
		    op_create_vi(vn, vi, is_affected, tb->insert_size[0]);
		if (tb->vn_buf + tb->vn_buf_size < vn->vn_free_ptr)
			reiserfs_panic(tb->tb_sb,
				       "vs-8030: create_virtual_node: "
			reiserfs_panic(tb->tb_sb, "vs-8030",
				       "virtual node space consumed");

		if (!is_affected)
@@ -186,8 +185,9 @@ static void create_virtual_node(struct tree_balance *tb, int h)
			     && I_ENTRY_COUNT(B_N_PITEM_HEAD(Sh, 0)) == 1)) {
				/* node contains more than 1 item, or item is not directory item, or this item contains more than 1 entry */
				print_block(Sh, 0, -1, -1);
				reiserfs_panic(tb->tb_sb,
					       "vs-8045: create_virtual_node: rdkey %k, affected item==%d (mode==%c) Must be %c",
				reiserfs_panic(tb->tb_sb, "vs-8045",
					       "rdkey %k, affected item==%d "
					       "(mode==%c) Must be %c",
					       key, vn->vn_affected_item_num,
					       vn->vn_mode, M_DELETE);
			}
@@ -1255,8 +1255,8 @@ static int ip_check_balance(struct tree_balance *tb, int h)
	/* Calculate balance parameters for creating new root. */
	if (!Sh) {
		if (!h)
			reiserfs_panic(tb->tb_sb,
				       "vs-8210: ip_check_balance: S[0] can not be 0");
			reiserfs_panic(tb->tb_sb, "vs-8210",
				       "S[0] can not be 0");
		switch (n_ret_value = get_empty_nodes(tb, h)) {
		case CARRY_ON:
			set_parameters(tb, h, 0, 0, 1, NULL, -1, -1);
@@ -1266,8 +1266,8 @@ static int ip_check_balance(struct tree_balance *tb, int h)
		case REPEAT_SEARCH:
			return n_ret_value;
		default:
			reiserfs_panic(tb->tb_sb,
				       "vs-8215: ip_check_balance: incorrect return value of get_empty_nodes");
			reiserfs_panic(tb->tb_sb, "vs-8215", "incorrect "
				       "return value of get_empty_nodes");
		}
	}

@@ -2095,38 +2095,38 @@ static void tb_buffer_sanity_check(struct super_block *p_s_sb,
	if (p_s_bh) {
		if (atomic_read(&(p_s_bh->b_count)) <= 0) {

			reiserfs_panic(p_s_sb,
				       "jmacd-1: tb_buffer_sanity_check(): negative or zero reference counter for buffer %s[%d] (%b)\n",
				       descr, level, p_s_bh);
			reiserfs_panic(p_s_sb, "jmacd-1", "negative or zero "
				       "reference counter for buffer %s[%d] "
				       "(%b)", descr, level, p_s_bh);
		}

		if (!buffer_uptodate(p_s_bh)) {
			reiserfs_panic(p_s_sb,
				       "jmacd-2: tb_buffer_sanity_check(): buffer is not up to date %s[%d] (%b)\n",
			reiserfs_panic(p_s_sb, "jmacd-2", "buffer is not up "
				       "to date %s[%d] (%b)",
				       descr, level, p_s_bh);
		}

		if (!B_IS_IN_TREE(p_s_bh)) {
			reiserfs_panic(p_s_sb,
				       "jmacd-3: tb_buffer_sanity_check(): buffer is not in tree %s[%d] (%b)\n",
			reiserfs_panic(p_s_sb, "jmacd-3", "buffer is not "
				       "in tree %s[%d] (%b)",
				       descr, level, p_s_bh);
		}

		if (p_s_bh->b_bdev != p_s_sb->s_bdev) {
			reiserfs_panic(p_s_sb,
				       "jmacd-4: tb_buffer_sanity_check(): buffer has wrong device %s[%d] (%b)\n",
			reiserfs_panic(p_s_sb, "jmacd-4", "buffer has wrong "
				       "device %s[%d] (%b)",
				       descr, level, p_s_bh);
		}

		if (p_s_bh->b_size != p_s_sb->s_blocksize) {
			reiserfs_panic(p_s_sb,
				       "jmacd-5: tb_buffer_sanity_check(): buffer has wrong blocksize %s[%d] (%b)\n",
			reiserfs_panic(p_s_sb, "jmacd-5", "buffer has wrong "
				       "blocksize %s[%d] (%b)",
				       descr, level, p_s_bh);
		}

		if (p_s_bh->b_blocknr > SB_BLOCK_COUNT(p_s_sb)) {
			reiserfs_panic(p_s_sb,
				       "jmacd-6: tb_buffer_sanity_check(): buffer block number too high %s[%d] (%b)\n",
			reiserfs_panic(p_s_sb, "jmacd-6", "buffer block "
				       "number too high %s[%d] (%b)",
				       descr, level, p_s_bh);
		}
	}
@@ -2358,14 +2358,14 @@ int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb, struct item_head *p_s_
#ifdef CONFIG_REISERFS_CHECK
	if (cur_tb) {
		print_cur_tb("fix_nodes");
		reiserfs_panic(p_s_tb->tb_sb,
			       "PAP-8305: fix_nodes:  there is pending do_balance");
		reiserfs_panic(p_s_tb->tb_sb, "PAP-8305",
			       "there is pending do_balance");
	}

	if (!buffer_uptodate(p_s_tbS0) || !B_IS_IN_TREE(p_s_tbS0)) {
		reiserfs_panic(p_s_tb->tb_sb,
			       "PAP-8320: fix_nodes: S[0] (%b %z) is not uptodate "
			       "at the beginning of fix_nodes or not in tree (mode %c)",
		reiserfs_panic(p_s_tb->tb_sb, "PAP-8320", "S[0] (%b %z) is "
			       "not uptodate at the beginning of fix_nodes "
			       "or not in tree (mode %c)",
			       p_s_tbS0, p_s_tbS0, n_op_mode);
	}

@@ -2373,24 +2373,26 @@ int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb, struct item_head *p_s_
	switch (n_op_mode) {
	case M_INSERT:
		if (n_item_num <= 0 || n_item_num > B_NR_ITEMS(p_s_tbS0))
			reiserfs_panic(p_s_tb->tb_sb,
				       "PAP-8330: fix_nodes: Incorrect item number %d (in S0 - %d) in case of insert",
				       n_item_num, B_NR_ITEMS(p_s_tbS0));
			reiserfs_panic(p_s_tb->tb_sb, "PAP-8330", "Incorrect "
				       "item number %d (in S0 - %d) in case "
				       "of insert", n_item_num,
				       B_NR_ITEMS(p_s_tbS0));
		break;
	case M_PASTE:
	case M_DELETE:
	case M_CUT:
		if (n_item_num < 0 || n_item_num >= B_NR_ITEMS(p_s_tbS0)) {
			print_block(p_s_tbS0, 0, -1, -1);
			reiserfs_panic(p_s_tb->tb_sb,
				       "PAP-8335: fix_nodes: Incorrect item number(%d); mode = %c insert_size = %d\n",
			reiserfs_panic(p_s_tb->tb_sb, "PAP-8335", "Incorrect "
				       "item number(%d); mode = %c "
				       "insert_size = %d",
				       n_item_num, n_op_mode,
				       p_s_tb->insert_size[0]);
		}
		break;
	default:
		reiserfs_panic(p_s_tb->tb_sb,
			       "PAP-8340: fix_nodes: Incorrect mode of operation");
		reiserfs_panic(p_s_tb->tb_sb, "PAP-8340", "Incorrect mode "
			       "of operation");
	}
#endif

+6 −6
Original line number Diff line number Diff line
@@ -105,8 +105,8 @@ static void internal_define_dest_src_infos(int shift_mode,
		break;

	default:
		reiserfs_panic(tb->tb_sb,
			       "internal_define_dest_src_infos: shift type is unknown (%d)",
		reiserfs_panic(tb->tb_sb, "ibalance-1",
			       "shift type is unknown (%d)",
			       shift_mode);
	}
}
@@ -702,8 +702,8 @@ static void balance_internal_when_delete(struct tree_balance *tb,

		return;
	}
	reiserfs_panic(tb->tb_sb,
		       "balance_internal_when_delete: unexpected tb->lnum[%d]==%d or tb->rnum[%d]==%d",
	reiserfs_panic(tb->tb_sb, "ibalance-2",
		       "unexpected tb->lnum[%d]==%d or tb->rnum[%d]==%d",
		       h, tb->lnum[h], h, tb->rnum[h]);
}

@@ -940,8 +940,8 @@ int balance_internal(struct tree_balance *tb, /* tree_balance structure
		struct block_head *blkh;

		if (tb->blknum[h] != 1)
			reiserfs_panic(NULL,
				       "balance_internal: One new node required for creating the new root");
			reiserfs_panic(NULL, "ibalance-3", "One new node "
				       "required for creating the new root");
		/* S[h] = empty buffer from the list FEB. */
		tbSh = get_FEB(tb);
		blkh = B_BLK_HEAD(tbSh);
+1 −2
Original line number Diff line number Diff line
@@ -1300,8 +1300,7 @@ static void update_stat_data(struct treepath *path, struct inode *inode,
	ih = PATH_PITEM_HEAD(path);

	if (!is_statdata_le_ih(ih))
		reiserfs_panic(inode->i_sb,
			       "vs-13065: update_stat_data: key %k, found item %h",
		reiserfs_panic(inode->i_sb, "vs-13065", "key %k, found item %h",
			       INODE_PKEY(inode), ih);

	if (stat_data_v1(ih)) {
+5 −3
Original line number Diff line number Diff line
@@ -517,8 +517,9 @@ static int direntry_create_vi(struct virtual_node *vn,
		    ((is_affected
		      && (vn->vn_mode == M_PASTE
			  || vn->vn_mode == M_CUT)) ? insert_size : 0)) {
			reiserfs_panic(NULL,
				       "vs-8025: set_entry_sizes: (mode==%c, insert_size==%d), invalid length of directory item",
			reiserfs_panic(NULL, "vs-8025", "(mode==%c, "
				       "insert_size==%d), invalid length of "
				       "directory item",
				       vn->vn_mode, insert_size);
		}
	}
@@ -549,7 +550,8 @@ static int direntry_check_left(struct virtual_item *vi, int free,
	}

	if (entries == dir_u->entry_count) {
		reiserfs_panic(NULL, "free space %d, entry_count %d\n", free,
		reiserfs_panic(NULL, "item_ops-1",
			       "free space %d, entry_count %d", free,
			       dir_u->entry_count);
	}

Loading