提交 86d7a720 编写于 作者: D Darrick J. Wong 提交者: Zheng Zengkai

xfs: create convenience wrappers for incore quota block reservations

mainline-inclusion
from mainline-v5.13-rc4
commit 85546500
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4KIAO
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/fs/xfs?h=v5.16-rc4&id=8554650003b8a66f3dd357692ab73101d088d938

----------------------------------------------------------------------

Create a couple of convenience wrappers for creating and deleting quota
block reservations against future changes.
Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NBrian Foster <bfoster@redhat.com>
Signed-off-by: NLihong Kou <koulihong@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 ba803695
...@@ -4000,8 +4000,7 @@ xfs_bmapi_reserve_delalloc( ...@@ -4000,8 +4000,7 @@ xfs_bmapi_reserve_delalloc(
* blocks. This number gets adjusted later. We return if we haven't * blocks. This number gets adjusted later. We return if we haven't
* allocated blocks already inside this loop. * allocated blocks already inside this loop.
*/ */
error = xfs_trans_reserve_quota_nblks(NULL, ip, (long)alen, 0, error = xfs_quota_reserve_blkres(ip, alen);
XFS_QMOPT_RES_REGBLKS);
if (error) if (error)
return error; return error;
...@@ -4047,8 +4046,7 @@ xfs_bmapi_reserve_delalloc( ...@@ -4047,8 +4046,7 @@ xfs_bmapi_reserve_delalloc(
xfs_mod_fdblocks(mp, alen, false); xfs_mod_fdblocks(mp, alen, false);
out_unreserve_quota: out_unreserve_quota:
if (XFS_IS_QUOTA_ON(mp)) if (XFS_IS_QUOTA_ON(mp))
xfs_trans_unreserve_quota_nblks(NULL, ip, (long)alen, 0, xfs_quota_unreserve_blkres(ip, alen);
XFS_QMOPT_RES_REGBLKS);
return error; return error;
} }
...@@ -4825,8 +4823,8 @@ xfs_bmap_del_extent_delay( ...@@ -4825,8 +4823,8 @@ xfs_bmap_del_extent_delay(
* sb counters as we might have to borrow some blocks for the * sb counters as we might have to borrow some blocks for the
* indirect block accounting. * indirect block accounting.
*/ */
error = xfs_trans_unreserve_quota_nblks(NULL, ip, del->br_blockcount, 0, ASSERT(!isrt);
isrt ? XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS); error = xfs_quota_unreserve_blkres(ip, del->br_blockcount);
if (error) if (error)
return error; return error;
ip->i_delayed_blks -= del->br_blockcount; ip->i_delayed_blks -= del->br_blockcount;
......
...@@ -108,6 +108,12 @@ extern void xfs_qm_mount_quotas(struct xfs_mount *); ...@@ -108,6 +108,12 @@ extern void xfs_qm_mount_quotas(struct xfs_mount *);
extern void xfs_qm_unmount(struct xfs_mount *); extern void xfs_qm_unmount(struct xfs_mount *);
extern void xfs_qm_unmount_quotas(struct xfs_mount *); extern void xfs_qm_unmount_quotas(struct xfs_mount *);
static inline int
xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t blocks)
{
return xfs_trans_reserve_quota_nblks(NULL, ip, blocks, 0,
XFS_QMOPT_RES_REGBLKS);
}
#else #else
static inline int static inline int
xfs_qm_vop_dqalloc(struct xfs_inode *ip, kuid_t kuid, kgid_t kgid, xfs_qm_vop_dqalloc(struct xfs_inode *ip, kuid_t kuid, kgid_t kgid,
...@@ -136,6 +142,13 @@ static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp, ...@@ -136,6 +142,13 @@ static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
{ {
return 0; return 0;
} }
static inline int
xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t blocks)
{
return 0;
}
#define xfs_qm_vop_create_dqattach(tp, ip, u, g, p) #define xfs_qm_vop_create_dqattach(tp, ip, u, g, p)
#define xfs_qm_vop_rename_dqattach(it) (0) #define xfs_qm_vop_rename_dqattach(it) (0)
#define xfs_qm_vop_chown(tp, ip, old, new) (NULL) #define xfs_qm_vop_chown(tp, ip, old, new) (NULL)
...@@ -157,6 +170,12 @@ static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp, ...@@ -157,6 +170,12 @@ static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
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)
static inline int
xfs_quota_unreserve_blkres(struct xfs_inode *ip, int64_t blocks)
{
return xfs_quota_reserve_blkres(ip, -blocks);
}
extern int xfs_mount_reset_sbqflags(struct xfs_mount *); extern int xfs_mount_reset_sbqflags(struct xfs_mount *);
#endif /* __XFS_QUOTA_H__ */ #endif /* __XFS_QUOTA_H__ */
...@@ -508,9 +508,8 @@ xfs_reflink_cancel_cow_blocks( ...@@ -508,9 +508,8 @@ xfs_reflink_cancel_cow_blocks(
xfs_bmap_del_extent_cow(ip, &icur, &got, &del); xfs_bmap_del_extent_cow(ip, &icur, &got, &del);
/* Remove the quota reservation */ /* Remove the quota reservation */
error = xfs_trans_unreserve_quota_nblks(NULL, ip, error = xfs_quota_unreserve_blkres(ip,
del.br_blockcount, 0, del.br_blockcount);
XFS_QMOPT_RES_REGBLKS);
if (error) if (error)
break; break;
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册