[XFS] kill usesless IHOLD calls in xfs_remove and xfs_rmdir
The VFS always has an inode reference when we call these functions. So we only need to grab a signle reference to each inode that's joined to a transaction - all the other bumping and dropping is as useless as the comments describing the IRIX semantics. SGI-PV: 976035 SGI-Modid: xfs-linux-melb:xfs-kern:30912a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
This commit is contained in:
parent
82dab941a1
commit
5df78e73d3
|
@ -2162,20 +2162,6 @@ xfs_remove(
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* We need to get a reference to ip before we get our log
|
|
||||||
* reservation. The reason for this is that we cannot call
|
|
||||||
* xfs_iget for an inode for which we do not have a reference
|
|
||||||
* once we've acquired a log reservation. This is because the
|
|
||||||
* inode we are trying to get might be in xfs_inactive going
|
|
||||||
* for a log reservation. Since we'll have to wait for the
|
|
||||||
* inactive code to complete before returning from xfs_iget,
|
|
||||||
* we need to make sure that we don't have log space reserved
|
|
||||||
* when we call xfs_iget. Instead we get an unlocked reference
|
|
||||||
* to the inode before getting our log reservation.
|
|
||||||
*/
|
|
||||||
IHOLD(ip);
|
|
||||||
|
|
||||||
xfs_itrace_entry(ip);
|
xfs_itrace_entry(ip);
|
||||||
xfs_itrace_ref(ip);
|
xfs_itrace_ref(ip);
|
||||||
|
|
||||||
|
@ -2184,7 +2170,6 @@ xfs_remove(
|
||||||
error = XFS_QM_DQATTACH(mp, ip, 0);
|
error = XFS_QM_DQATTACH(mp, ip, 0);
|
||||||
if (error) {
|
if (error) {
|
||||||
REMOVE_DEBUG_TRACE(__LINE__);
|
REMOVE_DEBUG_TRACE(__LINE__);
|
||||||
IRELE(ip);
|
|
||||||
goto std_return;
|
goto std_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2211,7 +2196,6 @@ xfs_remove(
|
||||||
ASSERT(error != ENOSPC);
|
ASSERT(error != ENOSPC);
|
||||||
REMOVE_DEBUG_TRACE(__LINE__);
|
REMOVE_DEBUG_TRACE(__LINE__);
|
||||||
xfs_trans_cancel(tp, 0);
|
xfs_trans_cancel(tp, 0);
|
||||||
IRELE(ip);
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2219,7 +2203,6 @@ xfs_remove(
|
||||||
if (error) {
|
if (error) {
|
||||||
REMOVE_DEBUG_TRACE(__LINE__);
|
REMOVE_DEBUG_TRACE(__LINE__);
|
||||||
xfs_trans_cancel(tp, cancel_flags);
|
xfs_trans_cancel(tp, cancel_flags);
|
||||||
IRELE(ip);
|
|
||||||
goto std_return;
|
goto std_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2227,6 +2210,7 @@ xfs_remove(
|
||||||
* At this point, we've gotten both the directory and the entry
|
* At this point, we've gotten both the directory and the entry
|
||||||
* inodes locked.
|
* inodes locked.
|
||||||
*/
|
*/
|
||||||
|
IHOLD(ip);
|
||||||
xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
|
xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
|
||||||
|
|
||||||
IHOLD(dp);
|
IHOLD(dp);
|
||||||
|
@ -2259,12 +2243,6 @@ xfs_remove(
|
||||||
*/
|
*/
|
||||||
link_zero = (ip)->i_d.di_nlink==0;
|
link_zero = (ip)->i_d.di_nlink==0;
|
||||||
|
|
||||||
/*
|
|
||||||
* Take an extra ref on the inode so that it doesn't
|
|
||||||
* go to xfs_inactive() from within the commit.
|
|
||||||
*/
|
|
||||||
IHOLD(ip);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is a synchronous mount, make sure that the
|
* If this is a synchronous mount, make sure that the
|
||||||
* remove transaction goes to disk before returning to
|
* remove transaction goes to disk before returning to
|
||||||
|
@ -2281,10 +2259,8 @@ xfs_remove(
|
||||||
}
|
}
|
||||||
|
|
||||||
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
|
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
|
||||||
if (error) {
|
if (error)
|
||||||
IRELE(ip);
|
|
||||||
goto std_return;
|
goto std_return;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we are using filestreams, kill the stream association.
|
* If we are using filestreams, kill the stream association.
|
||||||
|
@ -2296,7 +2272,6 @@ xfs_remove(
|
||||||
xfs_filestream_deassociate(ip);
|
xfs_filestream_deassociate(ip);
|
||||||
|
|
||||||
xfs_itrace_exit(ip);
|
xfs_itrace_exit(ip);
|
||||||
IRELE(ip);
|
|
||||||
|
|
||||||
/* Fall through to std_return with error = 0 */
|
/* Fall through to std_return with error = 0 */
|
||||||
std_return:
|
std_return:
|
||||||
|
@ -2325,8 +2300,6 @@ xfs_remove(
|
||||||
cancel_flags |= XFS_TRANS_ABORT;
|
cancel_flags |= XFS_TRANS_ABORT;
|
||||||
xfs_trans_cancel(tp, cancel_flags);
|
xfs_trans_cancel(tp, cancel_flags);
|
||||||
|
|
||||||
IRELE(ip);
|
|
||||||
|
|
||||||
goto std_return;
|
goto std_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2698,7 +2671,6 @@ xfs_rmdir(
|
||||||
struct xfs_name *name,
|
struct xfs_name *name,
|
||||||
xfs_inode_t *cdp)
|
xfs_inode_t *cdp)
|
||||||
{
|
{
|
||||||
bhv_vnode_t *dir_vp = XFS_ITOV(dp);
|
|
||||||
xfs_mount_t *mp = dp->i_mount;
|
xfs_mount_t *mp = dp->i_mount;
|
||||||
xfs_trans_t *tp;
|
xfs_trans_t *tp;
|
||||||
int error;
|
int error;
|
||||||
|
@ -2723,20 +2695,6 @@ xfs_rmdir(
|
||||||
return XFS_ERROR(error);
|
return XFS_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* We need to get a reference to cdp before we get our log
|
|
||||||
* reservation. The reason for this is that we cannot call
|
|
||||||
* xfs_iget for an inode for which we do not have a reference
|
|
||||||
* once we've acquired a log reservation. This is because the
|
|
||||||
* inode we are trying to get might be in xfs_inactive going
|
|
||||||
* for a log reservation. Since we'll have to wait for the
|
|
||||||
* inactive code to complete before returning from xfs_iget,
|
|
||||||
* we need to make sure that we don't have log space reserved
|
|
||||||
* when we call xfs_iget. Instead we get an unlocked reference
|
|
||||||
* to the inode before getting our log reservation.
|
|
||||||
*/
|
|
||||||
IHOLD(cdp);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the dquots for the inodes.
|
* Get the dquots for the inodes.
|
||||||
*/
|
*/
|
||||||
|
@ -2744,7 +2702,6 @@ xfs_rmdir(
|
||||||
if (!error)
|
if (!error)
|
||||||
error = XFS_QM_DQATTACH(mp, cdp, 0);
|
error = XFS_QM_DQATTACH(mp, cdp, 0);
|
||||||
if (error) {
|
if (error) {
|
||||||
IRELE(cdp);
|
|
||||||
REMOVE_DEBUG_TRACE(__LINE__);
|
REMOVE_DEBUG_TRACE(__LINE__);
|
||||||
goto std_return;
|
goto std_return;
|
||||||
}
|
}
|
||||||
|
@ -2771,7 +2728,6 @@ xfs_rmdir(
|
||||||
if (error) {
|
if (error) {
|
||||||
ASSERT(error != ENOSPC);
|
ASSERT(error != ENOSPC);
|
||||||
cancel_flags = 0;
|
cancel_flags = 0;
|
||||||
IRELE(cdp);
|
|
||||||
goto error_return;
|
goto error_return;
|
||||||
}
|
}
|
||||||
XFS_BMAP_INIT(&free_list, &first_block);
|
XFS_BMAP_INIT(&free_list, &first_block);
|
||||||
|
@ -2785,14 +2741,13 @@ xfs_rmdir(
|
||||||
error = xfs_lock_dir_and_entry(dp, cdp);
|
error = xfs_lock_dir_and_entry(dp, cdp);
|
||||||
if (error) {
|
if (error) {
|
||||||
xfs_trans_cancel(tp, cancel_flags);
|
xfs_trans_cancel(tp, cancel_flags);
|
||||||
IRELE(cdp);
|
|
||||||
goto std_return;
|
goto std_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IHOLD(dp);
|
||||||
xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
|
xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
|
||||||
VN_HOLD(dir_vp);
|
|
||||||
|
|
||||||
xfs_itrace_ref(cdp);
|
IHOLD(cdp);
|
||||||
xfs_trans_ijoin(tp, cdp, XFS_ILOCK_EXCL);
|
xfs_trans_ijoin(tp, cdp, XFS_ILOCK_EXCL);
|
||||||
|
|
||||||
ASSERT(cdp->i_d.di_nlink >= 2);
|
ASSERT(cdp->i_d.di_nlink >= 2);
|
||||||
|
@ -2845,12 +2800,6 @@ xfs_rmdir(
|
||||||
/* Determine these before committing transaction */
|
/* Determine these before committing transaction */
|
||||||
last_cdp_link = (cdp)->i_d.di_nlink==0;
|
last_cdp_link = (cdp)->i_d.di_nlink==0;
|
||||||
|
|
||||||
/*
|
|
||||||
* Take an extra ref on the child vnode so that it
|
|
||||||
* does not go to xfs_inactive() from within the commit.
|
|
||||||
*/
|
|
||||||
IHOLD(cdp);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is a synchronous mount, make sure that the
|
* If this is a synchronous mount, make sure that the
|
||||||
* rmdir transaction goes to disk before returning to
|
* rmdir transaction goes to disk before returning to
|
||||||
|
@ -2865,19 +2814,15 @@ xfs_rmdir(
|
||||||
xfs_bmap_cancel(&free_list);
|
xfs_bmap_cancel(&free_list);
|
||||||
xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES |
|
xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES |
|
||||||
XFS_TRANS_ABORT));
|
XFS_TRANS_ABORT));
|
||||||
IRELE(cdp);
|
|
||||||
goto std_return;
|
goto std_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
|
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
|
||||||
if (error) {
|
if (error) {
|
||||||
IRELE(cdp);
|
|
||||||
goto std_return;
|
goto std_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IRELE(cdp);
|
|
||||||
|
|
||||||
/* Fall through to std_return with error = 0 or the errno
|
/* Fall through to std_return with error = 0 or the errno
|
||||||
* from xfs_trans_commit. */
|
* from xfs_trans_commit. */
|
||||||
std_return:
|
std_return:
|
||||||
|
|
Loading…
Reference in New Issue