Skip to content

Commit ad4a747

Browse files
author
Darrick J. Wong
committed
xfs: clean up icreate quota reservation calls
Create a proper helper so that inode creation calls can reserve quota with a dedicated function. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Brian Foster <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]>
1 parent 35b1101 commit ad4a747

File tree

4 files changed

+31
-10
lines changed

4 files changed

+31
-10
lines changed

fs/xfs/xfs_inode.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,7 @@ xfs_create(
10371037
/*
10381038
* Reserve disk quota and the inode.
10391039
*/
1040-
error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp,
1041-
pdqp, resblks, 1, 0);
1040+
error = xfs_trans_reserve_quota_icreate(tp, udqp, gdqp, pdqp, resblks);
10421041
if (error)
10431042
goto out_trans_cancel;
10441043

@@ -1169,8 +1168,7 @@ xfs_create_tmpfile(
11691168
if (error)
11701169
goto out_release_inode;
11711170

1172-
error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp,
1173-
pdqp, resblks, 1, 0);
1171+
error = xfs_trans_reserve_quota_icreate(tp, udqp, gdqp, pdqp, resblks);
11741172
if (error)
11751173
goto out_trans_cancel;
11761174

fs/xfs/xfs_quota.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *,
8686
extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *,
8787
struct xfs_mount *, struct xfs_dquot *,
8888
struct xfs_dquot *, struct xfs_dquot *, int64_t, long, uint);
89+
int xfs_trans_reserve_quota_icreate(struct xfs_trans *tp,
90+
struct xfs_dquot *udqp, struct xfs_dquot *gdqp,
91+
struct xfs_dquot *pdqp, int64_t dblocks);
8992

9093
extern int xfs_qm_vop_dqalloc(struct xfs_inode *, kuid_t, kgid_t,
9194
prid_t, uint, struct xfs_dquot **, struct xfs_dquot **,
@@ -149,6 +152,13 @@ xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t blocks)
149152
return 0;
150153
}
151154

155+
static inline int
156+
xfs_trans_reserve_quota_icreate(struct xfs_trans *tp, struct xfs_dquot *udqp,
157+
struct xfs_dquot *gdqp, struct xfs_dquot *pdqp, int64_t dblocks)
158+
{
159+
return 0;
160+
}
161+
152162
#define xfs_qm_vop_create_dqattach(tp, ip, u, g, p)
153163
#define xfs_qm_vop_rename_dqattach(it) (0)
154164
#define xfs_qm_vop_chown(tp, ip, old, new) (NULL)
@@ -164,10 +174,6 @@ xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t blocks)
164174
#define xfs_qm_unmount_quotas(mp)
165175
#endif /* CONFIG_XFS_QUOTA */
166176

167-
#define xfs_trans_reserve_quota(tp, mp, ud, gd, pd, nb, ni, f) \
168-
xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \
169-
f | XFS_QMOPT_RES_REGBLKS)
170-
171177
static inline int
172178
xfs_quota_unreserve_blkres(struct xfs_inode *ip, int64_t blocks)
173179
{

fs/xfs/xfs_symlink.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ xfs_symlink(
215215
/*
216216
* Reserve disk quota : blocks and inode.
217217
*/
218-
error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp,
219-
pdqp, resblks, 1, 0);
218+
error = xfs_trans_reserve_quota_icreate(tp, udqp, gdqp, pdqp, resblks);
220219
if (error)
221220
goto out_trans_cancel;
222221

fs/xfs/xfs_trans_dquot.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,24 @@ xfs_trans_reserve_quota_nblks(
804804
nblks, ninos, flags);
805805
}
806806

807+
/* Change the quota reservations for an inode creation activity. */
808+
int
809+
xfs_trans_reserve_quota_icreate(
810+
struct xfs_trans *tp,
811+
struct xfs_dquot *udqp,
812+
struct xfs_dquot *gdqp,
813+
struct xfs_dquot *pdqp,
814+
int64_t dblocks)
815+
{
816+
struct xfs_mount *mp = tp->t_mountp;
817+
818+
if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp))
819+
return 0;
820+
821+
return xfs_trans_reserve_quota_bydquots(tp, mp, udqp, gdqp, pdqp,
822+
dblocks, 1, XFS_QMOPT_RES_REGBLKS);
823+
}
824+
807825
/*
808826
* This routine is called to allocate a quotaoff log item.
809827
*/

0 commit comments

Comments
 (0)