aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2018-08-07 13:57:13 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2018-08-07 13:57:13 -0400
commit73971b172a435079340007bee12b4944cc599a8a (patch)
treed023a9d243196397d8715402e08027ae0ca0e5d9 /fs/xfs
parent2ba090d521c5e09f32316c179d25bb6f699d3568 (diff)
xfs: remove dead error handling code in xfs_dquot_disk_alloc()
Colin Ian King reports that commit 82ff27bc52 ("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: 82ff27bc52 ("xfs: automatic dfops buffer relogging") Reported-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_dquot.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 70a76ac41f01..87e6dd5326d5 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -311,7 +311,7 @@ xfs_dquot_disk_alloc(
311 XFS_DQUOT_CLUSTER_SIZE_FSB, XFS_BMAPI_METADATA, 311 XFS_DQUOT_CLUSTER_SIZE_FSB, XFS_BMAPI_METADATA,
312 XFS_QM_DQALLOC_SPACE_RES(mp), &map, &nmaps); 312 XFS_QM_DQALLOC_SPACE_RES(mp), &map, &nmaps);
313 if (error) 313 if (error)
314 goto error0; 314 return error;
315 ASSERT(map.br_blockcount == XFS_DQUOT_CLUSTER_SIZE_FSB); 315 ASSERT(map.br_blockcount == XFS_DQUOT_CLUSTER_SIZE_FSB);
316 ASSERT(nmaps == 1); 316 ASSERT(nmaps == 1);
317 ASSERT((map.br_startblock != DELAYSTARTBLOCK) && 317 ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
@@ -325,10 +325,8 @@ xfs_dquot_disk_alloc(
325 /* now we can just get the buffer (there's nothing to read yet) */ 325 /* now we can just get the buffer (there's nothing to read yet) */
326 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, dqp->q_blkno, 326 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, dqp->q_blkno,
327 mp->m_quotainfo->qi_dqchunklen, 0); 327 mp->m_quotainfo->qi_dqchunklen, 0);
328 if (!bp) { 328 if (!bp)
329 error = -ENOMEM; 329 return -ENOMEM;
330 goto error1;
331 }
332 bp->b_ops = &xfs_dquot_buf_ops; 330 bp->b_ops = &xfs_dquot_buf_ops;
333 331
334 /* 332 /*
@@ -349,10 +347,8 @@ xfs_dquot_disk_alloc(
349 * the buffer locked across the _defer_finish call. We can now do 347 * the buffer locked across the _defer_finish call. We can now do
350 * this correctly with xfs_defer_bjoin. 348 * this correctly with xfs_defer_bjoin.
351 * 349 *
352 * Above, we allocated a disk block for the dquot information and 350 * Above, we allocated a disk block for the dquot information and used
353 * used get_buf to initialize the dquot. If the _defer_bjoin fails, 351 * get_buf to initialize the dquot. If the _defer_finish fails, the old
354 * the buffer is still locked to *tpp, so we must _bhold_release and
355 * then _trans_brelse the buffer. If the _defer_finish fails, the old
356 * transaction is gone but the new buffer is not joined or held to any 352 * transaction is gone but the new buffer is not joined or held to any
357 * transaction, so we must _buf_relse it. 353 * transaction, so we must _buf_relse it.
358 * 354 *
@@ -362,24 +358,14 @@ xfs_dquot_disk_alloc(
362 * manually or by committing the transaction. 358 * manually or by committing the transaction.
363 */ 359 */
364 xfs_trans_bhold(tp, bp); 360 xfs_trans_bhold(tp, bp);
365 if (error) {
366 xfs_trans_bhold_release(tp, bp);
367 xfs_trans_brelse(tp, bp);
368 goto error1;
369 }
370 error = xfs_defer_finish(tpp); 361 error = xfs_defer_finish(tpp);
371 tp = *tpp; 362 tp = *tpp;
372 if (error) { 363 if (error) {
373 xfs_buf_relse(bp); 364 xfs_buf_relse(bp);
374 goto error0; 365 return error;
375 } 366 }
376 *bpp = bp; 367 *bpp = bp;
377 return 0; 368 return 0;
378
379error1:
380 xfs_defer_cancel(tp);
381error0:
382 return error;
383} 369}
384 370
385/* 371/*