Commit 44a8736b authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: clean up IRELE/iput callsites

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: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarCarlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent 89c3e8cf
...@@ -711,7 +711,7 @@ xchk_get_inode( ...@@ -711,7 +711,7 @@ xchk_get_inode(
return error; return error;
} }
if (VFS_I(ip)->i_generation != sc->sm->sm_gen) { if (VFS_I(ip)->i_generation != sc->sm->sm_gen) {
iput(VFS_I(ip)); xfs_irele(ip);
return -ENOENT; return -ENOENT;
} }
......
...@@ -87,7 +87,7 @@ xchk_dir_check_ftype( ...@@ -87,7 +87,7 @@ xchk_dir_check_ftype(
xfs_mode_to_ftype(VFS_I(ip)->i_mode)); xfs_mode_to_ftype(VFS_I(ip)->i_mode));
if (ino_dtype != dtype) if (ino_dtype != dtype)
xchk_fblock_set_corrupt(sdc->sc, XFS_DATA_FORK, offset); xchk_fblock_set_corrupt(sdc->sc, XFS_DATA_FORK, offset);
iput(VFS_I(ip)); xfs_irele(ip);
out: out:
return error; return error;
} }
......
...@@ -230,11 +230,11 @@ xchk_parent_validate( ...@@ -230,11 +230,11 @@ xchk_parent_validate(
/* Drat, parent changed. Try again! */ /* Drat, parent changed. Try again! */
if (dnum != dp->i_ino) { if (dnum != dp->i_ino) {
iput(VFS_I(dp)); xfs_irele(dp);
*try_again = true; *try_again = true;
return 0; return 0;
} }
iput(VFS_I(dp)); xfs_irele(dp);
/* /*
* '..' didn't change, so check that there was only one entry * '..' didn't change, so check that there was only one entry
...@@ -247,7 +247,7 @@ xchk_parent_validate( ...@@ -247,7 +247,7 @@ xchk_parent_validate(
out_unlock: out_unlock:
xfs_iunlock(dp, XFS_IOLOCK_SHARED); xfs_iunlock(dp, XFS_IOLOCK_SHARED);
out_rele: out_rele:
iput(VFS_I(dp)); xfs_irele(dp);
out: out:
return error; return error;
} }
......
...@@ -183,7 +183,7 @@ xchk_teardown( ...@@ -183,7 +183,7 @@ xchk_teardown(
xfs_iunlock(sc->ip, sc->ilock_flags); xfs_iunlock(sc->ip, sc->ilock_flags);
if (sc->ip != ip_in && if (sc->ip != ip_in &&
!xfs_internal_inum(sc->mp, sc->ip->i_ino)) !xfs_internal_inum(sc->mp, sc->ip->i_ino))
iput(VFS_I(sc->ip)); xfs_irele(sc->ip);
sc->ip = NULL; sc->ip = NULL;
} }
if (sc->has_quotaofflock) if (sc->has_quotaofflock)
......
...@@ -497,7 +497,7 @@ xfs_bui_recover( ...@@ -497,7 +497,7 @@ xfs_bui_recover(
xfs_defer_move(dfops, tp->t_dfops); xfs_defer_move(dfops, tp->t_dfops);
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
IRELE(ip); xfs_irele(ip);
return error; return error;
...@@ -506,7 +506,7 @@ xfs_bui_recover( ...@@ -506,7 +506,7 @@ xfs_bui_recover(
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
if (ip) { if (ip) {
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
IRELE(ip); xfs_irele(ip);
} }
return error; return error;
} }
...@@ -150,7 +150,7 @@ xfs_nfs_get_inode( ...@@ -150,7 +150,7 @@ xfs_nfs_get_inode(
} }
if (VFS_I(ip)->i_generation != generation) { if (VFS_I(ip)->i_generation != generation) {
IRELE(ip); xfs_irele(ip);
return ERR_PTR(-ESTALE); return ERR_PTR(-ESTALE);
} }
......
...@@ -340,7 +340,7 @@ xfs_filestream_lookup_ag( ...@@ -340,7 +340,7 @@ xfs_filestream_lookup_ag(
if (xfs_filestream_pick_ag(pip, startag, &ag, 0, 0)) if (xfs_filestream_pick_ag(pip, startag, &ag, 0, 0))
ag = NULLAGNUMBER; ag = NULLAGNUMBER;
out: out:
IRELE(pip); xfs_irele(pip);
return ag; return ag;
} }
...@@ -389,7 +389,7 @@ xfs_filestream_new_ag( ...@@ -389,7 +389,7 @@ xfs_filestream_new_ag(
if (mru) if (mru)
xfs_fstrm_free_func(mp, mru); xfs_fstrm_free_func(mp, mru);
IRELE(pip); xfs_irele(pip);
exit: exit:
if (*agp == NULLAGNUMBER) if (*agp == NULLAGNUMBER)
*agp = 0; *agp = 0;
......
...@@ -716,7 +716,7 @@ xfs_icache_inode_is_allocated( ...@@ -716,7 +716,7 @@ xfs_icache_inode_is_allocated(
return error; return error;
*inuse = !!(VFS_I(ip)->i_mode); *inuse = !!(VFS_I(ip)->i_mode);
IRELE(ip); xfs_irele(ip);
return 0; return 0;
} }
...@@ -856,7 +856,7 @@ xfs_inode_ag_walk( ...@@ -856,7 +856,7 @@ xfs_inode_ag_walk(
xfs_iflags_test(batch[i], XFS_INEW)) xfs_iflags_test(batch[i], XFS_INEW))
xfs_inew_wait(batch[i]); xfs_inew_wait(batch[i]);
error = execute(batch[i], flags, args); error = execute(batch[i], flags, args);
IRELE(batch[i]); xfs_irele(batch[i]);
if (error == -EAGAIN) { if (error == -EAGAIN) {
skipped++; skipped++;
continue; continue;
......
...@@ -1276,7 +1276,7 @@ xfs_create( ...@@ -1276,7 +1276,7 @@ xfs_create(
*/ */
if (ip) { if (ip) {
xfs_finish_inode_setup(ip); xfs_finish_inode_setup(ip);
IRELE(ip); xfs_irele(ip);
} }
xfs_qm_dqrele(udqp); xfs_qm_dqrele(udqp);
...@@ -1371,7 +1371,7 @@ xfs_create_tmpfile( ...@@ -1371,7 +1371,7 @@ xfs_create_tmpfile(
*/ */
if (ip) { if (ip) {
xfs_finish_inode_setup(ip); xfs_finish_inode_setup(ip);
IRELE(ip); xfs_irele(ip);
} }
xfs_qm_dqrele(udqp); xfs_qm_dqrele(udqp);
...@@ -3134,14 +3134,14 @@ xfs_rename( ...@@ -3134,14 +3134,14 @@ xfs_rename(
error = xfs_finish_rename(tp); error = xfs_finish_rename(tp);
if (wip) if (wip)
IRELE(wip); xfs_irele(wip);
return error; return error;
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
out_release_wip: out_release_wip:
if (wip) if (wip)
IRELE(wip); xfs_irele(wip);
return error; return error;
} }
...@@ -3597,3 +3597,12 @@ xfs_iflush_int( ...@@ -3597,3 +3597,12 @@ xfs_iflush_int(
corrupt_out: corrupt_out:
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
/* Release an inode. */
void
xfs_irele(
struct xfs_inode *ip)
{
trace_xfs_irele(ip, _RET_IP_);
iput(VFS_I(ip));
}
...@@ -483,11 +483,7 @@ static inline void xfs_setup_existing_inode(struct xfs_inode *ip) ...@@ -483,11 +483,7 @@ static inline void xfs_setup_existing_inode(struct xfs_inode *ip)
xfs_finish_inode_setup(ip); xfs_finish_inode_setup(ip);
} }
#define IRELE(ip) \ void xfs_irele(struct xfs_inode *ip);
do { \
trace_xfs_irele(ip, _THIS_IP_); \
iput(VFS_I(ip)); \
} while (0)
extern struct kmem_zone *xfs_inode_zone; extern struct kmem_zone *xfs_inode_zone;
......
...@@ -209,7 +209,7 @@ xfs_generic_create( ...@@ -209,7 +209,7 @@ xfs_generic_create(
xfs_finish_inode_setup(ip); xfs_finish_inode_setup(ip);
if (!tmpfile) if (!tmpfile)
xfs_cleanup_inode(dir, inode, dentry); xfs_cleanup_inode(dir, inode, dentry);
iput(inode); xfs_irele(ip);
goto out_free_acl; goto out_free_acl;
} }
...@@ -391,7 +391,7 @@ xfs_vn_symlink( ...@@ -391,7 +391,7 @@ xfs_vn_symlink(
out_cleanup_inode: out_cleanup_inode:
xfs_finish_inode_setup(cip); xfs_finish_inode_setup(cip);
xfs_cleanup_inode(dir, inode, dentry); xfs_cleanup_inode(dir, inode, dentry);
iput(inode); xfs_irele(cip);
out: out:
return error; return error;
} }
......
...@@ -114,7 +114,7 @@ xfs_bulkstat_one_int( ...@@ -114,7 +114,7 @@ xfs_bulkstat_one_int(
break; break;
} }
xfs_iunlock(ip, XFS_ILOCK_SHARED); xfs_iunlock(ip, XFS_ILOCK_SHARED);
IRELE(ip); xfs_irele(ip);
error = formatter(buffer, ubsize, ubused, buf); error = formatter(buffer, ubsize, ubused, buf);
if (!error) if (!error)
......
...@@ -5087,11 +5087,11 @@ xlog_recover_process_one_iunlink( ...@@ -5087,11 +5087,11 @@ xlog_recover_process_one_iunlink(
*/ */
ip->i_d.di_dmevmask = 0; ip->i_d.di_dmevmask = 0;
IRELE(ip); xfs_irele(ip);
return agino; return agino;
fail_iput: fail_iput:
IRELE(ip); xfs_irele(ip);
fail: fail:
/* /*
* We can't read in the inode this bucket points to, or this inode * We can't read in the inode this bucket points to, or this inode
......
...@@ -1039,7 +1039,7 @@ xfs_mountfs( ...@@ -1039,7 +1039,7 @@ xfs_mountfs(
out_rtunmount: out_rtunmount:
xfs_rtunmount_inodes(mp); xfs_rtunmount_inodes(mp);
out_rele_rip: out_rele_rip:
IRELE(rip); xfs_irele(rip);
/* Clean out dquots that might be in memory after quotacheck. */ /* Clean out dquots that might be in memory after quotacheck. */
xfs_qm_unmount(mp); xfs_qm_unmount(mp);
/* /*
...@@ -1095,7 +1095,7 @@ xfs_unmountfs( ...@@ -1095,7 +1095,7 @@ xfs_unmountfs(
xfs_fs_unreserve_ag_blocks(mp); xfs_fs_unreserve_ag_blocks(mp);
xfs_qm_unmount_quotas(mp); xfs_qm_unmount_quotas(mp);
xfs_rtunmount_inodes(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 * We can potentially deadlock here if we have an inode cluster
......
...@@ -231,15 +231,15 @@ xfs_qm_unmount_quotas( ...@@ -231,15 +231,15 @@ xfs_qm_unmount_quotas(
*/ */
if (mp->m_quotainfo) { if (mp->m_quotainfo) {
if (mp->m_quotainfo->qi_uquotaip) { 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; mp->m_quotainfo->qi_uquotaip = NULL;
} }
if (mp->m_quotainfo->qi_gquotaip) { 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; mp->m_quotainfo->qi_gquotaip = NULL;
} }
if (mp->m_quotainfo->qi_pquotaip) { 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; mp->m_quotainfo->qi_pquotaip = NULL;
} }
} }
...@@ -1200,12 +1200,12 @@ xfs_qm_dqusage_adjust( ...@@ -1200,12 +1200,12 @@ xfs_qm_dqusage_adjust(
goto error0; goto error0;
} }
IRELE(ip); xfs_irele(ip);
*res = BULKSTAT_RV_DIDONE; *res = BULKSTAT_RV_DIDONE;
return 0; return 0;
error0: error0:
IRELE(ip); xfs_irele(ip);
*res = BULKSTAT_RV_GIVEUP; *res = BULKSTAT_RV_GIVEUP;
return error; return error;
} }
...@@ -1575,11 +1575,11 @@ xfs_qm_init_quotainos( ...@@ -1575,11 +1575,11 @@ xfs_qm_init_quotainos(
error_rele: error_rele:
if (uip) if (uip)
IRELE(uip); xfs_irele(uip);
if (gip) if (gip)
IRELE(gip); xfs_irele(gip);
if (pip) if (pip)
IRELE(pip); xfs_irele(pip);
return error; return error;
} }
...@@ -1588,15 +1588,15 @@ xfs_qm_destroy_quotainos( ...@@ -1588,15 +1588,15 @@ xfs_qm_destroy_quotainos(
xfs_quotainfo_t *qi) xfs_quotainfo_t *qi)
{ {
if (qi->qi_uquotaip) { if (qi->qi_uquotaip) {
IRELE(qi->qi_uquotaip); xfs_irele(qi->qi_uquotaip);
qi->qi_uquotaip = NULL; /* paranoia */ qi->qi_uquotaip = NULL; /* paranoia */
} }
if (qi->qi_gquotaip) { if (qi->qi_gquotaip) {
IRELE(qi->qi_gquotaip); xfs_irele(qi->qi_gquotaip);
qi->qi_gquotaip = NULL; qi->qi_gquotaip = NULL;
} }
if (qi->qi_pquotaip) { if (qi->qi_pquotaip) {
IRELE(qi->qi_pquotaip); xfs_irele(qi->qi_pquotaip);
qi->qi_pquotaip = NULL; qi->qi_pquotaip = NULL;
} }
} }
......
...@@ -190,15 +190,15 @@ xfs_qm_scall_quotaoff( ...@@ -190,15 +190,15 @@ xfs_qm_scall_quotaoff(
* Release our quotainode references if we don't need them anymore. * Release our quotainode references if we don't need them anymore.
*/ */
if ((dqtype & XFS_QMOPT_UQUOTA) && q->qi_uquotaip) { if ((dqtype & XFS_QMOPT_UQUOTA) && q->qi_uquotaip) {
IRELE(q->qi_uquotaip); xfs_irele(q->qi_uquotaip);
q->qi_uquotaip = NULL; q->qi_uquotaip = NULL;
} }
if ((dqtype & XFS_QMOPT_GQUOTA) && q->qi_gquotaip) { if ((dqtype & XFS_QMOPT_GQUOTA) && q->qi_gquotaip) {
IRELE(q->qi_gquotaip); xfs_irele(q->qi_gquotaip);
q->qi_gquotaip = NULL; q->qi_gquotaip = NULL;
} }
if ((dqtype & XFS_QMOPT_PQUOTA) && q->qi_pquotaip) { if ((dqtype & XFS_QMOPT_PQUOTA) && q->qi_pquotaip) {
IRELE(q->qi_pquotaip); xfs_irele(q->qi_pquotaip);
q->qi_pquotaip = NULL; q->qi_pquotaip = NULL;
} }
...@@ -251,7 +251,7 @@ xfs_qm_scall_trunc_qfile( ...@@ -251,7 +251,7 @@ xfs_qm_scall_trunc_qfile(
out_unlock: out_unlock:
xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
out_put: out_put:
IRELE(ip); xfs_irele(ip);
return error; return error;
} }
......
...@@ -45,7 +45,7 @@ xfs_qm_fill_state( ...@@ -45,7 +45,7 @@ xfs_qm_fill_state(
tstate->ino_warnlimit = q->qi_iwarnlimit; tstate->ino_warnlimit = q->qi_iwarnlimit;
tstate->rt_spc_warnlimit = q->qi_rtbwarnlimit; tstate->rt_spc_warnlimit = q->qi_rtbwarnlimit;
if (tempqip) if (tempqip)
IRELE(ip); xfs_irele(ip);
} }
/* /*
......
...@@ -1207,7 +1207,7 @@ xfs_rtmount_inodes( ...@@ -1207,7 +1207,7 @@ xfs_rtmount_inodes(
ASSERT(sbp->sb_rsumino != NULLFSINO); ASSERT(sbp->sb_rsumino != NULLFSINO);
error = xfs_iget(mp, NULL, sbp->sb_rsumino, 0, 0, &mp->m_rsumip); error = xfs_iget(mp, NULL, sbp->sb_rsumino, 0, 0, &mp->m_rsumip);
if (error) { if (error) {
IRELE(mp->m_rbmip); xfs_irele(mp->m_rbmip);
return error; return error;
} }
ASSERT(mp->m_rsumip != NULL); ASSERT(mp->m_rsumip != NULL);
...@@ -1219,9 +1219,9 @@ xfs_rtunmount_inodes( ...@@ -1219,9 +1219,9 @@ xfs_rtunmount_inodes(
struct xfs_mount *mp) struct xfs_mount *mp)
{ {
if (mp->m_rbmip) if (mp->m_rbmip)
IRELE(mp->m_rbmip); xfs_irele(mp->m_rbmip);
if (mp->m_rsumip) if (mp->m_rsumip)
IRELE(mp->m_rsumip); xfs_irele(mp->m_rsumip);
} }
/* /*
......
...@@ -364,7 +364,7 @@ xfs_symlink( ...@@ -364,7 +364,7 @@ xfs_symlink(
*/ */
if (ip) { if (ip) {
xfs_finish_inode_setup(ip); xfs_finish_inode_setup(ip);
IRELE(ip); xfs_irele(ip);
} }
xfs_qm_dqrele(udqp); xfs_qm_dqrele(udqp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment