xfs: remove xfs_trans_unreserve_quota_nblks completely
authorDarrick J. Wong <djwong@kernel.org>
Wed, 27 Jan 2021 01:23:30 +0000 (17:23 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 3 Feb 2021 17:18:49 +0000 (09:18 -0800)
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>
fs/xfs/xfs_bmap_util.c
fs/xfs/xfs_iomap.c
fs/xfs/xfs_quota.h
fs/xfs/xfs_reflink.c

index 792809debaaa7e4776b0b66df727970bed59e8c3..ae2d98af693cb5fd59902ca1f07e20d3cc742d2f 100644 (file)
@@ -820,12 +820,12 @@ xfs_alloc_file_space(
                error = xfs_trans_reserve_quota_nblks(tp, ip, qblocks,
                                                      0, quota_flag);
                if (error)
-                       goto error1;
+                       goto error;
 
                error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK,
                                XFS_IEXT_ADD_NOSPLIT_CNT);
                if (error)
-                       goto error0;
+                       goto error;
 
                xfs_trans_ijoin(tp, ip, 0);
 
@@ -833,7 +833,7 @@ xfs_alloc_file_space(
                                        allocatesize_fsb, alloc_type, 0, imapp,
                                        &nimaps);
                if (error)
-                       goto error0;
+                       goto error;
 
                /*
                 * Complete the transaction
@@ -856,10 +856,7 @@ xfs_alloc_file_space(
 
        return error;
 
-error0:        /* unlock inode, unreserve quota blocks, cancel trans */
-       xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag);
-
-error1:        /* Just cancel transaction */
+error:
        xfs_trans_cancel(tp);
        xfs_iunlock(ip, XFS_ILOCK_EXCL);
        return error;
index b05cfeb0930146eb06fecb7e5aad2f42995248e9..b046eadd3b2189ce3a9df93221c41833db47a302 100644 (file)
@@ -253,7 +253,7 @@ xfs_iomap_write_direct(
        error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK,
                        XFS_IEXT_ADD_NOSPLIT_CNT);
        if (error)
-               goto out_res_cancel;
+               goto out_trans_cancel;
 
        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,
                                imap, &nimaps);
        if (error)
-               goto out_res_cancel;
+               goto out_trans_cancel;
 
        /*
         * Complete the transaction
@@ -289,8 +289,6 @@ out_unlock:
        xfs_iunlock(ip, XFS_ILOCK_EXCL);
        return error;
 
-out_res_cancel:
-       xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag);
 out_trans_cancel:
        xfs_trans_cancel(tp);
        goto out_unlock;
index 1d1a1634ea291759347a83778f88a2de5018b7d8..31d0de899cc4707d9e97a4fa5fe968be0dd14a59 100644 (file)
@@ -164,8 +164,6 @@ xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t blocks)
 #define xfs_qm_unmount_quotas(mp)
 #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) \
        xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \
                                f | XFS_QMOPT_RES_REGBLKS)
index bea64ed5a57fe45808e7c152f248021bfd28b34f..15435229bc1f22c8a38ba0f87dd1214c2b2554f4 100644 (file)
@@ -411,7 +411,7 @@ xfs_reflink_allocate_cow(
                        XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC, 0, cmap,
                        &nimaps);
        if (error)
-               goto out_unreserve;
+               goto out_trans_cancel;
 
        xfs_inode_set_cowblocks_tag(ip);
        error = xfs_trans_commit(tp);
@@ -436,9 +436,6 @@ convert:
        trace_xfs_reflink_convert_cow(ip, cmap);
        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:
        xfs_trans_cancel(tp);
        return error;