From: Darrick J. Wong Date: Wed, 24 Aug 2022 13:40:21 +0000 (+0200) Subject: xfs: replace XFS_IFORK_Q with a proper predicate function X-Git-Tag: v6.0.0-rc0~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4f841585811f28f57616e1180458fe9080e72dea;p=thirdparty%2Fxfsprogs-dev.git xfs: replace XFS_IFORK_Q with a proper predicate function Source kernel commit: 932b42c66cb5d0ca9800b128415b4ad6b1952b3e Replace this shouty macro with a real C function that has a more descriptive name. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Signed-off-by: Carlos Maiolino --- diff --git a/include/xfs_inode.h b/include/xfs_inode.h index 6470fe4d7..d3c2bb8fa 100644 --- a/include/xfs_inode.h +++ b/include/xfs_inode.h @@ -100,6 +100,11 @@ typedef struct xfs_inode { struct inode i_vnode; } xfs_inode_t; +static inline bool xfs_inode_has_attr_fork(struct xfs_inode *ip) +{ + return ip->i_forkoff > 0; +} + static inline struct xfs_ifork * xfs_ifork_ptr( struct xfs_inode *ip, @@ -109,7 +114,7 @@ xfs_ifork_ptr( case XFS_DATA_FORK: return &ip->i_df; case XFS_ATTR_FORK: - if (!XFS_IFORK_Q(ip)) + if (!xfs_inode_has_attr_fork(ip)) return NULL; return &ip->i_af; case XFS_COW_FORK: diff --git a/libxfs/util.c b/libxfs/util.c index 3e12a188f..a41d50c4a 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -374,7 +374,7 @@ libxfs_iflush_int( if (ip->i_df.if_format == XFS_DINODE_FMT_LOCAL && xfs_ifork_verify_local_data(ip)) return -EFSCORRUPTED; - if (XFS_IFORK_Q(ip) && + if (xfs_inode_has_attr_fork(ip) && ip->i_af.if_format == XFS_DINODE_FMT_LOCAL && xfs_ifork_verify_local_attr(ip)) return -EFSCORRUPTED; @@ -388,7 +388,7 @@ libxfs_iflush_int( xfs_inode_to_disk(ip, dip, iip->ili_item.li_lsn); xfs_iflush_fork(ip, dip, iip, XFS_DATA_FORK); - if (XFS_IFORK_Q(ip)) + if (xfs_inode_has_attr_fork(ip)) xfs_iflush_fork(ip, dip, iip, XFS_ATTR_FORK); /* generate the checksum. */ diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 404cff679..2103a06b9 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -65,7 +65,7 @@ int xfs_inode_hasattr( struct xfs_inode *ip) { - if (!XFS_IFORK_Q(ip)) + if (!xfs_inode_has_attr_fork(ip)) return 0; if (ip->i_af.if_format == XFS_DINODE_FMT_EXTENTS && ip->i_af.if_nextents == 0) @@ -997,7 +997,7 @@ xfs_attr_set( * If the inode doesn't have an attribute fork, add one. * (inode must not be locked when we call this routine) */ - if (XFS_IFORK_Q(dp) == 0) { + if (xfs_inode_has_attr_fork(dp) == 0) { int sf_size = sizeof(struct xfs_attr_sf_hdr) + xfs_attr_sf_entsize_byname(args->namelen, args->valuelen); diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 36371c3b9..81be9b3e4 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -576,7 +576,7 @@ xfs_attr_init_add_state(struct xfs_da_args *args) * context, i_af is guaranteed to exist. Hence if the attr fork is * null, we were called from a pure remove operation and so we are done. */ - if (!XFS_IFORK_Q(args->dp)) + if (!xfs_inode_has_attr_fork(args->dp)) return XFS_DAS_DONE; args->op_flags |= XFS_DA_OP_ADDNAME; diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index c2f87bbbd..11d0aa0e7 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -1016,7 +1016,7 @@ xfs_bmap_add_attrfork( int logflags; /* logging flags */ int error; /* error return value */ - ASSERT(XFS_IFORK_Q(ip) == 0); + ASSERT(xfs_inode_has_attr_fork(ip) == 0); mp = ip->i_mount; ASSERT(!XFS_NOT_DQATTACHED(mp, ip)); @@ -1027,7 +1027,7 @@ xfs_bmap_add_attrfork( rsvd, &tp); if (error) return error; - if (XFS_IFORK_Q(ip)) + if (xfs_inode_has_attr_fork(ip)) goto trans_cancel; xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); diff --git a/libxfs/xfs_inode_fork.c b/libxfs/xfs_inode_fork.c index 225b7f8ca..616f31b3c 100644 --- a/libxfs/xfs_inode_fork.c +++ b/libxfs/xfs_inode_fork.c @@ -715,7 +715,7 @@ xfs_ifork_verify_local_attr( struct xfs_ifork *ifp = &ip->i_af; xfs_failaddr_t fa; - if (!XFS_IFORK_Q(ip)) + if (!xfs_inode_has_attr_fork(ip)) fa = __this_address; else fa = xfs_attr_shortform_verify(ip); diff --git a/libxfs/xfs_inode_fork.h b/libxfs/xfs_inode_fork.h index 0b912bbe4..efee11956 100644 --- a/libxfs/xfs_inode_fork.h +++ b/libxfs/xfs_inode_fork.h @@ -78,13 +78,12 @@ struct xfs_ifork { * Fork handling. */ -#define XFS_IFORK_Q(ip) ((ip)->i_forkoff != 0) #define XFS_IFORK_BOFF(ip) ((int)((ip)->i_forkoff << 3)) #define XFS_IFORK_DSIZE(ip) \ - (XFS_IFORK_Q(ip) ? XFS_IFORK_BOFF(ip) : XFS_LITINO((ip)->i_mount)) + (xfs_inode_has_attr_fork(ip) ? XFS_IFORK_BOFF(ip) : XFS_LITINO((ip)->i_mount)) #define XFS_IFORK_ASIZE(ip) \ - (XFS_IFORK_Q(ip) ? XFS_LITINO((ip)->i_mount) - XFS_IFORK_BOFF(ip) : 0) + (xfs_inode_has_attr_fork(ip) ? XFS_LITINO((ip)->i_mount) - XFS_IFORK_BOFF(ip) : 0) #define XFS_IFORK_SIZE(ip,w) \ ((w) == XFS_DATA_FORK ? \ XFS_IFORK_DSIZE(ip) : \