xfs: clean up IRELE/iput callsites
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 25 Jul 2018 19:52:32 +0000 (12:52 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Thu, 26 Jul 2018 17:15:16 +0000 (10:15 -0700)
Replace the IRELE macro with a proper function so that we can do proper
typechecking and so that we can stop open-coding iput in scrub, which
means that we'll be able to ftrace inode lifetimes going through scrub
correctly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
19 files changed:
fs/xfs/scrub/common.c
fs/xfs/scrub/dir.c
fs/xfs/scrub/parent.c
fs/xfs/scrub/scrub.c
fs/xfs/xfs_bmap_item.c
fs/xfs/xfs_export.c
fs/xfs/xfs_filestream.c
fs/xfs/xfs_icache.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_inode.h
fs/xfs/xfs_iops.c
fs/xfs/xfs_itable.c
fs/xfs/xfs_log_recover.c
fs/xfs/xfs_mount.c
fs/xfs/xfs_qm.c
fs/xfs/xfs_qm_syscalls.c
fs/xfs/xfs_quotaops.c
fs/xfs/xfs_rtalloc.c
fs/xfs/xfs_symlink.c

index baac08304a5a09c23535cbc79d9d6da57a237a2c..346b02abccf710536b58b678a0a64905879301dc 100644 (file)
@@ -711,7 +711,7 @@ xchk_get_inode(
                return error;
        }
        if (VFS_I(ip)->i_generation != sc->sm->sm_gen) {
-               iput(VFS_I(ip));
+               xfs_irele(ip);
                return -ENOENT;
        }
 
index f58709052b030dd819412d2e367328103cda9af7..cd3e4d768a18ce2d6466c973dfe891174cc523cf 100644 (file)
@@ -87,7 +87,7 @@ xchk_dir_check_ftype(
                        xfs_mode_to_ftype(VFS_I(ip)->i_mode));
        if (ino_dtype != dtype)
                xchk_fblock_set_corrupt(sdc->sc, XFS_DATA_FORK, offset);
-       iput(VFS_I(ip));
+       xfs_irele(ip);
 out:
        return error;
 }
index aacb0284c48a08de74427e8a8171a7880a53334d..1c9d7c7f64f5d59caee67e53a5a54d09f09fd951 100644 (file)
@@ -230,11 +230,11 @@ xchk_parent_validate(
 
        /* Drat, parent changed.  Try again! */
        if (dnum != dp->i_ino) {
-               iput(VFS_I(dp));
+               xfs_irele(dp);
                *try_again = true;
                return 0;
        }
-       iput(VFS_I(dp));
+       xfs_irele(dp);
 
        /*
         * '..' didn't change, so check that there was only one entry
@@ -247,7 +247,7 @@ xchk_parent_validate(
 out_unlock:
        xfs_iunlock(dp, XFS_IOLOCK_SHARED);
 out_rele:
-       iput(VFS_I(dp));
+       xfs_irele(dp);
 out:
        return error;
 }
index 5956b8073e2fc3644dbfc3ccf16fc5fa034aaf6f..6efb926f3cf81970b6e7ca526a8ef687c13a63b4 100644 (file)
@@ -183,7 +183,7 @@ xchk_teardown(
                        xfs_iunlock(sc->ip, sc->ilock_flags);
                if (sc->ip != ip_in &&
                    !xfs_internal_inum(sc->mp, sc->ip->i_ino))
-                       iput(VFS_I(sc->ip));
+                       xfs_irele(sc->ip);
                sc->ip = NULL;
        }
        if (sc->has_quotaofflock)
index bc5eb2e0ab0c30bf0c2d57473ed8a83d4a58472b..e1d6c127b07d65c4332c8d0e6cd9365ea4825213 100644 (file)
@@ -497,7 +497,7 @@ xfs_bui_recover(
        xfs_defer_move(dfops, tp->t_dfops);
        error = xfs_trans_commit(tp);
        xfs_iunlock(ip, XFS_ILOCK_EXCL);
-       IRELE(ip);
+       xfs_irele(ip);
 
        return error;
 
@@ -506,7 +506,7 @@ err_inode:
        xfs_trans_cancel(tp);
        if (ip) {
                xfs_iunlock(ip, XFS_ILOCK_EXCL);
-               IRELE(ip);
+               xfs_irele(ip);
        }
        return error;
 }
index 3cf4682e2510db5eb3614d15a47e4992365dc673..f2284ceb129f7acdf91874934c3013c6d9b174f3 100644 (file)
@@ -150,7 +150,7 @@ xfs_nfs_get_inode(
        }
 
        if (VFS_I(ip)->i_generation != generation) {
-               IRELE(ip);
+               xfs_irele(ip);
                return ERR_PTR(-ESTALE);
        }
 
index 56a3999cefae4fe1b445e87a0d6488265a4984d1..212173c62588f3264251537b710e16fc68f0f030 100644 (file)
@@ -340,7 +340,7 @@ xfs_filestream_lookup_ag(
        if (xfs_filestream_pick_ag(pip, startag, &ag, 0, 0))
                ag = NULLAGNUMBER;
 out:
-       IRELE(pip);
+       xfs_irele(pip);
        return ag;
 }
 
@@ -389,7 +389,7 @@ xfs_filestream_new_ag(
        if (mru)
                xfs_fstrm_free_func(mp, mru);
 
-       IRELE(pip);
+       xfs_irele(pip);
 exit:
        if (*agp == NULLAGNUMBER)
                *agp = 0;
index 47f417d20a30c5c8b885946c09ed013e8af16523..8de94ecd73ae0d11980578eeb1bc0b078623c931 100644 (file)
@@ -716,7 +716,7 @@ xfs_icache_inode_is_allocated(
                return error;
 
        *inuse = !!(VFS_I(ip)->i_mode);
-       IRELE(ip);
+       xfs_irele(ip);
        return 0;
 }
 
@@ -856,7 +856,7 @@ restart:
                            xfs_iflags_test(batch[i], XFS_INEW))
                                xfs_inew_wait(batch[i]);
                        error = execute(batch[i], flags, args);
-                       IRELE(batch[i]);
+                       xfs_irele(batch[i]);
                        if (error == -EAGAIN) {
                                skipped++;
                                continue;
index 0e4bd559a6a7c765efa5980e0fe3fa202ade4e61..64c694d2b2a5114c09c2c0febe06f4f614a3e7d9 100644 (file)
@@ -1276,7 +1276,7 @@ xfs_create(
         */
        if (ip) {
                xfs_finish_inode_setup(ip);
-               IRELE(ip);
+               xfs_irele(ip);
        }
 
        xfs_qm_dqrele(udqp);
@@ -1371,7 +1371,7 @@ xfs_create_tmpfile(
         */
        if (ip) {
                xfs_finish_inode_setup(ip);
-               IRELE(ip);
+               xfs_irele(ip);
        }
 
        xfs_qm_dqrele(udqp);
@@ -3134,14 +3134,14 @@ xfs_rename(
 
        error = xfs_finish_rename(tp);
        if (wip)
-               IRELE(wip);
+               xfs_irele(wip);
        return error;
 
 out_trans_cancel:
        xfs_trans_cancel(tp);
 out_release_wip:
        if (wip)
-               IRELE(wip);
+               xfs_irele(wip);
        return error;
 }
 
@@ -3597,3 +3597,12 @@ xfs_iflush_int(
 corrupt_out:
        return -EFSCORRUPTED;
 }
+
+/* Release an inode. */
+void
+xfs_irele(
+       struct xfs_inode        *ip)
+{
+       trace_xfs_irele(ip, _RET_IP_);
+       iput(VFS_I(ip));
+}
index c43abf4ea3fc082f5ab2274f01db099bdb068b58..8db34d6f28359de84c51b1a6cb0f087f5424ffcc 100644 (file)
@@ -483,11 +483,7 @@ static inline void xfs_setup_existing_inode(struct xfs_inode *ip)
        xfs_finish_inode_setup(ip);
 }
 
-#define IRELE(ip) \
-do { \
-       trace_xfs_irele(ip, _THIS_IP_); \
-       iput(VFS_I(ip)); \
-} while (0)
+void xfs_irele(struct xfs_inode *ip);
 
 extern struct kmem_zone        *xfs_inode_zone;
 
index 2eac22bfad6a71604752c873ef08c3afbaf0e53c..0ef5ad7fb851e36339df36fc4fd6b84b67dc1e84 100644 (file)
@@ -209,7 +209,7 @@ xfs_generic_create(
        xfs_finish_inode_setup(ip);
        if (!tmpfile)
                xfs_cleanup_inode(dir, inode, dentry);
-       iput(inode);
+       xfs_irele(ip);
        goto out_free_acl;
 }
 
@@ -391,7 +391,7 @@ xfs_vn_symlink(
  out_cleanup_inode:
        xfs_finish_inode_setup(cip);
        xfs_cleanup_inode(dir, inode, dentry);
-       iput(inode);
+       xfs_irele(cip);
  out:
        return error;
 }
index 65810827a8d07703e22a7dbd719d076bfe52a14d..e9508ba01ed19973f4e7493156c11998a8be255d 100644 (file)
@@ -114,7 +114,7 @@ xfs_bulkstat_one_int(
                break;
        }
        xfs_iunlock(ip, XFS_ILOCK_SHARED);
-       IRELE(ip);
+       xfs_irele(ip);
 
        error = formatter(buffer, ubsize, ubused, buf);
        if (!error)
index 94908a4019e19ba30092996257ccd9f151eeb931..7776fde9430c4af23d6bebe435acd9c4fe4e584b 100644 (file)
@@ -5087,11 +5087,11 @@ xlog_recover_process_one_iunlink(
         */
        ip->i_d.di_dmevmask = 0;
 
-       IRELE(ip);
+       xfs_irele(ip);
        return agino;
 
  fail_iput:
-       IRELE(ip);
+       xfs_irele(ip);
  fail:
        /*
         * We can't read in the inode this bucket points to, or this inode
index 4fb361cde32a12e59c64bbe9b840b526d8eaf921..8f739e4d0d1c4b8168c49fc96c0f7247a8e58dbb 100644 (file)
@@ -1039,7 +1039,7 @@ xfs_mountfs(
  out_rtunmount:
        xfs_rtunmount_inodes(mp);
  out_rele_rip:
-       IRELE(rip);
+       xfs_irele(rip);
        /* Clean out dquots that might be in memory after quotacheck. */
        xfs_qm_unmount(mp);
        /*
@@ -1095,7 +1095,7 @@ xfs_unmountfs(
        xfs_fs_unreserve_ag_blocks(mp);
        xfs_qm_unmount_quotas(mp);
        xfs_rtunmount_inodes(mp);
-       IRELE(mp->m_rootip);
+       xfs_irele(mp->m_rootip);
 
        /*
         * We can potentially deadlock here if we have an inode cluster
index 9ceb85cce33a54cc02fd1b09efd074c2af8206c0..52ed7904df10b75ad5182e9391589b8e351cf9f4 100644 (file)
@@ -231,15 +231,15 @@ xfs_qm_unmount_quotas(
         */
        if (mp->m_quotainfo) {
                if (mp->m_quotainfo->qi_uquotaip) {
-                       IRELE(mp->m_quotainfo->qi_uquotaip);
+                       xfs_irele(mp->m_quotainfo->qi_uquotaip);
                        mp->m_quotainfo->qi_uquotaip = NULL;
                }
                if (mp->m_quotainfo->qi_gquotaip) {
-                       IRELE(mp->m_quotainfo->qi_gquotaip);
+                       xfs_irele(mp->m_quotainfo->qi_gquotaip);
                        mp->m_quotainfo->qi_gquotaip = NULL;
                }
                if (mp->m_quotainfo->qi_pquotaip) {
-                       IRELE(mp->m_quotainfo->qi_pquotaip);
+                       xfs_irele(mp->m_quotainfo->qi_pquotaip);
                        mp->m_quotainfo->qi_pquotaip = NULL;
                }
        }
@@ -1200,12 +1200,12 @@ xfs_qm_dqusage_adjust(
                        goto error0;
        }
 
-       IRELE(ip);
+       xfs_irele(ip);
        *res = BULKSTAT_RV_DIDONE;
        return 0;
 
 error0:
-       IRELE(ip);
+       xfs_irele(ip);
        *res = BULKSTAT_RV_GIVEUP;
        return error;
 }
@@ -1575,11 +1575,11 @@ xfs_qm_init_quotainos(
 
 error_rele:
        if (uip)
-               IRELE(uip);
+               xfs_irele(uip);
        if (gip)
-               IRELE(gip);
+               xfs_irele(gip);
        if (pip)
-               IRELE(pip);
+               xfs_irele(pip);
        return error;
 }
 
@@ -1588,15 +1588,15 @@ xfs_qm_destroy_quotainos(
        xfs_quotainfo_t *qi)
 {
        if (qi->qi_uquotaip) {
-               IRELE(qi->qi_uquotaip);
+               xfs_irele(qi->qi_uquotaip);
                qi->qi_uquotaip = NULL; /* paranoia */
        }
        if (qi->qi_gquotaip) {
-               IRELE(qi->qi_gquotaip);
+               xfs_irele(qi->qi_gquotaip);
                qi->qi_gquotaip = NULL;
        }
        if (qi->qi_pquotaip) {
-               IRELE(qi->qi_pquotaip);
+               xfs_irele(qi->qi_pquotaip);
                qi->qi_pquotaip = NULL;
        }
 }
index c07c5a39d516dac7b87cb9c1129f0d936ccc2c24..b3190890f096d5f8717f8762e53be74edfdaa9d9 100644 (file)
@@ -190,15 +190,15 @@ xfs_qm_scall_quotaoff(
         * Release our quotainode references if we don't need them anymore.
         */
        if ((dqtype & XFS_QMOPT_UQUOTA) && q->qi_uquotaip) {
-               IRELE(q->qi_uquotaip);
+               xfs_irele(q->qi_uquotaip);
                q->qi_uquotaip = NULL;
        }
        if ((dqtype & XFS_QMOPT_GQUOTA) && q->qi_gquotaip) {
-               IRELE(q->qi_gquotaip);
+               xfs_irele(q->qi_gquotaip);
                q->qi_gquotaip = NULL;
        }
        if ((dqtype & XFS_QMOPT_PQUOTA) && q->qi_pquotaip) {
-               IRELE(q->qi_pquotaip);
+               xfs_irele(q->qi_pquotaip);
                q->qi_pquotaip = NULL;
        }
 
@@ -251,7 +251,7 @@ xfs_qm_scall_trunc_qfile(
 out_unlock:
        xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
 out_put:
-       IRELE(ip);
+       xfs_irele(ip);
        return error;
 }
 
index 205fbb2a77e4d97ebf148e7c9fbea5ea79787c2a..a7c0c657dfaf943037bcb6fa753996c32956413b 100644 (file)
@@ -45,7 +45,7 @@ xfs_qm_fill_state(
        tstate->ino_warnlimit = q->qi_iwarnlimit;
        tstate->rt_spc_warnlimit = q->qi_rtbwarnlimit;
        if (tempqip)
-               IRELE(ip);
+               xfs_irele(ip);
 }
 
 /*
index 86d7d2f7622604ceb5dfbbe1256f068fcd0da5e5..926ed314ffba1d78b88cbf80d2d9cdeef3cc0fe3 100644 (file)
@@ -1207,7 +1207,7 @@ xfs_rtmount_inodes(
        ASSERT(sbp->sb_rsumino != NULLFSINO);
        error = xfs_iget(mp, NULL, sbp->sb_rsumino, 0, 0, &mp->m_rsumip);
        if (error) {
-               IRELE(mp->m_rbmip);
+               xfs_irele(mp->m_rbmip);
                return error;
        }
        ASSERT(mp->m_rsumip != NULL);
@@ -1219,9 +1219,9 @@ xfs_rtunmount_inodes(
        struct xfs_mount        *mp)
 {
        if (mp->m_rbmip)
-               IRELE(mp->m_rbmip);
+               xfs_irele(mp->m_rbmip);
        if (mp->m_rsumip)
-               IRELE(mp->m_rsumip);
+               xfs_irele(mp->m_rsumip);
 }
 
 /*
index ce801aedbcdce199bf3cae754252704c2e8e9526..2bfe7fbbedb251805d93b497409da88b0e0ad144 100644 (file)
@@ -364,7 +364,7 @@ out_release_inode:
         */
        if (ip) {
                xfs_finish_inode_setup(ip);
-               IRELE(ip);
+               xfs_irele(ip);
        }
 
        xfs_qm_dqrele(udqp);