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

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
...@@ -1227,6 +1227,9 @@ xfs_iread_extents( ...@@ -1227,6 +1227,9 @@ xfs_iread_extents(
struct xfs_btree_cur *cur; struct xfs_btree_cur *cur;
int error; int error;
if (ifp->if_flags & XFS_IFEXTENTS)
return 0;
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
if (XFS_IS_CORRUPT(mp, ifp->if_format != XFS_DINODE_FMT_BTREE)) { if (XFS_IS_CORRUPT(mp, ifp->if_format != XFS_DINODE_FMT_BTREE)) {
...@@ -1284,11 +1287,9 @@ xfs_bmap_first_unused( ...@@ -1284,11 +1287,9 @@ xfs_bmap_first_unused(
ASSERT(xfs_ifork_has_extents(ifp)); ASSERT(xfs_ifork_has_extents(ifp));
if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(tp, ip, whichfork);
error = xfs_iread_extents(tp, ip, whichfork); if (error)
if (error) return error;
return error;
}
lowest = max = *first_unused; lowest = max = *first_unused;
for_each_xfs_iext(ifp, &icur, &got) { for_each_xfs_iext(ifp, &icur, &got) {
...@@ -1336,11 +1337,9 @@ xfs_bmap_last_before( ...@@ -1336,11 +1337,9 @@ xfs_bmap_last_before(
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(tp, ip, whichfork);
error = xfs_iread_extents(tp, ip, whichfork); if (error)
if (error) return error;
return error;
}
if (!xfs_iext_lookup_extent_before(ip, ifp, last_block, &icur, &got)) if (!xfs_iext_lookup_extent_before(ip, ifp, last_block, &icur, &got))
*last_block = 0; *last_block = 0;
...@@ -1359,11 +1358,9 @@ xfs_bmap_last_extent( ...@@ -1359,11 +1358,9 @@ xfs_bmap_last_extent(
struct xfs_iext_cursor icur; struct xfs_iext_cursor icur;
int error; int error;
if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(tp, ip, whichfork);
error = xfs_iread_extents(tp, ip, whichfork); if (error)
if (error) return error;
return error;
}
xfs_iext_last(ifp, &icur); xfs_iext_last(ifp, &icur);
if (!xfs_iext_get_extent(ifp, &icur, rec)) if (!xfs_iext_get_extent(ifp, &icur, rec))
...@@ -3991,11 +3988,9 @@ xfs_bmapi_read( ...@@ -3991,11 +3988,9 @@ xfs_bmapi_read(
XFS_STATS_INC(mp, xs_blk_mapr); XFS_STATS_INC(mp, xs_blk_mapr);
if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(NULL, ip, whichfork);
error = xfs_iread_extents(NULL, ip, whichfork); if (error)
if (error) return error;
return error;
}
if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got))
eof = true; eof = true;
...@@ -4475,11 +4470,9 @@ xfs_bmapi_write( ...@@ -4475,11 +4470,9 @@ xfs_bmapi_write(
XFS_STATS_INC(mp, xs_blk_mapw); XFS_STATS_INC(mp, xs_blk_mapw);
if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(tp, ip, whichfork);
error = xfs_iread_extents(tp, ip, whichfork); if (error)
if (error) goto error0;
goto error0;
}
if (!xfs_iext_lookup_extent(ip, ifp, bno, &bma.icur, &bma.got)) if (!xfs_iext_lookup_extent(ip, ifp, bno, &bma.icur, &bma.got))
eof = true; eof = true;
...@@ -4758,11 +4751,9 @@ xfs_bmapi_remap( ...@@ -4758,11 +4751,9 @@ xfs_bmapi_remap(
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return -EIO; return -EIO;
if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(tp, ip, whichfork);
error = xfs_iread_extents(tp, ip, whichfork); if (error)
if (error) return error;
return error;
}
if (xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) { if (xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) {
/* make sure we only reflink into a hole. */ /* make sure we only reflink into a hole. */
...@@ -5433,9 +5424,10 @@ __xfs_bunmapi( ...@@ -5433,9 +5424,10 @@ __xfs_bunmapi(
else else
max_len = len; 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; return error;
if (xfs_iext_count(ifp) == 0) { if (xfs_iext_count(ifp) == 0) {
*rlen = 0; *rlen = 0;
return 0; return 0;
...@@ -5921,11 +5913,9 @@ xfs_bmap_collapse_extents( ...@@ -5921,11 +5913,9 @@ xfs_bmap_collapse_extents(
ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL)); ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL));
if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(tp, ip, whichfork);
error = xfs_iread_extents(tp, ip, whichfork); if (error)
if (error) return error;
return error;
}
if (ifp->if_flags & XFS_IFBROOT) { if (ifp->if_flags & XFS_IFBROOT) {
cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
...@@ -6038,11 +6028,9 @@ xfs_bmap_insert_extents( ...@@ -6038,11 +6028,9 @@ xfs_bmap_insert_extents(
ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL)); ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL));
if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(tp, ip, whichfork);
error = xfs_iread_extents(tp, ip, whichfork); if (error)
if (error) return error;
return error;
}
if (ifp->if_flags & XFS_IFBROOT) { if (ifp->if_flags & XFS_IFBROOT) {
cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
...@@ -6141,12 +6129,10 @@ xfs_bmap_split_extent( ...@@ -6141,12 +6129,10 @@ xfs_bmap_split_extent(
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return -EIO; return -EIO;
if (!(ifp->if_flags & XFS_IFEXTENTS)) { /* Read in all the extents */
/* Read in all the extents */ error = xfs_iread_extents(tp, ip, whichfork);
error = xfs_iread_extents(tp, ip, whichfork); if (error)
if (error) return error;
return error;
}
/* /*
* If there are not extents, or split_fsb lies in a hole we are done. * If there are not extents, or split_fsb lies in a hole we are done.
......
...@@ -448,11 +448,10 @@ xchk_bmap_btree( ...@@ -448,11 +448,10 @@ xchk_bmap_btree(
/* Load the incore bmap cache if it's not loaded. */ /* Load the incore bmap cache if it's not loaded. */
info->was_loaded = ifp->if_flags & XFS_IFEXTENTS; info->was_loaded = ifp->if_flags & XFS_IFEXTENTS;
if (!info->was_loaded) {
error = xfs_iread_extents(sc->tp, ip, whichfork); error = xfs_iread_extents(sc->tp, ip, whichfork);
if (!xchk_fblock_process_error(sc, whichfork, 0, &error)) if (!xchk_fblock_process_error(sc, whichfork, 0, &error))
goto out; goto out;
}
/* Check the btree structure. */ /* Check the btree structure. */
cur = xfs_bmbt_init_cursor(mp, sc->tp, ip, whichfork); cur = xfs_bmbt_init_cursor(mp, sc->tp, ip, whichfork);
......
...@@ -225,11 +225,9 @@ xfs_bmap_count_blocks( ...@@ -225,11 +225,9 @@ xfs_bmap_count_blocks(
switch (ifp->if_format) { switch (ifp->if_format) {
case XFS_DINODE_FMT_BTREE: case XFS_DINODE_FMT_BTREE:
if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(tp, ip, whichfork);
error = xfs_iread_extents(tp, ip, whichfork); if (error)
if (error) return error;
return error;
}
cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
error = xfs_btree_count_blocks(cur, &btblocks); error = xfs_btree_count_blocks(cur, &btblocks);
...@@ -471,11 +469,9 @@ xfs_getbmap( ...@@ -471,11 +469,9 @@ xfs_getbmap(
first_bno = bno = XFS_BB_TO_FSBT(mp, bmv->bmv_offset); first_bno = bno = XFS_BB_TO_FSBT(mp, bmv->bmv_offset);
len = XFS_BB_TO_FSB(mp, bmv->bmv_length); len = XFS_BB_TO_FSB(mp, bmv->bmv_length);
if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(NULL, ip, whichfork);
error = xfs_iread_extents(NULL, ip, whichfork); if (error)
if (error) goto out_unlock_ilock;
goto out_unlock_ilock;
}
if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) { if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) {
/* /*
......
...@@ -258,11 +258,9 @@ xfs_dir2_leaf_readbuf( ...@@ -258,11 +258,9 @@ xfs_dir2_leaf_readbuf(
int ra_want; int ra_want;
int error = 0; int error = 0;
if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(args->trans, dp, XFS_DATA_FORK);
error = xfs_iread_extents(args->trans, dp, XFS_DATA_FORK); if (error)
if (error) goto out;
goto out;
}
/* /*
* Look for mapped directory blocks at or above the current offset. * Look for mapped directory blocks at or above the current offset.
......
...@@ -748,11 +748,9 @@ xfs_dq_get_next_id( ...@@ -748,11 +748,9 @@ xfs_dq_get_next_id(
start = (xfs_fsblock_t)next_id / mp->m_quotainfo->qi_dqperchunk; start = (xfs_fsblock_t)next_id / mp->m_quotainfo->qi_dqperchunk;
lock_flags = xfs_ilock_data_map_shared(quotip); 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);
error = xfs_iread_extents(NULL, quotip, XFS_DATA_FORK); if (error)
if (error) return error;
return error;
}
if (xfs_iext_lookup_extent(quotip, &quotip->i_df, start, &cur, &got)) { if (xfs_iext_lookup_extent(quotip, &quotip->i_df, start, &cur, &got)) {
/* contiguous chunk, bump startoff for the id calculation */ /* contiguous chunk, bump startoff for the id calculation */
......
...@@ -894,11 +894,9 @@ xfs_buffered_write_iomap_begin( ...@@ -894,11 +894,9 @@ xfs_buffered_write_iomap_begin(
XFS_STATS_INC(mp, xs_blk_mapw); XFS_STATS_INC(mp, xs_blk_mapw);
if (!(ip->i_df.if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK);
error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK); if (error)
if (error) goto out_unlock;
goto out_unlock;
}
/* /*
* Search the data fork first to look up our source mapping. We * Search the data fork first to look up our source mapping. We
...@@ -1209,11 +1207,9 @@ xfs_seek_iomap_begin( ...@@ -1209,11 +1207,9 @@ xfs_seek_iomap_begin(
return -EIO; return -EIO;
lockmode = xfs_ilock_data_map_shared(ip); lockmode = xfs_ilock_data_map_shared(ip);
if (!(ip->i_df.if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK);
error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK); if (error)
if (error) goto out_unlock;
goto out_unlock;
}
if (xfs_iext_lookup_extent(ip, &ip->i_df, offset_fsb, &icur, &imap)) { if (xfs_iext_lookup_extent(ip, &ip->i_df, offset_fsb, &icur, &imap)) {
/* /*
......
...@@ -1165,11 +1165,9 @@ xfs_qm_dqusage_adjust( ...@@ -1165,11 +1165,9 @@ xfs_qm_dqusage_adjust(
if (XFS_IS_REALTIME_INODE(ip)) { if (XFS_IS_REALTIME_INODE(ip)) {
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(tp, ip, XFS_DATA_FORK);
error = xfs_iread_extents(tp, ip, XFS_DATA_FORK); if (error)
if (error) goto error0;
goto error0;
}
xfs_bmap_count_leaves(ifp, &rtblks); xfs_bmap_count_leaves(ifp, &rtblks);
} }
......
...@@ -1392,11 +1392,9 @@ xfs_reflink_inode_has_shared_extents( ...@@ -1392,11 +1392,9 @@ xfs_reflink_inode_has_shared_extents(
int error; int error;
ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(tp, ip, XFS_DATA_FORK);
error = xfs_iread_extents(tp, ip, XFS_DATA_FORK); if (error)
if (error) return error;
return error;
}
*has_shared = false; *has_shared = false;
found = xfs_iext_lookup_extent(ip, ifp, 0, &icur, &got); found = xfs_iext_lookup_extent(ip, ifp, 0, &icur, &got);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment