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

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

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: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1d889d99
Loading
Loading
Loading
Loading
+23 −29
Original line number Diff line number Diff line
@@ -64,8 +64,8 @@ int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value)
	unsigned int bmap_count = reiserfs_bmap_count(s);

	if (block == 0 || block >= SB_BLOCK_COUNT(s)) {
		reiserfs_warning(s,
				 "vs-4010: is_reusable: block number is out of range %lu (%u)",
		reiserfs_warning(s, "vs-4010",
				 "block number is out of range %lu (%u)",
				 block, SB_BLOCK_COUNT(s));
		return 0;
	}
@@ -79,30 +79,29 @@ int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value)
		b_blocknr_t bmap1 = REISERFS_SB(s)->s_sbh->b_blocknr + 1;
		if (block >= bmap1 &&
		    block <= bmap1 + bmap_count) {
			reiserfs_warning(s, "vs: 4019: is_reusable: "
					 "bitmap block %lu(%u) can't be freed or reused",
			reiserfs_warning(s, "vs-4019", "bitmap block %lu(%u) "
					 "can't be freed or reused",
					 block, bmap_count);
			return 0;
		}
	} else {
		if (offset == 0) {
			reiserfs_warning(s, "vs: 4020: is_reusable: "
					 "bitmap block %lu(%u) can't be freed or reused",
			reiserfs_warning(s, "vs-4020", "bitmap block %lu(%u) "
					 "can't be freed or reused",
					 block, bmap_count);
			return 0;
		}
	}

	if (bmap >= bmap_count) {
		reiserfs_warning(s,
				 "vs-4030: is_reusable: there is no so many bitmap blocks: "
				 "block=%lu, bitmap_nr=%u", block, bmap);
		reiserfs_warning(s, "vs-4030", "bitmap for requested block "
				 "is out of range: block=%lu, bitmap_nr=%u",
				 block, bmap);
		return 0;
	}

	if (bit_value == 0 && block == SB_ROOT_BLOCK(s)) {
		reiserfs_warning(s,
				 "vs-4050: is_reusable: this is root block (%u), "
		reiserfs_warning(s, "vs-4050", "this is root block (%u), "
				 "it must be busy", SB_ROOT_BLOCK(s));
		return 0;
	}
@@ -154,8 +153,8 @@ static int scan_bitmap_block(struct reiserfs_transaction_handle *th,
/* - I mean `a window of zero bits' as in description of this function - Zam. */

	if (!bi) {
		reiserfs_warning(s, "NULL bitmap info pointer for bitmap %d",
				 bmap_n);
		reiserfs_warning(s, "jdm-4055", "NULL bitmap info pointer "
				 "for bitmap %d", bmap_n);
		return 0;
	}

@@ -400,11 +399,8 @@ static void _reiserfs_free_block(struct reiserfs_transaction_handle *th,
	get_bit_address(s, block, &nr, &offset);

	if (nr >= reiserfs_bmap_count(s)) {
		reiserfs_warning(s, "vs-4075: reiserfs_free_block: "
				 "block %lu is out of range on %s "
				 "(nr=%u,max=%u)", block,
				 reiserfs_bdevname(s), nr,
				 reiserfs_bmap_count(s));
		reiserfs_warning(s, "vs-4075", "block %lu is out of range",
				 block);
		return;
	}

@@ -416,9 +412,8 @@ static void _reiserfs_free_block(struct reiserfs_transaction_handle *th,

	/* clear bit for the given block in bit map */
	if (!reiserfs_test_and_clear_le_bit(offset, bmbh->b_data)) {
		reiserfs_warning(s, "vs-4080: reiserfs_free_block: "
				 "free_block (%s:%lu)[dev:blocknr]: bit already cleared",
				 reiserfs_bdevname(s), block);
		reiserfs_warning(s, "vs-4080",
				 "block %lu: bit already cleared", block);
	}
	apbi[nr].free_count++;
	journal_mark_dirty(th, s, bmbh);
@@ -477,9 +472,8 @@ static void __discard_prealloc(struct reiserfs_transaction_handle *th,
	BUG_ON(!th->t_trans_id);
#ifdef CONFIG_REISERFS_CHECK
	if (ei->i_prealloc_count < 0)
		reiserfs_warning(th->t_super,
				 "zam-4001:%s: inode has negative prealloc blocks count.",
				 __func__);
		reiserfs_warning(th->t_super, "zam-4001",
				 "inode has negative prealloc blocks count.");
#endif
	while (ei->i_prealloc_count > 0) {
		reiserfs_free_prealloc_block(th, inode, ei->i_prealloc_block);
@@ -515,9 +509,9 @@ void reiserfs_discard_all_prealloc(struct reiserfs_transaction_handle *th)
				i_prealloc_list);
#ifdef CONFIG_REISERFS_CHECK
		if (!ei->i_prealloc_count) {
			reiserfs_warning(th->t_super,
					 "zam-4001:%s: inode is in prealloc list but has no preallocated blocks.",
					 __func__);
			reiserfs_warning(th->t_super, "zam-4001",
					 "inode is in prealloc list but has "
					 "no preallocated blocks.");
		}
#endif
		__discard_prealloc(th, ei);
@@ -631,8 +625,8 @@ int reiserfs_parse_alloc_options(struct super_block *s, char *options)
			continue;
		}

		reiserfs_warning(s, "zam-4001: %s : unknown option - %s",
				 __func__, this_char);
		reiserfs_warning(s, "zam-4001", "unknown option - %s",
				 this_char);
		return 1;
	}

+20 −20
Original line number Diff line number Diff line
@@ -1752,15 +1752,16 @@ static void store_thrown(struct tree_balance *tb, struct buffer_head *bh)
	int i;

	if (buffer_dirty(bh))
		reiserfs_warning(tb->tb_sb,
				 "store_thrown deals with dirty buffer");
		reiserfs_warning(tb->tb_sb, "reiserfs-12320",
				 "called with dirty buffer");
	for (i = 0; i < ARRAY_SIZE(tb->thrown); i++)
		if (!tb->thrown[i]) {
			tb->thrown[i] = bh;
			get_bh(bh);	/* free_thrown puts this */
			return;
		}
	reiserfs_warning(tb->tb_sb, "store_thrown: too many thrown buffers");
	reiserfs_warning(tb->tb_sb, "reiserfs-12321",
			 "too many thrown buffers");
}

static void free_thrown(struct tree_balance *tb)
@@ -1771,8 +1772,8 @@ static void free_thrown(struct tree_balance *tb)
		if (tb->thrown[i]) {
			blocknr = tb->thrown[i]->b_blocknr;
			if (buffer_dirty(tb->thrown[i]))
				reiserfs_warning(tb->tb_sb,
						 "free_thrown deals with dirty buffer %d",
				reiserfs_warning(tb->tb_sb, "reiserfs-12322",
						 "called with dirty buffer %d",
						 blocknr);
			brelse(tb->thrown[i]);	/* incremented in store_thrown */
			reiserfs_free_block(tb->transaction_handle, NULL,
@@ -1877,13 +1878,12 @@ static void check_internal_node(struct super_block *s, struct buffer_head *bh,
	}
}

static int locked_or_not_in_tree(struct buffer_head *bh, char *which)
static int locked_or_not_in_tree(struct tree_balance *tb,
				  struct buffer_head *bh, char *which)
{
	if ((!buffer_journal_prepared(bh) && buffer_locked(bh)) ||
	    !B_IS_IN_TREE(bh)) {
		reiserfs_warning(NULL,
				 "vs-12339: locked_or_not_in_tree: %s (%b)",
				 which, bh);
		reiserfs_warning(tb->tb_sb, "vs-12339", "%s (%b)", which, bh);
		return 1;
	}
	return 0;
@@ -1902,18 +1902,19 @@ static int check_before_balancing(struct tree_balance *tb)
	/* double check that buffers that we will modify are unlocked. (fix_nodes should already have
	   prepped all of these for us). */
	if (tb->lnum[0]) {
		retval |= locked_or_not_in_tree(tb->L[0], "L[0]");
		retval |= locked_or_not_in_tree(tb->FL[0], "FL[0]");
		retval |= locked_or_not_in_tree(tb->CFL[0], "CFL[0]");
		retval |= locked_or_not_in_tree(tb, tb->L[0], "L[0]");
		retval |= locked_or_not_in_tree(tb, tb->FL[0], "FL[0]");
		retval |= locked_or_not_in_tree(tb, tb->CFL[0], "CFL[0]");
		check_leaf(tb->L[0]);
	}
	if (tb->rnum[0]) {
		retval |= locked_or_not_in_tree(tb->R[0], "R[0]");
		retval |= locked_or_not_in_tree(tb->FR[0], "FR[0]");
		retval |= locked_or_not_in_tree(tb->CFR[0], "CFR[0]");
		retval |= locked_or_not_in_tree(tb, tb->R[0], "R[0]");
		retval |= locked_or_not_in_tree(tb, tb->FR[0], "FR[0]");
		retval |= locked_or_not_in_tree(tb, tb->CFR[0], "CFR[0]");
		check_leaf(tb->R[0]);
	}
	retval |= locked_or_not_in_tree(PATH_PLAST_BUFFER(tb->tb_path), "S[0]");
	retval |= locked_or_not_in_tree(tb, PATH_PLAST_BUFFER(tb->tb_path),
					"S[0]");
	check_leaf(PATH_PLAST_BUFFER(tb->tb_path));

	return retval;
@@ -1952,7 +1953,7 @@ static void check_after_balance_leaf(struct tree_balance *tb)
					       PATH_H_POSITION(tb->tb_path,
							       1))));
		print_cur_tb("12223");
		reiserfs_warning(tb->tb_sb,
		reiserfs_warning(tb->tb_sb, "reiserfs-12363",
				 "B_FREE_SPACE (PATH_H_PBUFFER(tb->tb_path,0)) = %d; "
				 "MAX_CHILD_SIZE (%d) - dc_size( %y, %d ) [%d] = %d",
				 left,
@@ -2104,9 +2105,8 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
	}
	/* if we have no real work to do  */
	if (!tb->insert_size[0]) {
		reiserfs_warning(tb->tb_sb,
				 "PAP-12350: do_balance: insert_size == 0, mode == %c",
				 flag);
		reiserfs_warning(tb->tb_sb, "PAP-12350",
				 "insert_size == 0, mode == %c", flag);
		unfix_nodes(tb);
		return;
	}
+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
			 * and let the admin know what is going on.
			 */
			igrab(inode);
			reiserfs_warning(inode->i_sb,
			reiserfs_warning(inode->i_sb, "clm-9001",
					 "pinning inode %lu because the "
					 "preallocation can't be freed",
					 inode->i_ino);
+7 −7
Original line number Diff line number Diff line
@@ -496,8 +496,8 @@ static int get_num_ver(int mode, struct tree_balance *tb, int h,
		snum012[needed_nodes - 1 + 3] = units;

		if (needed_nodes > 2)
			reiserfs_warning(tb->tb_sb, "vs-8111: get_num_ver: "
					 "split_item_position is out of boundary");
			reiserfs_warning(tb->tb_sb, "vs-8111",
					 "split_item_position is out of range");
		snum012[needed_nodes - 1]++;
		split_item_positions[needed_nodes - 1] = i;
		needed_nodes++;
@@ -533,8 +533,8 @@ static int get_num_ver(int mode, struct tree_balance *tb, int h,

		if (vn->vn_vi[split_item_num].vi_index != TYPE_DIRENTRY &&
		    vn->vn_vi[split_item_num].vi_index != TYPE_INDIRECT)
			reiserfs_warning(tb->tb_sb, "vs-8115: get_num_ver: not "
					 "directory or indirect item");
			reiserfs_warning(tb->tb_sb, "vs-8115",
					 "not directory or indirect item");
	}

	/* now we know S2bytes, calculate S1bytes */
@@ -2268,9 +2268,9 @@ static int wait_tb_buffers_until_unlocked(struct tree_balance *p_s_tb)
#ifdef CONFIG_REISERFS_CHECK
			repeat_counter++;
			if ((repeat_counter % 10000) == 0) {
				reiserfs_warning(p_s_tb->tb_sb,
						 "wait_tb_buffers_until_released(): too many "
						 "iterations waiting for buffer to unlock "
				reiserfs_warning(p_s_tb->tb_sb, "reiserfs-8200",
						 "too many iterations waiting "
						 "for buffer to unlock "
						 "(%b)", locked);

				/* Don't loop forever.  Try to recover from possible error. */
+29 −31
Original line number Diff line number Diff line
@@ -842,7 +842,9 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
				if (retval) {
					if (retval != -ENOSPC)
						reiserfs_warning(inode->i_sb,
								 "clm-6004: convert tail failed inode %lu, error %d",
							 "clm-6004",
							 "convert tail failed "
							 "inode %lu, error %d",
								 inode->i_ino,
								 retval);
					if (allocated_block_nr) {
@@ -1006,8 +1008,7 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
			goto failure;
		}
		if (retval == POSITION_FOUND) {
			reiserfs_warning(inode->i_sb,
					 "vs-825: reiserfs_get_block: "
			reiserfs_warning(inode->i_sb, "vs-825",
					 "%K should not be found", &key);
			retval = -EEXIST;
			if (allocated_block_nr)
@@ -1332,9 +1333,9 @@ void reiserfs_update_sd_size(struct reiserfs_transaction_handle *th,
		/* look for the object's stat data */
		retval = search_item(inode->i_sb, &key, &path);
		if (retval == IO_ERROR) {
			reiserfs_warning(inode->i_sb,
					 "vs-13050: reiserfs_update_sd: "
					 "i/o failure occurred trying to update %K stat data",
			reiserfs_warning(inode->i_sb, "vs-13050",
					 "i/o failure occurred trying to "
					 "update %K stat data",
					 &key);
			return;
		}
@@ -1345,9 +1346,9 @@ void reiserfs_update_sd_size(struct reiserfs_transaction_handle *th,
				/*reiserfs_warning (inode->i_sb, "vs-13050: reiserfs_update_sd: i_nlink == 0, stat data not found"); */
				return;
			}
			reiserfs_warning(inode->i_sb,
					 "vs-13060: reiserfs_update_sd: "
					 "stat data of object %k (nlink == %d) not found (pos %d)",
			reiserfs_warning(inode->i_sb, "vs-13060",
					 "stat data of object %k (nlink == %d) "
					 "not found (pos %d)",
					 INODE_PKEY(inode), inode->i_nlink,
					 pos);
			reiserfs_check_path(&path);
@@ -1424,10 +1425,9 @@ void reiserfs_read_locked_inode(struct inode *inode,
	/* look for the object's stat data */
	retval = search_item(inode->i_sb, &key, &path_to_sd);
	if (retval == IO_ERROR) {
		reiserfs_warning(inode->i_sb,
				 "vs-13070: reiserfs_read_locked_inode: "
				 "i/o failure occurred trying to find stat data of %K",
				 &key);
		reiserfs_warning(inode->i_sb, "vs-13070",
				 "i/o failure occurred trying to find "
				 "stat data of %K", &key);
		reiserfs_make_bad_inode(inode);
		return;
	}
@@ -1457,8 +1457,7 @@ void reiserfs_read_locked_inode(struct inode *inode,
	   during mount (fs/reiserfs/super.c:finish_unfinished()). */
	if ((inode->i_nlink == 0) &&
	    !REISERFS_SB(inode->i_sb)->s_is_unlinked_ok) {
		reiserfs_warning(inode->i_sb,
				 "vs-13075: reiserfs_read_locked_inode: "
		reiserfs_warning(inode->i_sb, "vs-13075",
				 "dead inode read from disk %K. "
				 "This is likely to be race with knfsd. Ignore",
				 &key);
@@ -1555,7 +1554,7 @@ struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
	 */
	if (fh_type > fh_len) {
		if (fh_type != 6 || fh_len != 5)
			reiserfs_warning(sb,
			reiserfs_warning(sb, "reiserfs-13077",
				"nfsd/reiserfs, fhtype=%d, len=%d - odd",
				fh_type, fh_len);
		fh_type = 5;
@@ -1680,13 +1679,13 @@ static int reiserfs_new_directory(struct reiserfs_transaction_handle *th,
	/* look for place in the tree for new item */
	retval = search_item(sb, &key, path);
	if (retval == IO_ERROR) {
		reiserfs_warning(sb, "vs-13080: reiserfs_new_directory: "
		reiserfs_warning(sb, "vs-13080",
				 "i/o failure occurred creating new directory");
		return -EIO;
	}
	if (retval == ITEM_FOUND) {
		pathrelse(path);
		reiserfs_warning(sb, "vs-13070: reiserfs_new_directory: "
		reiserfs_warning(sb, "vs-13070",
				 "object with this key exists (%k)",
				 &(ih->ih_key));
		return -EEXIST;
@@ -1720,13 +1719,13 @@ static int reiserfs_new_symlink(struct reiserfs_transaction_handle *th, struct i
	/* look for place in the tree for new item */
	retval = search_item(sb, &key, path);
	if (retval == IO_ERROR) {
		reiserfs_warning(sb, "vs-13080: reiserfs_new_symlinik: "
		reiserfs_warning(sb, "vs-13080",
				 "i/o failure occurred creating new symlink");
		return -EIO;
	}
	if (retval == ITEM_FOUND) {
		pathrelse(path);
		reiserfs_warning(sb, "vs-13080: reiserfs_new_symlink: "
		reiserfs_warning(sb, "vs-13080",
				 "object with this key exists (%k)",
				 &(ih->ih_key));
		return -EEXIST;
@@ -1927,7 +1926,8 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
			goto out_inserted_sd;
		}
	} else if (inode->i_sb->s_flags & MS_POSIXACL) {
		reiserfs_warning(inode->i_sb, "ACLs aren't enabled in the fs, "
		reiserfs_warning(inode->i_sb, "jdm-13090",
				 "ACLs aren't enabled in the fs, "
				 "but vfs thinks they are!");
	} else if (is_reiserfs_priv_object(dir)) {
		reiserfs_mark_inode_private(inode);
@@ -2044,8 +2044,8 @@ static int grab_tail_page(struct inode *p_s_inode,
		 ** I've screwed up the code to find the buffer, or the code to
		 ** call prepare_write
		 */
		reiserfs_warning(p_s_inode->i_sb,
				 "clm-6000: error reading block %lu on dev %s",
		reiserfs_warning(p_s_inode->i_sb, "clm-6000",
				 "error reading block %lu on dev %s",
				 bh->b_blocknr,
				 reiserfs_bdevname(p_s_inode->i_sb));
		error = -EIO;
@@ -2089,8 +2089,8 @@ int reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps)
			// and get_block_create_0 could not find a block to read in,
			// which is ok.
			if (error != -ENOENT)
				reiserfs_warning(p_s_inode->i_sb,
						 "clm-6001: grab_tail_page failed %d",
				reiserfs_warning(p_s_inode->i_sb, "clm-6001",
						 "grab_tail_page failed %d",
						 error);
			page = NULL;
			bh = NULL;
@@ -2208,9 +2208,8 @@ static int map_block_for_writepage(struct inode *inode,
	/* we've found an unformatted node */
	if (indirect_item_found(retval, ih)) {
		if (bytes_copied > 0) {
			reiserfs_warning(inode->i_sb,
					 "clm-6002: bytes_copied %d",
					 bytes_copied);
			reiserfs_warning(inode->i_sb, "clm-6002",
					 "bytes_copied %d", bytes_copied);
		}
		if (!get_block_num(item, pos_in_item)) {
			/* crap, we are writing to a hole */
@@ -2267,9 +2266,8 @@ static int map_block_for_writepage(struct inode *inode,
			goto research;
		}
	} else {
		reiserfs_warning(inode->i_sb,
				 "clm-6003: bad item inode %lu, device %s",
				 inode->i_ino, reiserfs_bdevname(inode->i_sb));
		reiserfs_warning(inode->i_sb, "clm-6003",
				 "bad item inode %lu", inode->i_ino);
		retval = -EIO;
		goto out;
	}
Loading