xfs: remove xfs_trans_unreserve_quota_nblks completely

xfs_trans_cancel will release all the quota resources that were reserved
on behalf of the transaction, so get rid of the explicit unreserve step.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
This commit is contained in:
Darrick J. Wong 2021-01-26 17:23:30 -08:00
parent 8554650003
commit 35b1101099
4 changed files with 7 additions and 17 deletions

View file

@ -820,12 +820,12 @@ xfs_alloc_file_space(
error = xfs_trans_reserve_quota_nblks(tp, ip, qblocks, error = xfs_trans_reserve_quota_nblks(tp, ip, qblocks,
0, quota_flag); 0, quota_flag);
if (error) if (error)
goto error1; goto error;
error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK, error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK,
XFS_IEXT_ADD_NOSPLIT_CNT); XFS_IEXT_ADD_NOSPLIT_CNT);
if (error) if (error)
goto error0; goto error;
xfs_trans_ijoin(tp, ip, 0); xfs_trans_ijoin(tp, ip, 0);
@ -833,7 +833,7 @@ xfs_alloc_file_space(
allocatesize_fsb, alloc_type, 0, imapp, allocatesize_fsb, alloc_type, 0, imapp,
&nimaps); &nimaps);
if (error) if (error)
goto error0; goto error;
/* /*
* Complete the transaction * Complete the transaction
@ -856,10 +856,7 @@ xfs_alloc_file_space(
return error; return error;
error0: /* unlock inode, unreserve quota blocks, cancel trans */ error:
xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag);
error1: /* Just cancel transaction */
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error; return error;

View file

@ -253,7 +253,7 @@ xfs_iomap_write_direct(
error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK, error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK,
XFS_IEXT_ADD_NOSPLIT_CNT); XFS_IEXT_ADD_NOSPLIT_CNT);
if (error) if (error)
goto out_res_cancel; goto out_trans_cancel;
xfs_trans_ijoin(tp, ip, 0); xfs_trans_ijoin(tp, ip, 0);
@ -265,7 +265,7 @@ xfs_iomap_write_direct(
error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb, bmapi_flags, 0, error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb, bmapi_flags, 0,
imap, &nimaps); imap, &nimaps);
if (error) if (error)
goto out_res_cancel; goto out_trans_cancel;
/* /*
* Complete the transaction * Complete the transaction
@ -289,8 +289,6 @@ out_unlock:
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error; return error;
out_res_cancel:
xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag);
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
goto out_unlock; goto out_unlock;

View file

@ -164,8 +164,6 @@ xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t blocks)
#define xfs_qm_unmount_quotas(mp) #define xfs_qm_unmount_quotas(mp)
#endif /* CONFIG_XFS_QUOTA */ #endif /* CONFIG_XFS_QUOTA */
#define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \
xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags)
#define xfs_trans_reserve_quota(tp, mp, ud, gd, pd, nb, ni, f) \ #define xfs_trans_reserve_quota(tp, mp, ud, gd, pd, nb, ni, f) \
xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \ xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \
f | XFS_QMOPT_RES_REGBLKS) f | XFS_QMOPT_RES_REGBLKS)

View file

@ -411,7 +411,7 @@ xfs_reflink_allocate_cow(
XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC, 0, cmap, XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC, 0, cmap,
&nimaps); &nimaps);
if (error) if (error)
goto out_unreserve; goto out_trans_cancel;
xfs_inode_set_cowblocks_tag(ip); xfs_inode_set_cowblocks_tag(ip);
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
@ -436,9 +436,6 @@ convert:
trace_xfs_reflink_convert_cow(ip, cmap); trace_xfs_reflink_convert_cow(ip, cmap);
return xfs_reflink_convert_cow_locked(ip, offset_fsb, count_fsb); return xfs_reflink_convert_cow_locked(ip, offset_fsb, count_fsb);
out_unreserve:
xfs_trans_unreserve_quota_nblks(tp, ip, (long)resblks, 0,
XFS_QMOPT_RES_REGBLKS);
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
return error; return error;