Commit 73971b17 authored by Brian Foster's avatar Brian Foster Committed by Darrick J. Wong

xfs: remove dead error handling code in xfs_dquot_disk_alloc()

Colin Ian King reports that commit 82ff27bc ("xfs: automatic dfops
buffer relogging") leaves around some dead error handling code in
xfs_dquot_disk_alloc(). This was discovered via Coverity scan.

Since the associated commit eliminates the act of joining a buffer
to a dfops, this intermediate error state is no longer possible and
the error handling code can be removed. Since the caller cancels the
transaction on error, which cancels the dfops, eliminate the
unnecessary xfs_defer_cancel() call and error handling labels.

Fixes: 82ff27bc ("xfs: automatic dfops buffer relogging")
Reported-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 2ba090d5
...@@ -311,7 +311,7 @@ xfs_dquot_disk_alloc( ...@@ -311,7 +311,7 @@ xfs_dquot_disk_alloc(
XFS_DQUOT_CLUSTER_SIZE_FSB, XFS_BMAPI_METADATA, XFS_DQUOT_CLUSTER_SIZE_FSB, XFS_BMAPI_METADATA,
XFS_QM_DQALLOC_SPACE_RES(mp), &map, &nmaps); XFS_QM_DQALLOC_SPACE_RES(mp), &map, &nmaps);
if (error) if (error)
goto error0; return error;
ASSERT(map.br_blockcount == XFS_DQUOT_CLUSTER_SIZE_FSB); ASSERT(map.br_blockcount == XFS_DQUOT_CLUSTER_SIZE_FSB);
ASSERT(nmaps == 1); ASSERT(nmaps == 1);
ASSERT((map.br_startblock != DELAYSTARTBLOCK) && ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
...@@ -325,10 +325,8 @@ xfs_dquot_disk_alloc( ...@@ -325,10 +325,8 @@ xfs_dquot_disk_alloc(
/* now we can just get the buffer (there's nothing to read yet) */ /* now we can just get the buffer (there's nothing to read yet) */
bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, dqp->q_blkno, bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, dqp->q_blkno,
mp->m_quotainfo->qi_dqchunklen, 0); mp->m_quotainfo->qi_dqchunklen, 0);
if (!bp) { if (!bp)
error = -ENOMEM; return -ENOMEM;
goto error1;
}
bp->b_ops = &xfs_dquot_buf_ops; bp->b_ops = &xfs_dquot_buf_ops;
/* /*
...@@ -349,10 +347,8 @@ xfs_dquot_disk_alloc( ...@@ -349,10 +347,8 @@ xfs_dquot_disk_alloc(
* the buffer locked across the _defer_finish call. We can now do * the buffer locked across the _defer_finish call. We can now do
* this correctly with xfs_defer_bjoin. * this correctly with xfs_defer_bjoin.
* *
* Above, we allocated a disk block for the dquot information and * Above, we allocated a disk block for the dquot information and used
* used get_buf to initialize the dquot. If the _defer_bjoin fails, * get_buf to initialize the dquot. If the _defer_finish fails, the old
* the buffer is still locked to *tpp, so we must _bhold_release and
* then _trans_brelse the buffer. If the _defer_finish fails, the old
* transaction is gone but the new buffer is not joined or held to any * transaction is gone but the new buffer is not joined or held to any
* transaction, so we must _buf_relse it. * transaction, so we must _buf_relse it.
* *
...@@ -362,24 +358,14 @@ xfs_dquot_disk_alloc( ...@@ -362,24 +358,14 @@ xfs_dquot_disk_alloc(
* manually or by committing the transaction. * manually or by committing the transaction.
*/ */
xfs_trans_bhold(tp, bp); xfs_trans_bhold(tp, bp);
if (error) {
xfs_trans_bhold_release(tp, bp);
xfs_trans_brelse(tp, bp);
goto error1;
}
error = xfs_defer_finish(tpp); error = xfs_defer_finish(tpp);
tp = *tpp; tp = *tpp;
if (error) { if (error) {
xfs_buf_relse(bp); xfs_buf_relse(bp);
goto error0; return error;
} }
*bpp = bp; *bpp = bp;
return 0; return 0;
error1:
xfs_defer_cancel(tp);
error0:
return error;
} }
/* /*
......
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