Skip to content

Commit 862a804

Browse files
Christoph HellwigDarrick J. Wong
authored andcommitted
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: Christoph Hellwig <[email protected]> Reviewed-by: Brian Foster <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent e7a3d7e commit 862a804

File tree

8 files changed

+62
-93
lines changed

8 files changed

+62
-93
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 34 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,9 @@ xfs_iread_extents(
12271227
struct xfs_btree_cur *cur;
12281228
int error;
12291229

1230+
if (ifp->if_flags & XFS_IFEXTENTS)
1231+
return 0;
1232+
12301233
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
12311234

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

12851288
ASSERT(xfs_ifork_has_extents(ifp));
12861289

1287-
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
1288-
error = xfs_iread_extents(tp, ip, whichfork);
1289-
if (error)
1290-
return error;
1291-
}
1290+
error = xfs_iread_extents(tp, ip, whichfork);
1291+
if (error)
1292+
return error;
12921293

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

1339-
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
1340-
error = xfs_iread_extents(tp, ip, whichfork);
1341-
if (error)
1342-
return error;
1343-
}
1340+
error = xfs_iread_extents(tp, ip, whichfork);
1341+
if (error)
1342+
return error;
13441343

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

1362-
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
1363-
error = xfs_iread_extents(tp, ip, whichfork);
1364-
if (error)
1365-
return error;
1366-
}
1361+
error = xfs_iread_extents(tp, ip, whichfork);
1362+
if (error)
1363+
return error;
13671364

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

39923989
XFS_STATS_INC(mp, xs_blk_mapr);
39933990

3994-
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
3995-
error = xfs_iread_extents(NULL, ip, whichfork);
3996-
if (error)
3997-
return error;
3998-
}
3991+
error = xfs_iread_extents(NULL, ip, whichfork);
3992+
if (error)
3993+
return error;
39993994

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

44764471
XFS_STATS_INC(mp, xs_blk_mapw);
44774472

4478-
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
4479-
error = xfs_iread_extents(tp, ip, whichfork);
4480-
if (error)
4481-
goto error0;
4482-
}
4473+
error = xfs_iread_extents(tp, ip, whichfork);
4474+
if (error)
4475+
goto error0;
44834476

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

4761-
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
4762-
error = xfs_iread_extents(tp, ip, whichfork);
4763-
if (error)
4764-
return error;
4765-
}
4754+
error = xfs_iread_extents(tp, ip, whichfork);
4755+
if (error)
4756+
return error;
47664757

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

5436-
if (!(ifp->if_flags & XFS_IFEXTENTS) &&
5437-
(error = xfs_iread_extents(tp, ip, whichfork)))
5427+
error = xfs_iread_extents(tp, ip, whichfork);
5428+
if (error)
54385429
return error;
5430+
54395431
if (xfs_iext_count(ifp) == 0) {
54405432
*rlen = 0;
54415433
return 0;
@@ -5921,11 +5913,9 @@ xfs_bmap_collapse_extents(
59215913

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

5924-
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
5925-
error = xfs_iread_extents(tp, ip, whichfork);
5926-
if (error)
5927-
return error;
5928-
}
5916+
error = xfs_iread_extents(tp, ip, whichfork);
5917+
if (error)
5918+
return error;
59295919

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

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

6041-
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
6042-
error = xfs_iread_extents(tp, ip, whichfork);
6043-
if (error)
6044-
return error;
6045-
}
6031+
error = xfs_iread_extents(tp, ip, whichfork);
6032+
if (error)
6033+
return error;
60466034

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

6144-
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
6145-
/* Read in all the extents */
6146-
error = xfs_iread_extents(tp, ip, whichfork);
6147-
if (error)
6148-
return error;
6149-
}
6132+
/* Read in all the extents */
6133+
error = xfs_iread_extents(tp, ip, whichfork);
6134+
if (error)
6135+
return error;
61506136

61516137
/*
61526138
* If there are not extents, or split_fsb lies in a hole we are done.

fs/xfs/scrub/bmap.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,11 +448,10 @@ xchk_bmap_btree(
448448

449449
/* Load the incore bmap cache if it's not loaded. */
450450
info->was_loaded = ifp->if_flags & XFS_IFEXTENTS;
451-
if (!info->was_loaded) {
452-
error = xfs_iread_extents(sc->tp, ip, whichfork);
453-
if (!xchk_fblock_process_error(sc, whichfork, 0, &error))
454-
goto out;
455-
}
451+
452+
error = xfs_iread_extents(sc->tp, ip, whichfork);
453+
if (!xchk_fblock_process_error(sc, whichfork, 0, &error))
454+
goto out;
456455

457456
/* Check the btree structure. */
458457
cur = xfs_bmbt_init_cursor(mp, sc->tp, ip, whichfork);

fs/xfs/xfs_bmap_util.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,9 @@ xfs_bmap_count_blocks(
225225

226226
switch (ifp->if_format) {
227227
case XFS_DINODE_FMT_BTREE:
228-
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
229-
error = xfs_iread_extents(tp, ip, whichfork);
230-
if (error)
231-
return error;
232-
}
228+
error = xfs_iread_extents(tp, ip, whichfork);
229+
if (error)
230+
return error;
233231

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

474-
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
475-
error = xfs_iread_extents(NULL, ip, whichfork);
476-
if (error)
477-
goto out_unlock_ilock;
478-
}
472+
error = xfs_iread_extents(NULL, ip, whichfork);
473+
if (error)
474+
goto out_unlock_ilock;
479475

480476
if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) {
481477
/*

fs/xfs/xfs_dir2_readdir.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,9 @@ xfs_dir2_leaf_readbuf(
258258
int ra_want;
259259
int error = 0;
260260

261-
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
262-
error = xfs_iread_extents(args->trans, dp, XFS_DATA_FORK);
263-
if (error)
264-
goto out;
265-
}
261+
error = xfs_iread_extents(args->trans, dp, XFS_DATA_FORK);
262+
if (error)
263+
goto out;
266264

267265
/*
268266
* Look for mapped directory blocks at or above the current offset.

fs/xfs/xfs_dquot.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -748,11 +748,9 @@ xfs_dq_get_next_id(
748748
start = (xfs_fsblock_t)next_id / mp->m_quotainfo->qi_dqperchunk;
749749

750750
lock_flags = xfs_ilock_data_map_shared(quotip);
751-
if (!(quotip->i_df.if_flags & XFS_IFEXTENTS)) {
752-
error = xfs_iread_extents(NULL, quotip, XFS_DATA_FORK);
753-
if (error)
754-
return error;
755-
}
751+
error = xfs_iread_extents(NULL, quotip, XFS_DATA_FORK);
752+
if (error)
753+
return error;
756754

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

fs/xfs/xfs_iomap.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -894,11 +894,9 @@ xfs_buffered_write_iomap_begin(
894894

895895
XFS_STATS_INC(mp, xs_blk_mapw);
896896

897-
if (!(ip->i_df.if_flags & XFS_IFEXTENTS)) {
898-
error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK);
899-
if (error)
900-
goto out_unlock;
901-
}
897+
error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK);
898+
if (error)
899+
goto out_unlock;
902900

903901
/*
904902
* Search the data fork first to look up our source mapping. We
@@ -1209,11 +1207,9 @@ xfs_seek_iomap_begin(
12091207
return -EIO;
12101208

12111209
lockmode = xfs_ilock_data_map_shared(ip);
1212-
if (!(ip->i_df.if_flags & XFS_IFEXTENTS)) {
1213-
error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK);
1214-
if (error)
1215-
goto out_unlock;
1216-
}
1210+
error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK);
1211+
if (error)
1212+
goto out_unlock;
12171213

12181214
if (xfs_iext_lookup_extent(ip, &ip->i_df, offset_fsb, &icur, &imap)) {
12191215
/*

fs/xfs/xfs_qm.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,11 +1165,9 @@ xfs_qm_dqusage_adjust(
11651165
if (XFS_IS_REALTIME_INODE(ip)) {
11661166
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
11671167

1168-
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
1169-
error = xfs_iread_extents(tp, ip, XFS_DATA_FORK);
1170-
if (error)
1171-
goto error0;
1172-
}
1168+
error = xfs_iread_extents(tp, ip, XFS_DATA_FORK);
1169+
if (error)
1170+
goto error0;
11731171

11741172
xfs_bmap_count_leaves(ifp, &rtblks);
11751173
}

fs/xfs/xfs_reflink.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,11 +1392,9 @@ xfs_reflink_inode_has_shared_extents(
13921392
int error;
13931393

13941394
ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
1395-
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
1396-
error = xfs_iread_extents(tp, ip, XFS_DATA_FORK);
1397-
if (error)
1398-
return error;
1399-
}
1395+
error = xfs_iread_extents(tp, ip, XFS_DATA_FORK);
1396+
if (error)
1397+
return error;
14001398

14011399
*has_shared = false;
14021400
found = xfs_iext_lookup_extent(ip, ifp, 0, &icur, &got);

0 commit comments

Comments
 (0)