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

Commit ad9759d4 authored by Darrick J. Wong's avatar Darrick J. Wong Committed by Greg Kroah-Hartman
Browse files

xfs: always log corruption errors



commit a5155b870d687de1a5f07e774b49b1e8ef0f6f50 upstream.

Make sure we log something to dmesg whenever we return -EFSCORRUPTED up
the call stack.

Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarCarlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarChandan Babu R <chandan.babu@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0336599b
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -684,8 +684,10 @@ xfs_alloc_update_counters(

	xfs_trans_agblocks_delta(tp, len);
	if (unlikely(be32_to_cpu(agf->agf_freeblks) >
		     be32_to_cpu(agf->agf_length)))
		     be32_to_cpu(agf->agf_length))) {
		xfs_buf_corruption_error(agbp);
		return -EFSCORRUPTED;
	}

	xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS);
	return 0;
@@ -751,6 +753,7 @@ xfs_alloc_ag_vextent_small(

		bp = xfs_btree_get_bufs(args->mp, args->tp, args->agno, fbno);
		if (!bp) {
			XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, args->mp);
			error = -EFSCORRUPTED;
			goto error;
		}
@@ -2087,8 +2090,10 @@ xfs_free_agfl_block(
		return error;

	bp = xfs_btree_get_bufs(tp->t_mountp, tp, agno, agbno);
	if (!bp)
	if (!bp) {
		XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, tp->t_mountp);
		return -EFSCORRUPTED;
	}
	xfs_trans_binval(tp, bp);

	return 0;
+9 −3
Original line number Diff line number Diff line
@@ -2287,8 +2287,10 @@ xfs_attr3_leaf_lookup_int(
	leaf = bp->b_addr;
	xfs_attr3_leaf_hdr_from_disk(args->geo, &ichdr, leaf);
	entries = xfs_attr3_leaf_entryp(leaf);
	if (ichdr.count >= args->geo->blksize / 8)
	if (ichdr.count >= args->geo->blksize / 8) {
		xfs_buf_corruption_error(bp);
		return -EFSCORRUPTED;
	}

	/*
	 * Binary search.  (note: small blocks will skip this loop)
@@ -2304,10 +2306,14 @@ xfs_attr3_leaf_lookup_int(
		else
			break;
	}
	if (!(probe >= 0 && (!ichdr.count || probe < ichdr.count)))
	if (!(probe >= 0 && (!ichdr.count || probe < ichdr.count))) {
		xfs_buf_corruption_error(bp);
		return -EFSCORRUPTED;
	if (!(span <= 4 || be32_to_cpu(entry->hashval) == hashval))
	}
	if (!(span <= 4 || be32_to_cpu(entry->hashval) == hashval)) {
		xfs_buf_corruption_error(bp);
		return -EFSCORRUPTED;
	}

	/*
	 * Since we may have duplicate hashval's, find the first matching
+7 −1
Original line number Diff line number Diff line
@@ -729,6 +729,7 @@ xfs_bmap_extents_to_btree(
	xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L);
	abp = xfs_btree_get_bufl(mp, tp, args.fsbno);
	if (!abp) {
		XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
		error = -EFSCORRUPTED;
		goto out_unreserve_dquot;
	}
@@ -1084,6 +1085,7 @@ xfs_bmap_add_attrfork(
	if (XFS_IFORK_Q(ip))
		goto trans_cancel;
	if (ip->i_d.di_anextents != 0) {
		XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
		error = -EFSCORRUPTED;
		goto trans_cancel;
	}
@@ -1374,6 +1376,7 @@ xfs_bmap_last_before(
	case XFS_DINODE_FMT_EXTENTS:
		break;
	default:
		ASSERT(0);
		return -EFSCORRUPTED;
	}

@@ -1474,8 +1477,10 @@ xfs_bmap_last_offset(
		return 0;

	if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE &&
	    XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS)
	    XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS) {
		ASSERT(0);
		return -EFSCORRUPTED;
	}

	error = xfs_bmap_last_extent(NULL, ip, whichfork, &rec, &is_empty);
	if (error || is_empty)
@@ -5872,6 +5877,7 @@ xfs_bmap_insert_extents(
				del_cursor);

	if (stop_fsb >= got.br_startoff + got.br_blockcount) {
		ASSERT(0);
		error = -EFSCORRUPTED;
		goto del_cursor;
	}
+4 −1
Original line number Diff line number Diff line
@@ -1820,6 +1820,7 @@ xfs_btree_lookup_get_block(

out_bad:
	*blkp = NULL;
	xfs_buf_corruption_error(bp);
	xfs_trans_brelse(cur->bc_tp, bp);
	return -EFSCORRUPTED;
}
@@ -1867,8 +1868,10 @@ xfs_btree_lookup(
	XFS_BTREE_STATS_INC(cur, lookup);

	/* No such thing as a zero-level tree. */
	if (cur->bc_nlevels == 0)
	if (cur->bc_nlevels == 0) {
		XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, cur->bc_mp);
		return -EFSCORRUPTED;
	}

	block = NULL;
	keyno = 0;
+18 −6
Original line number Diff line number Diff line
@@ -504,6 +504,7 @@ xfs_da3_split(
	node = oldblk->bp->b_addr;
	if (node->hdr.info.forw) {
		if (be32_to_cpu(node->hdr.info.forw) != addblk->blkno) {
			xfs_buf_corruption_error(oldblk->bp);
			error = -EFSCORRUPTED;
			goto out;
		}
@@ -516,6 +517,7 @@ xfs_da3_split(
	node = oldblk->bp->b_addr;
	if (node->hdr.info.back) {
		if (be32_to_cpu(node->hdr.info.back) != addblk->blkno) {
			xfs_buf_corruption_error(oldblk->bp);
			error = -EFSCORRUPTED;
			goto out;
		}
@@ -1541,8 +1543,10 @@ xfs_da3_node_lookup_int(
			break;
		}

		if (magic != XFS_DA_NODE_MAGIC && magic != XFS_DA3_NODE_MAGIC)
		if (magic != XFS_DA_NODE_MAGIC && magic != XFS_DA3_NODE_MAGIC) {
			xfs_buf_corruption_error(blk->bp);
			return -EFSCORRUPTED;
		}

		blk->magic = XFS_DA_NODE_MAGIC;

@@ -1554,15 +1558,18 @@ xfs_da3_node_lookup_int(
		btree = dp->d_ops->node_tree_p(node);

		/* Tree taller than we can handle; bail out! */
		if (nodehdr.level >= XFS_DA_NODE_MAXDEPTH)
		if (nodehdr.level >= XFS_DA_NODE_MAXDEPTH) {
			xfs_buf_corruption_error(blk->bp);
			return -EFSCORRUPTED;
		}

		/* Check the level from the root. */
		if (blkno == args->geo->leafblk)
			expected_level = nodehdr.level - 1;
		else if (expected_level != nodehdr.level)
		else if (expected_level != nodehdr.level) {
			xfs_buf_corruption_error(blk->bp);
			return -EFSCORRUPTED;
		else
		} else
			expected_level--;

		max = nodehdr.count;
@@ -1612,12 +1619,17 @@ xfs_da3_node_lookup_int(
		}

		/* We can't point back to the root. */
		if (blkno == args->geo->leafblk)
		if (blkno == args->geo->leafblk) {
			XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW,
					dp->i_mount);
			return -EFSCORRUPTED;
		}
	}

	if (expected_level != 0)
	if (expected_level != 0) {
		XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, dp->i_mount);
		return -EFSCORRUPTED;
	}

	/*
	 * A leaf block that ends in the hashval that we are interested in
Loading