xfs: replace XFS_IFORK_Q with a proper predicate function
authorDarrick J. Wong <djwong@kernel.org>
Sat, 9 Jul 2022 17:56:06 +0000 (10:56 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 12 Jul 2022 18:17:27 +0000 (11:17 -0700)
Replace this shouty macro with a real C function that has a more
descriptive name.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
13 files changed:
fs/xfs/libxfs/xfs_attr.c
fs/xfs/libxfs/xfs_attr.h
fs/xfs/libxfs/xfs_bmap.c
fs/xfs/libxfs/xfs_inode_fork.c
fs/xfs/libxfs/xfs_inode_fork.h
fs/xfs/scrub/btree.c
fs/xfs/xfs_attr_inactive.c
fs/xfs/xfs_bmap_util.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_inode.h
fs/xfs/xfs_inode_item.c
fs/xfs/xfs_iomap.c
fs/xfs/xfs_iops.c

index 8721d012e9836577b93aaf93df9ddb8aae62781f..e28d93d232de49e18dad3fe5c02843ea6addd34a 100644 (file)
@@ -67,7 +67,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)
@@ -999,7 +999,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);
index 36371c3b9069c4b05013572dfc2999316334a850..81be9b3e40047b928707e620820616407309a197 100644 (file)
@@ -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;
index 1ef72443025ad744a2e30df5fd852a0c05cf17b2..e5108df54f5a6681391644e15e78436c0b993625 100644 (file)
@@ -1023,7 +1023,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));
@@ -1034,7 +1034,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);
index b0370b837166a147789d8f94009854fd58ebc27b..b3ba97242e715b92f342a1e7c9393c55f5ffcc65 100644 (file)
@@ -717,7 +717,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);
index 0b912bbe4f4bcf9b2aa7c3829ae9b02f1c2c91f5..efee1195654083697a1b8502d17be4ea1cfdf749 100644 (file)
@@ -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) : \
index 39dd46f038fe46f7ca02ffce77c7d31ebc44fdf6..2f4519590dc14ecd64b63c1b7c8f84fa17b81387 100644 (file)
@@ -462,7 +462,7 @@ xchk_btree_check_iroot_minrecs(
         */
        if (bs->cur->bc_btnum == XFS_BTNUM_BMAP &&
            bs->cur->bc_ino.whichfork == XFS_DATA_FORK &&
-           XFS_IFORK_Q(bs->sc->ip))
+           xfs_inode_has_attr_fork(bs->sc->ip))
                return false;
 
        return true;
