Skip to content

Commit 732436e

Browse files
author
Darrick J. Wong
committed
xfs: convert XFS_IFORK_PTR to a static inline helper
We're about to make this logic do a bit more, so convert the macro to a static inline function for better typechecking and fewer shouty macros. No functional changes here. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 0f38063 commit 732436e

23 files changed

Lines changed: 95 additions & 83 deletions

fs/xfs/libxfs/xfs_attr_leaf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ xfs_attr_shortform_verify(
10561056
int64_t size;
10571057

10581058
ASSERT(ip->i_afp->if_format == XFS_DINODE_FMT_LOCAL);
1059-
ifp = XFS_IFORK_PTR(ip, XFS_ATTR_FORK);
1059+
ifp = xfs_ifork_ptr(ip, XFS_ATTR_FORK);
10601060
sfp = (struct xfs_attr_shortform *)ifp->if_u1.if_data;
10611061
size = ifp->if_bytes;
10621062

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ xfs_bmbt_lookup_first(
128128
*/
129129
static inline bool xfs_bmap_needs_btree(struct xfs_inode *ip, int whichfork)
130130
{
131-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
131+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
132132

133133
return whichfork != XFS_COW_FORK &&
134134
ifp->if_format == XFS_DINODE_FMT_EXTENTS &&
@@ -140,7 +140,7 @@ static inline bool xfs_bmap_needs_btree(struct xfs_inode *ip, int whichfork)
140140
*/
141141
static inline bool xfs_bmap_wants_extents(struct xfs_inode *ip, int whichfork)
142142
{
143-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
143+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
144144

145145
return whichfork != XFS_COW_FORK &&
146146
ifp->if_format == XFS_DINODE_FMT_BTREE &&
@@ -319,7 +319,7 @@ xfs_bmap_check_leaf_extents(
319319
int whichfork) /* data or attr fork */
320320
{
321321
struct xfs_mount *mp = ip->i_mount;
322-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
322+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
323323
struct xfs_btree_block *block; /* current btree block */
324324
xfs_fsblock_t bno; /* block # of "block" */
325325
struct xfs_buf *bp; /* buffer for "block" */
@@ -538,7 +538,7 @@ xfs_bmap_btree_to_extents(
538538
int *logflagsp, /* inode logging flags */
539539
int whichfork) /* data or attr fork */
540540
{
541-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
541+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
542542
struct xfs_mount *mp = ip->i_mount;
543543
struct xfs_btree_block *rblock = ifp->if_broot;
544544
struct xfs_btree_block *cblock;/* child btree block */
@@ -616,7 +616,7 @@ xfs_bmap_extents_to_btree(
616616

617617
mp = ip->i_mount;
618618
ASSERT(whichfork != XFS_COW_FORK);
619-
ifp = XFS_IFORK_PTR(ip, whichfork);
619+
ifp = xfs_ifork_ptr(ip, whichfork);
620620
ASSERT(ifp->if_format == XFS_DINODE_FMT_EXTENTS);
621621

622622
/*
@@ -745,7 +745,7 @@ xfs_bmap_local_to_extents_empty(
745745
struct xfs_inode *ip,
746746
int whichfork)
747747
{
748-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
748+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
749749

750750
ASSERT(whichfork != XFS_COW_FORK);
751751
ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL);
@@ -785,7 +785,7 @@ xfs_bmap_local_to_extents(
785785
* So sending the data fork of a regular inode is invalid.
786786
*/
787787
ASSERT(!(S_ISREG(VFS_I(ip)->i_mode) && whichfork == XFS_DATA_FORK));
788-
ifp = XFS_IFORK_PTR(ip, whichfork);
788+
ifp = xfs_ifork_ptr(ip, whichfork);
789789
ASSERT(ifp->if_format == XFS_DINODE_FMT_LOCAL);
790790

791791
if (!ifp->if_bytes) {
@@ -1116,7 +1116,7 @@ xfs_iread_bmbt_block(
11161116
xfs_extnum_t num_recs;
11171117
xfs_extnum_t j;
11181118
int whichfork = cur->bc_ino.whichfork;
1119-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
1119+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
11201120

11211121
block = xfs_btree_get_block(cur, level, &bp);
11221122

@@ -1164,7 +1164,7 @@ xfs_iread_extents(
11641164
int whichfork)
11651165
{
11661166
struct xfs_iread_state ir;
1167-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
1167+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
11681168
struct xfs_mount *mp = ip->i_mount;
11691169
struct xfs_btree_cur *cur;
11701170
int error;
@@ -1208,7 +1208,7 @@ xfs_bmap_first_unused(
12081208
xfs_fileoff_t *first_unused, /* unused block */
12091209
int whichfork) /* data or attr fork */
12101210
{
1211-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
1211+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
12121212
struct xfs_bmbt_irec got;
12131213
struct xfs_iext_cursor icur;
12141214
xfs_fileoff_t lastaddr = 0;
@@ -1255,7 +1255,7 @@ xfs_bmap_last_before(
12551255
xfs_fileoff_t *last_block, /* last block */
12561256
int whichfork) /* data or attr fork */
12571257
{
1258-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
1258+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
12591259
struct xfs_bmbt_irec got;
12601260
struct xfs_iext_cursor icur;
12611261
int error;
@@ -1289,7 +1289,7 @@ xfs_bmap_last_extent(
12891289
struct xfs_bmbt_irec *rec,
12901290
int *is_empty)
12911291
{
1292-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
1292+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
12931293
struct xfs_iext_cursor icur;
12941294
int error;
12951295

@@ -1355,7 +1355,7 @@ xfs_bmap_last_offset(
13551355
xfs_fileoff_t *last_block,
13561356
int whichfork)
13571357
{
1358-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
1358+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
13591359
struct xfs_bmbt_irec rec;
13601360
int is_empty;
13611361
int error;
@@ -1389,7 +1389,7 @@ xfs_bmap_add_extent_delay_real(
13891389
int whichfork)
13901390
{
13911391
struct xfs_mount *mp = bma->ip->i_mount;
1392-
struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork);
1392+
struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork);
13931393
struct xfs_bmbt_irec *new = &bma->got;
13941394
int error; /* error return value */
13951395
int i; /* temp state */
@@ -1955,7 +1955,7 @@ xfs_bmap_add_extent_unwritten_real(
19551955
*logflagsp = 0;
19561956

19571957
cur = *curp;
1958-
ifp = XFS_IFORK_PTR(ip, whichfork);
1958+
ifp = xfs_ifork_ptr(ip, whichfork);
19591959

19601960
ASSERT(!isnullstartblock(new->br_startblock));
19611961

@@ -2480,7 +2480,7 @@ xfs_bmap_add_extent_hole_delay(
24802480
uint32_t state = xfs_bmap_fork_to_state(whichfork);
24812481
xfs_filblks_t temp; /* temp for indirect calculations */
24822482

2483-
ifp = XFS_IFORK_PTR(ip, whichfork);
2483+
ifp = xfs_ifork_ptr(ip, whichfork);
24842484
ASSERT(isnullstartblock(new->br_startblock));
24852485

24862486
/*
@@ -2616,7 +2616,7 @@ xfs_bmap_add_extent_hole_real(
26162616
int *logflagsp,
26172617
uint32_t flags)
26182618
{
2619-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
2619+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
26202620
struct xfs_mount *mp = ip->i_mount;
26212621
struct xfs_btree_cur *cur = *curp;
26222622
int error; /* error return value */
@@ -3867,7 +3867,7 @@ xfs_bmapi_read(
38673867
{
38683868
struct xfs_mount *mp = ip->i_mount;
38693869
int whichfork = xfs_bmapi_whichfork(flags);
3870-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
3870+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
38713871
struct xfs_bmbt_irec got;
38723872
xfs_fileoff_t obno;
38733873
xfs_fileoff_t end;
@@ -3960,7 +3960,7 @@ xfs_bmapi_reserve_delalloc(
39603960
int eof)
39613961
{
39623962
struct xfs_mount *mp = ip->i_mount;
3963-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
3963+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
39643964
xfs_extlen_t alen;
39653965
xfs_extlen_t indlen;
39663966
int error;
@@ -4087,7 +4087,7 @@ xfs_bmapi_allocate(
40874087
{
40884088
struct xfs_mount *mp = bma->ip->i_mount;
40894089
int whichfork = xfs_bmapi_whichfork(bma->flags);
4090-
struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork);
4090+
struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork);
40914091
int tmp_logflags = 0;
40924092
int error;
40934093

@@ -4186,7 +4186,7 @@ xfs_bmapi_convert_unwritten(
41864186
uint32_t flags)
41874187
{
41884188
int whichfork = xfs_bmapi_whichfork(flags);
4189-
struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork);
4189+
struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork);
41904190
int tmp_logflags = 0;
41914191
int error;
41924192

@@ -4263,7 +4263,7 @@ xfs_bmapi_minleft(
42634263
struct xfs_inode *ip,
42644264
int fork)
42654265
{
4266-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, fork);
4266+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, fork);
42674267

42684268
if (tp && tp->t_firstblock != NULLFSBLOCK)
42694269
return 0;
@@ -4284,7 +4284,7 @@ xfs_bmapi_finish(
42844284
int whichfork,
42854285
int error)
42864286
{
4287-
struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork);
4287+
struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork);
42884288

42894289
if ((bma->logflags & xfs_ilog_fext(whichfork)) &&
42904290
ifp->if_format != XFS_DINODE_FMT_EXTENTS)
@@ -4323,7 +4323,7 @@ xfs_bmapi_write(
43234323
};
43244324
struct xfs_mount *mp = ip->i_mount;
43254325
int whichfork = xfs_bmapi_whichfork(flags);
4326-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
4326+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
43274327
xfs_fileoff_t end; /* end of mapped file region */
43284328
bool eof = false; /* after the end of extents */
43294329
int error; /* error return */
@@ -4504,7 +4504,7 @@ xfs_bmapi_convert_delalloc(
45044504
struct iomap *iomap,
45054505
unsigned int *seq)
45064506
{
4507-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
4507+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
45084508
struct xfs_mount *mp = ip->i_mount;
45094509
xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset);
45104510
struct xfs_bmalloca bma = { NULL };
@@ -4641,7 +4641,7 @@ xfs_bmapi_remap(
46414641
int whichfork = xfs_bmapi_whichfork(flags);
46424642
int logflags = 0, error;
46434643

4644-
ifp = XFS_IFORK_PTR(ip, whichfork);
4644+
ifp = xfs_ifork_ptr(ip, whichfork);
46454645
ASSERT(len > 0);
46464646
ASSERT(len <= (xfs_filblks_t)XFS_MAX_BMBT_EXTLEN);
46474647
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
@@ -4798,7 +4798,7 @@ xfs_bmap_del_extent_delay(
47984798
struct xfs_bmbt_irec *del)
47994799
{
48004800
struct xfs_mount *mp = ip->i_mount;
4801-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
4801+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
48024802
struct xfs_bmbt_irec new;
48034803
int64_t da_old, da_new, da_diff = 0;
48044804
xfs_fileoff_t del_endoff, got_endoff;
@@ -4925,7 +4925,7 @@ xfs_bmap_del_extent_cow(
49254925
struct xfs_bmbt_irec *del)
49264926
{
49274927
struct xfs_mount *mp = ip->i_mount;
4928-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
4928+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, XFS_COW_FORK);
49294929
struct xfs_bmbt_irec new;
49304930
xfs_fileoff_t del_endoff, got_endoff;
49314931
uint32_t state = BMAP_COWFORK;
@@ -5023,7 +5023,7 @@ xfs_bmap_del_extent_real(
50235023
mp = ip->i_mount;
50245024
XFS_STATS_INC(mp, xs_del_exlist);
50255025

5026-
ifp = XFS_IFORK_PTR(ip, whichfork);
5026+
ifp = xfs_ifork_ptr(ip, whichfork);
50275027
ASSERT(del->br_blockcount > 0);
50285028
xfs_iext_get_extent(ifp, icur, &got);
50295029
ASSERT(got.br_startoff <= del->br_startoff);
@@ -5289,7 +5289,7 @@ __xfs_bunmapi(
52895289

52905290
whichfork = xfs_bmapi_whichfork(flags);
52915291
ASSERT(whichfork != XFS_COW_FORK);
5292-
ifp = XFS_IFORK_PTR(ip, whichfork);
5292+
ifp = xfs_ifork_ptr(ip, whichfork);
52935293
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)))
52945294
return -EFSCORRUPTED;
52955295
if (xfs_is_shutdown(mp))
@@ -5630,7 +5630,7 @@ xfs_bmse_merge(
56305630
struct xfs_btree_cur *cur,
56315631
int *logflags) /* output */
56325632
{
5633-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
5633+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
56345634
struct xfs_bmbt_irec new;
56355635
xfs_filblks_t blockcount;
56365636
int error, i;
@@ -5751,7 +5751,7 @@ xfs_bmap_collapse_extents(
57515751
{
57525752
int whichfork = XFS_DATA_FORK;
57535753
struct xfs_mount *mp = ip->i_mount;
5754-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
5754+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
57555755
struct xfs_btree_cur *cur = NULL;
57565756
struct xfs_bmbt_irec got, prev;
57575757
struct xfs_iext_cursor icur;
@@ -5866,7 +5866,7 @@ xfs_bmap_insert_extents(
58665866
{
58675867
int whichfork = XFS_DATA_FORK;
58685868
struct xfs_mount *mp = ip->i_mount;
5869-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
5869+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
58705870
struct xfs_btree_cur *cur = NULL;
58715871
struct xfs_bmbt_irec got, next;
58725872
struct xfs_iext_cursor icur;
@@ -5966,7 +5966,7 @@ xfs_bmap_split_extent(
59665966
xfs_fileoff_t split_fsb)
59675967
{
59685968
int whichfork = XFS_DATA_FORK;
5969-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
5969+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
59705970
struct xfs_btree_cur *cur = NULL;
59715971
struct xfs_bmbt_irec got;
59725972
struct xfs_bmbt_irec new; /* split extent */

fs/xfs/libxfs/xfs_bmap_btree.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ xfs_bmbt_get_minrecs(
304304
if (level == cur->bc_nlevels - 1) {
305305
struct xfs_ifork *ifp;
306306

307-
ifp = XFS_IFORK_PTR(cur->bc_ino.ip,
307+
ifp = xfs_ifork_ptr(cur->bc_ino.ip,
308308
cur->bc_ino.whichfork);
309309

310310
return xfs_bmbt_maxrecs(cur->bc_mp,
@@ -322,7 +322,7 @@ xfs_bmbt_get_maxrecs(
322322
if (level == cur->bc_nlevels - 1) {
323323
struct xfs_ifork *ifp;
324324

325-
ifp = XFS_IFORK_PTR(cur->bc_ino.ip,
325+
ifp = xfs_ifork_ptr(cur->bc_ino.ip,
326326
cur->bc_ino.whichfork);
327327

328328
return xfs_bmbt_maxrecs(cur->bc_mp,
@@ -550,7 +550,7 @@ xfs_bmbt_init_cursor(
550550
struct xfs_inode *ip, /* inode owning the btree */
551551
int whichfork) /* data or attr fork */
552552
{
553-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
553+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
554554
struct xfs_btree_cur *cur;
555555
ASSERT(whichfork != XFS_COW_FORK);
556556

@@ -664,7 +664,7 @@ xfs_bmbt_change_owner(
664664

665665
ASSERT(tp || buffer_list);
666666
ASSERT(!(tp && buffer_list));
667-
ASSERT(XFS_IFORK_PTR(ip, whichfork)->if_format == XFS_DINODE_FMT_BTREE);
667+
ASSERT(xfs_ifork_ptr(ip, whichfork)->if_format == XFS_DINODE_FMT_BTREE);
668668

669669
cur = xfs_bmbt_init_cursor(ip->i_mount, tp, ip, whichfork);
670670
cur->bc_ino.flags |= XFS_BTCUR_BMBT_INVALID_OWNER;

fs/xfs/libxfs/xfs_btree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ xfs_btree_ifork_ptr(
722722

723723
if (cur->bc_flags & XFS_BTREE_STAGING)
724724
return cur->bc_ino.ifake->if_fork;
725-
return XFS_IFORK_PTR(cur->bc_ino.ip, cur->bc_ino.whichfork);
725+
return xfs_ifork_ptr(cur->bc_ino.ip, cur->bc_ino.whichfork);
726726
}
727727

728728
/*
@@ -3556,7 +3556,7 @@ xfs_btree_kill_iroot(
35563556
{
35573557
int whichfork = cur->bc_ino.whichfork;
35583558
struct xfs_inode *ip = cur->bc_ino.ip;
3559-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
3559+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
35603560
struct xfs_btree_block *block;
35613561
struct xfs_btree_block *cblock;
35623562
union xfs_btree_key *kp;

fs/xfs/libxfs/xfs_dir2_block.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ xfs_dir2_sf_to_block(
10711071
struct xfs_trans *tp = args->trans;
10721072
struct xfs_inode *dp = args->dp;
10731073
struct xfs_mount *mp = dp->i_mount;
1074-
struct xfs_ifork *ifp = XFS_IFORK_PTR(dp, XFS_DATA_FORK);
1074+
struct xfs_ifork *ifp = xfs_ifork_ptr(dp, XFS_DATA_FORK);
10751075
struct xfs_da_geometry *geo = args->geo;
10761076
xfs_dir2_db_t blkno; /* dir-relative block # (0) */
10771077
xfs_dir2_data_hdr_t *hdr; /* block header */

fs/xfs/libxfs/xfs_dir2_sf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ xfs_dir2_sf_verify(
710710
struct xfs_inode *ip)
711711
{
712712
struct xfs_mount *mp = ip->i_mount;
713-
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
713+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, XFS_DATA_FORK);
714714
struct xfs_dir2_sf_hdr *sfp;
715715
struct xfs_dir2_sf_entry *sfep;
716716
struct xfs_dir2_sf_entry *next_sfep;

0 commit comments

Comments
 (0)