Commit 862a804a authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong
Browse files

xfs: move the XFS_IFEXTENTS check into xfs_iread_extents



Move the XFS_IFEXTENTS check from the callers into xfs_iread_extents to
simplify the code.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent e7a3d7e7
Loading
Loading
Loading
Loading
+34 −48
Original line number Diff line number Diff line
@@ -1227,6 +1227,9 @@ xfs_iread_extents(
	struct xfs_btree_cur	*cur;
	int			error;

	if (ifp->if_flags & XFS_IFEXTENTS)
		return 0;

	ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));

	if (XFS_IS_CORRUPT(mp, ifp->if_format != XFS_DINODE_FMT_BTREE)) {
@@ -1284,11 +1287,9 @@ xfs_bmap_first_unused(

	ASSERT(xfs_ifork_has_extents(ifp));

	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
	error = xfs_iread_extents(tp, ip, whichfork);
	if (error)
		return error;
	}

	lowest = max = *first_unused;
	for_each_xfs_iext(ifp, &icur, &got) {
@@ -1336,11 +1337,9 @@ xfs_bmap_last_before(
		return -EFSCORRUPTED;
	}

	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
	error = xfs_iread_extents(tp, ip, whichfork);
	if (error)
		return error;
	}

	if (!xfs_iext_lookup_extent_before(ip, ifp, last_block, &icur, &got))
		*last_block = 0;
@@ -1359,11 +1358,9 @@ xfs_bmap_last_extent(
	struct xfs_iext_cursor	icur;
	int			error;

	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
	error = xfs_iread_extents(tp, ip, whichfork);
	if (error)
		return error;
	}

	xfs_iext_last(ifp, &icur);
	if (!xfs_iext_get_extent(ifp, &icur, rec))
@@ -3991,11 +3988,9 @@ xfs_bmapi_read(

	XFS_STATS_INC(mp, xs_blk_mapr);

	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
	error = xfs_iread_extents(NULL, ip, whichfork);
	if (error)
		return error;
	}

	if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got))
		eof = true;
@@ -4475,11 +4470,9 @@ xfs_bmapi_write(

	XFS_STATS_INC(mp, xs_blk_mapw);

	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
	error = xfs_iread_extents(tp, ip, whichfork);
	if (error)
		goto error0;
	}

	if (!xfs_iext_lookup_extent(ip, ifp, bno, &bma.icur, &bma.got))
		eof = true;
@@ -4758,11 +4751,9 @@ xfs_bmapi_remap(
	if (XFS_FORCED_SHUTDOWN(mp))
		return -EIO;

	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
	error = xfs_iread_extents(tp, ip, whichfork);
	if (error)
		return error;
	}

	if (xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) {
		/* make sure we only reflink into a hole. */
@@ -5433,9 +5424,10 @@ __xfs_bunmapi(
	else
		max_len = len;

	if (!(ifp->if_flags & XFS_IFEXTENTS) &&
	    (error = xfs_iread_extents(tp, ip, whichfork)))
	error = xfs_iread_extents(tp, ip, whichfork);
	if (error)
		return error;

	if (xfs_iext_count(ifp) == 0) {
		*rlen = 0;
		return 0;
@@ -5921,11 +5913,9 @@ xfs_bmap_collapse_extents(

	ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL));

	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
	error = xfs_iread_extents(tp, ip, whichfork);
	if (error)
		return error;
	}

	if (ifp->if_flags & XFS_IFBROOT) {
		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
@@ -6038,11 +6028,9 @@ xfs_bmap_insert_extents(

	ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL));

	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
	error = xfs_iread_extents(tp, ip, whichfork);
	if (error)
		return error;
	}

	if (ifp->if_flags & XFS_IFBROOT) {
		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
@@ -6141,12 +6129,10 @@ xfs_bmap_split_extent(
	if (XFS_FORCED_SHUTDOWN(mp))
		return -EIO;

	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
	/* Read in all the extents */
	error = xfs_iread_extents(tp, ip, whichfork);
	if (error)
		return error;
	}

	/*
	 * If there are not extents, or split_fsb lies in a hole we are done.
+4 −5
Original line number Diff line number Diff line
@@ -448,11 +448,10 @@ xchk_bmap_btree(

	/* Load the incore bmap cache if it's not loaded. */
	info->was_loaded = ifp->if_flags & XFS_IFEXTENTS;
	if (!info->was_loaded) {

	error = xfs_iread_extents(sc->tp, ip, whichfork);
	if (!xchk_fblock_process_error(sc, whichfork, 0, &error))
		goto out;
	}

	/* Check the btree structure. */
	cur = xfs_bmbt_init_cursor(mp, sc->tp, ip, whichfork);
+6 −10
Original line number Diff line number Diff line
@@ -225,11 +225,9 @@ xfs_bmap_count_blocks(

	switch (ifp->if_format) {
	case XFS_DINODE_FMT_BTREE:
		if (!(ifp->if_flags & XFS_IFEXTENTS)) {
		error = xfs_iread_extents(tp, ip, whichfork);
		if (error)
			return error;
		}

		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
		error = xfs_btree_count_blocks(cur, &btblocks);
@@ -471,11 +469,9 @@ xfs_getbmap(
	first_bno = bno = XFS_BB_TO_FSBT(mp, bmv->bmv_offset);
	len = XFS_BB_TO_FSB(mp, bmv->bmv_length);

	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
	error = xfs_iread_extents(NULL, ip, whichfork);
	if (error)
		goto out_unlock_ilock;
	}

	if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) {
		/*
+3 −5
Original line number Diff line number Diff line
@@ -258,11 +258,9 @@ xfs_dir2_leaf_readbuf(
	int			ra_want;
	int			error = 0;

	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
	error = xfs_iread_extents(args->trans, dp, XFS_DATA_FORK);
	if (error)
		goto out;
	}

	/*
	 * Look for mapped directory blocks at or above the current offset.
+3 −5
Original line number Diff line number Diff line
@@ -748,11 +748,9 @@ xfs_dq_get_next_id(
	start = (xfs_fsblock_t)next_id / mp->m_quotainfo->qi_dqperchunk;

	lock_flags = xfs_ilock_data_map_shared(quotip);
	if (!(quotip->i_df.if_flags & XFS_IFEXTENTS)) {
	error = xfs_iread_extents(NULL, quotip, XFS_DATA_FORK);
	if (error)
		return error;
	}

	if (xfs_iext_lookup_extent(quotip, &quotip->i_df, start, &cur, &got)) {
		/* contiguous chunk, bump startoff for the id calculation */
Loading