index ec20ad7a9001512a5cd717068dab752a01b4140d..0e83cab9cddec46dad71eb0565306394977b2b73 100644 (file)
@@ -338,7 +338,7 @@ xfs_attr_inactive(
        ASSERT(! XFS_NOT_DQATTACHED(mp, dp));
 
        xfs_ilock(dp, lock_mode);
-       if (!XFS_IFORK_Q(dp))
+       if (!xfs_inode_has_attr_fork(dp))
                goto out_destroy_fork;
        xfs_iunlock(dp, lock_mode);
 
@@ -351,7 +351,7 @@ xfs_attr_inactive(
        lock_mode = XFS_ILOCK_EXCL;
        xfs_ilock(dp, lock_mode);
 
-       if (!XFS_IFORK_Q(dp))
+       if (!xfs_inode_has_attr_fork(dp))
                goto out_cancel;
 
        /*
index f317586d2f6390e7336b6faf86637ed346a27dbd..8111319cbb4696c83d8b60532570383d573c2ba9 100644 (file)
@@ -444,7 +444,7 @@ xfs_getbmap(
        xfs_ilock(ip, XFS_IOLOCK_SHARED);
        switch (whichfork) {
        case XFS_ATTR_FORK:
-               if (!XFS_IFORK_Q(ip))
+               if (!xfs_inode_has_attr_fork(ip))
                        goto out_unlock_iolock;
 
                max_len = 1LL << 32;
@@ -1320,7 +1320,7 @@ xfs_swap_extents_check_format(
         * extent format...
         */
        if (tifp->if_format == XFS_DINODE_FMT_BTREE) {
-               if (XFS_IFORK_Q(ip) &&
+               if (xfs_inode_has_attr_fork(ip) &&
                    XFS_BMAP_BMDR_SPACE(tifp->if_broot) > XFS_IFORK_BOFF(ip))
                        return -EINVAL;
                if (tifp->if_nextents <= XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
@@ -1329,7 +1329,7 @@ xfs_swap_extents_check_format(
 
        /* Reciprocal target->temp btree format checks */
        if (ifp->if_format == XFS_DINODE_FMT_BTREE) {
-               if (XFS_IFORK_Q(tip) &&
+               if (xfs_inode_has_attr_fork(tip) &&
                    XFS_BMAP_BMDR_SPACE(ip->i_df.if_broot) > XFS_IFORK_BOFF(tip))
                        return -EINVAL;
                if (ifp->if_nextents <= XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK))
@@ -1506,14 +1506,14 @@ xfs_swap_extent_forks(
        /*
         * Count the number of extended attribute blocks
         */
-       if (XFS_IFORK_Q(ip) && ip->i_af.if_nextents > 0 &&
+       if (xfs_inode_has_attr_fork(ip) && ip->i_af.if_nextents > 0 &&
            ip->i_af.if_format != XFS_DINODE_FMT_LOCAL) {
                error = xfs_bmap_count_blocks(tp, ip, XFS_ATTR_FORK, &junk,
                                &aforkblks);
                if (error)
                        return error;
        }
-       if (XFS_IFORK_Q(tip) && tip->i_af.if_nextents > 0 &&
+       if (xfs_inode_has_attr_fork(tip) && tip->i_af.if_nextents > 0 &&
            tip->i_af.if_format != XFS_DINODE_FMT_LOCAL) {
                error = xfs_bmap_count_blocks(tp, tip, XFS_ATTR_FORK, &junk,
                                &taforkblks);
index 699c44f5770794c99c32d7f029730bd6598048c0..33cf0b82a0c0fefd4447d3a2c8ebc909b732ac09 100644 (file)
@@ -125,7 +125,7 @@ xfs_ilock_attr_map_shared(
 {
        uint                    lock_mode = XFS_ILOCK_SHARED;
 
-       if (XFS_IFORK_Q(ip) && xfs_need_iread_extents(&ip->i_af))
+       if (xfs_inode_has_attr_fork(ip) && xfs_need_iread_extents(&ip->i_af))
                lock_mode = XFS_ILOCK_EXCL;
        xfs_ilock(ip, lock_mode);
        return lock_mode;
@@ -635,7 +635,7 @@ xfs_ip2xflags(
                        flags |= FS_XFLAG_COWEXTSIZE;
        }
 
-       if (XFS_IFORK_Q(ip))
+       if (xfs_inode_has_attr_fork(ip))
                flags |= FS_XFLAG_HASATTR;
        return flags;
 }
@@ -1762,7 +1762,7 @@ xfs_inactive(
         * now.  The code calls a routine that recursively deconstructs the
         * attribute fork. If also blows away the in-core attribute fork.
         */
-       if (XFS_IFORK_Q(ip)) {
+       if (xfs_inode_has_attr_fork(ip)) {
                error = xfs_attr_inactive(ip);
                if (error)
                        goto out;
@@ -3501,7 +3501,7 @@ xfs_iflush(
        if (ip->i_df.if_format == XFS_DINODE_FMT_LOCAL &&
            xfs_ifork_verify_local_data(ip))
                goto flush_out;
-       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))
                goto flush_out;
@@ -3520,7 +3520,7 @@ xfs_iflush(
        }
 
        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);
 
        /*
index 9bda01311c2f7637316f7016878e75e74a5e2bda..2badbf9bb80d8a3faf43ad5ed2a6787626403340 100644 (file)
@@ -77,6 +77,11 @@ typedef struct xfs_inode {
        struct list_head        i_ioend_list;
 } 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,
@@ -86,7 +91,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:
index 77519e6f0b3437841c7c71ceb684706d83f30643..a78a0b9dd1d0988cf787a1d7dc6a753e10e6aa32 100644 (file)
@@ -143,7 +143,7 @@ xfs_inode_item_size(
                   xfs_log_dinode_size(ip->i_mount);
 
        xfs_inode_item_data_fork_size(iip, nvecs, nbytes);
-       if (XFS_IFORK_Q(ip))
+       if (xfs_inode_has_attr_fork(ip))
                xfs_inode_item_attr_fork_size(iip, nvecs, nbytes);
 }
 
@@ -480,7 +480,7 @@ xfs_inode_item_format(
 
        xfs_inode_item_format_core(ip, lv, &vecp);
        xfs_inode_item_format_data_fork(iip, ilf, lv, &vecp);
-       if (XFS_IFORK_Q(ip)) {
+       if (xfs_inode_has_attr_fork(ip)) {
                xfs_inode_item_format_attr_fork(iip, ilf, lv, &vecp);
        } else {
                iip->ili_fields &=
index eb54fd259d154a855a7a9d95755585390e1ac662..edbfd6abcc15c8848a68faa6105abc11febcb299 100644 (file)
@@ -1307,7 +1307,7 @@ xfs_xattr_iomap_begin(
        lockmode = xfs_ilock_attr_map_shared(ip);
 
        /* if there are no attribute fork or extents, return ENOENT */
-       if (!XFS_IFORK_Q(ip) || !ip->i_af.if_nextents) {
+       if (!xfs_inode_has_attr_fork(ip) || !ip->i_af.if_nextents) {
                error = -ENOENT;
                goto out_unlock;
        }
index 6720b60f88cfcbaf3f3c0595992e97d3a7228ea9..14efa0fc1c19d22bc10de8c0c332070f5d197f1b 100644 (file)
@@ -1279,7 +1279,7 @@ xfs_setup_inode(
         * If there is no attribute fork no ACL can exist on this inode,
         * and it can't have any file capabilities attached to it either.
         */
-       if (!XFS_IFORK_Q(ip)) {
+       if (!xfs_inode_has_attr_fork(ip)) {
                inode_has_no_xattr(inode);
                cache_no_acl(inode);
        }