Skip to content

Commit c01147d

Browse files
author
Darrick J. Wong
committed
xfs: replace inode fork size macros with functions
Replace the shouty macros here with typechecked helper functions. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]>
1 parent 932b42c commit c01147d

15 files changed

+61
-39
lines changed

fs/xfs/libxfs/xfs_attr_leaf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ xfs_attr_shortform_bytesfit(
590590
* to real extents, or the delalloc conversion will take care of the
591591
* literal area rebalancing.
592592
*/
593-
if (bytes <= XFS_IFORK_ASIZE(dp))
593+
if (bytes <= xfs_inode_attr_fork_size(dp))
594594
return dp->i_forkoff;
595595

596596
/*

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ xfs_bmap_add_attrfork_btree(
880880

881881
mp = ip->i_mount;
882882

883-
if (XFS_BMAP_BMDR_SPACE(block) <= XFS_IFORK_DSIZE(ip))
883+
if (XFS_BMAP_BMDR_SPACE(block) <= xfs_inode_data_fork_size(ip))
884884
*flags |= XFS_ILOG_DBROOT;
885885
else {
886886
cur = xfs_bmbt_init_cursor(mp, tp, ip, XFS_DATA_FORK);
@@ -920,7 +920,7 @@ xfs_bmap_add_attrfork_extents(
920920
int error; /* error return value */
921921

922922
if (ip->i_df.if_nextents * sizeof(struct xfs_bmbt_rec) <=
923-
XFS_IFORK_DSIZE(ip))
923+
xfs_inode_data_fork_size(ip))
924924
return 0;
925925
cur = NULL;
926926
error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0, flags,
@@ -951,7 +951,7 @@ xfs_bmap_add_attrfork_local(
951951
{
952952
struct xfs_da_args dargs; /* args for dir/attr code */
953953

954-
if (ip->i_df.if_bytes <= XFS_IFORK_DSIZE(ip))
954+
if (ip->i_df.if_bytes <= xfs_inode_data_fork_size(ip))
955955
return 0;
956956

957957
if (S_ISDIR(VFS_I(ip)->i_mode)) {

fs/xfs/libxfs/xfs_bmap_btree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ xfs_bmbt_init_cursor(
564564
if (xfs_has_crc(mp))
565565
cur->bc_flags |= XFS_BTREE_CRC_BLOCKS;
566566

567-
cur->bc_ino.forksize = XFS_IFORK_SIZE(ip, whichfork);
567+
cur->bc_ino.forksize = xfs_inode_fork_size(ip, whichfork);
568568
cur->bc_ino.ip = ip;
569569
cur->bc_ino.allocated = 0;
570570
cur->bc_ino.flags = 0;

fs/xfs/libxfs/xfs_dir2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ xfs_dir_isempty(
193193
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
194194
if (dp->i_disk_size == 0) /* might happen during shutdown. */
195195
return 1;
196-
if (dp->i_disk_size > XFS_IFORK_DSIZE(dp))
196+
if (dp->i_disk_size > xfs_inode_data_fork_size(dp))
197197
return 0;
198198
sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
199199
return !sfp->count;

fs/xfs/libxfs/xfs_dir2_block.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ xfs_dir2_block_removename(
842842
* See if the size as a shortform is good enough.
843843
*/
844844
size = xfs_dir2_block_sfsize(dp, hdr, &sfh);
845-
if (size > XFS_IFORK_DSIZE(dp))
845+
if (size > xfs_inode_data_fork_size(dp))
846846
return 0;
847847

848848
/*
@@ -1055,7 +1055,7 @@ xfs_dir2_leaf_to_block(
10551055
* Now see if the resulting block can be shrunken to shortform.
10561056
*/
10571057
size = xfs_dir2_block_sfsize(dp, hdr, &sfh);
1058-
if (size > XFS_IFORK_DSIZE(dp))
1058+
if (size > xfs_inode_data_fork_size(dp))
10591059
return 0;
10601060

10611061
return xfs_dir2_block_to_sf(args, dbp, size, &sfh);

fs/xfs/libxfs/xfs_dir2_sf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ xfs_dir2_block_sfsize(
237237
(i8count ? /* inumber */
238238
count * XFS_INO64_SIZE :
239239
count * XFS_INO32_SIZE);
240-
if (size > XFS_IFORK_DSIZE(dp))
240+
if (size > xfs_inode_data_fork_size(dp))
241241
return size; /* size value is a failure */
242242
}
243243
/*
@@ -406,7 +406,7 @@ xfs_dir2_sf_addname(
406406
* Won't fit as shortform any more (due to size),
407407
* or the pick routine says it won't (due to offset values).
408408
*/
409-
if (new_isize > XFS_IFORK_DSIZE(dp) ||
409+
if (new_isize > xfs_inode_data_fork_size(dp) ||
410410
(pick =
411411
xfs_dir2_sf_addname_pick(args, objchange, &sfep, &offset)) == 0) {
412412
/*
@@ -1031,7 +1031,7 @@ xfs_dir2_sf_replace_needblock(
10311031
newsize = dp->i_df.if_bytes + (sfp->count + 1) * XFS_INO64_DIFF;
10321032

10331033
return inum > XFS_DIR2_MAX_SHORT_INUM &&
1034-
sfp->i8count == 0 && newsize > XFS_IFORK_DSIZE(dp);
1034+
sfp->i8count == 0 && newsize > xfs_inode_data_fork_size(dp);
10351035
}
10361036

10371037
/*

fs/xfs/libxfs/xfs_inode_fork.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ xfs_iroot_realloc(
407407
(int)new_size);
408408
ifp->if_broot_bytes = (int)new_size;
409409
ASSERT(XFS_BMAP_BMDR_SPACE(ifp->if_broot) <=
410-
XFS_IFORK_SIZE(ip, whichfork));
410+
xfs_inode_fork_size(ip, whichfork));
411411
memmove(np, op, cur_max * (uint)sizeof(xfs_fsblock_t));
412412
return;
413413
}
@@ -461,7 +461,7 @@ xfs_iroot_realloc(
461461
ifp->if_broot_bytes = (int)new_size;
462462
if (ifp->if_broot)
463463
ASSERT(XFS_BMAP_BMDR_SPACE(ifp->if_broot) <=
464-
XFS_IFORK_SIZE(ip, whichfork));
464+
xfs_inode_fork_size(ip, whichfork));
465465
return;
466466
}
467467

@@ -491,7 +491,7 @@ xfs_idata_realloc(
491491
int64_t new_size = ifp->if_bytes + byte_diff;
492492

493493
ASSERT(new_size >= 0);
494-
ASSERT(new_size <= XFS_IFORK_SIZE(ip, whichfork));
494+
ASSERT(new_size <= xfs_inode_fork_size(ip, whichfork));
495495

496496
if (byte_diff == 0)
497497
return;
@@ -614,7 +614,7 @@ xfs_iflush_fork(
614614
if ((iip->ili_fields & dataflag[whichfork]) &&
615615
(ifp->if_bytes > 0)) {
616616
ASSERT(ifp->if_u1.if_data != NULL);
617-
ASSERT(ifp->if_bytes <= XFS_IFORK_SIZE(ip, whichfork));
617+
ASSERT(ifp->if_bytes <= xfs_inode_fork_size(ip, whichfork));
618618
memcpy(cp, ifp->if_u1.if_data, ifp->if_bytes);
619619
}
620620
break;
@@ -633,7 +633,7 @@ xfs_iflush_fork(
633633
(ifp->if_broot_bytes > 0)) {
634634
ASSERT(ifp->if_broot != NULL);
635635
ASSERT(XFS_BMAP_BMDR_SPACE(ifp->if_broot) <=
636-
XFS_IFORK_SIZE(ip, whichfork));
636+
xfs_inode_fork_size(ip, whichfork));
637637
xfs_bmbt_to_bmdr(mp, ifp->if_broot, ifp->if_broot_bytes,
638638
(xfs_bmdr_block_t *)cp,
639639
XFS_DFORK_SIZE(dip, mp, whichfork));

fs/xfs/libxfs/xfs_inode_fork.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,8 @@ struct xfs_ifork {
7777
/*
7878
* Fork handling.
7979
*/
80-
81-
#define XFS_IFORK_BOFF(ip) ((int)((ip)->i_forkoff << 3))
82-
83-
#define XFS_IFORK_DSIZE(ip) \
84-
(xfs_inode_has_attr_fork(ip) ? XFS_IFORK_BOFF(ip) : XFS_LITINO((ip)->i_mount))
85-
#define XFS_IFORK_ASIZE(ip) \
86-
(xfs_inode_has_attr_fork(ip) ? XFS_LITINO((ip)->i_mount) - XFS_IFORK_BOFF(ip) : 0)
87-
#define XFS_IFORK_SIZE(ip,w) \
88-
((w) == XFS_DATA_FORK ? \
89-
XFS_IFORK_DSIZE(ip) : \
90-
((w) == XFS_ATTR_FORK ? \
91-
XFS_IFORK_ASIZE(ip) : \
92-
0))
9380
#define XFS_IFORK_MAXEXT(ip, w) \
94-
(XFS_IFORK_SIZE(ip, w) / sizeof(xfs_bmbt_rec_t))
81+
(xfs_inode_fork_size(ip, w) / sizeof(xfs_bmbt_rec_t))
9582

9683
static inline bool xfs_ifork_has_extents(struct xfs_ifork *ifp)
9784
{

fs/xfs/scrub/symlink.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ xchk_symlink(
5252

5353
/* Inline symlink? */
5454
if (ifp->if_format == XFS_DINODE_FMT_LOCAL) {
55-
if (len > XFS_IFORK_DSIZE(ip) ||
56-
len > strnlen(ifp->if_u1.if_data, XFS_IFORK_DSIZE(ip)))
55+
if (len > xfs_inode_data_fork_size(ip) ||
56+
len > strnlen(ifp->if_u1.if_data, xfs_inode_data_fork_size(ip)))
5757
xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0);
5858
goto out;
5959
}

fs/xfs/xfs_bmap_util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ xfs_swap_extents_check_format(
13211321
*/
13221322
if (tifp->if_format == XFS_DINODE_FMT_BTREE) {
13231323
if (xfs_inode_has_attr_fork(ip) &&
1324-
XFS_BMAP_BMDR_SPACE(tifp->if_broot) > XFS_IFORK_BOFF(ip))
1324+
XFS_BMAP_BMDR_SPACE(tifp->if_broot) > xfs_inode_fork_boff(ip))
13251325
return -EINVAL;
13261326
if (tifp->if_nextents <= XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
13271327
return -EINVAL;
@@ -1330,7 +1330,7 @@ xfs_swap_extents_check_format(
13301330
/* Reciprocal target->temp btree format checks */
13311331
if (ifp->if_format == XFS_DINODE_FMT_BTREE) {
13321332
if (xfs_inode_has_attr_fork(tip) &&
1333-
XFS_BMAP_BMDR_SPACE(ip->i_df.if_broot) > XFS_IFORK_BOFF(tip))
1333+
XFS_BMAP_BMDR_SPACE(ip->i_df.if_broot) > xfs_inode_fork_boff(tip))
13341334
return -EINVAL;
13351335
if (ifp->if_nextents <= XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK))
13361336
return -EINVAL;

0 commit comments

Comments
 (0)