Skip to content

Commit ce6e7e7

Browse files
Eric Sandeendjwong
authored andcommitted
xfs: switch xfs_get_defquota to take explicit type
xfs_get_defquota() currently takes an xfs_dquot, and from that obtains the type of default quota we should get (user/group/project). But early in init, we don't have access to a fully set up quota, so that's not possible. The next patch needs go set up default quota timers early, so switch xfs_get_defquota to take an explicit type and add a helper function to obtain that type from an xfs_dquot for the existing callers. Signed-off-by: Eric Sandeen <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 3dbb9aa commit ce6e7e7

File tree

5 files changed

+26
-15
lines changed

5 files changed

+26
-15
lines changed

fs/xfs/xfs_dquot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ xfs_qm_adjust_dqlimits(
7575
int prealloc = 0;
7676

7777
ASSERT(d->d_id);
78-
defq = xfs_get_defquota(dq, q);
78+
defq = xfs_get_defquota(q, xfs_dquot_type(dq));
7979

8080
if (defq->bsoftlimit && !d->d_blk_softlimit) {
8181
d->d_blk_softlimit = cpu_to_be64(defq->bsoftlimit);

fs/xfs/xfs_qm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ xfs_qm_set_defquota(
558558
return;
559559

560560
ddqp = &dqp->q_core;
561-
defq = xfs_get_defquota(dqp, qinf);
561+
defq = xfs_get_defquota(qinf, xfs_dquot_type(dqp));
562562

563563
/*
564564
* Timers and warnings have been already set, let's just set the

fs/xfs/xfs_qm.h

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,17 @@ xfs_quota_inode(xfs_mount_t *mp, uint dq_flags)
113113
return NULL;
114114
}
115115

116+
static inline int
117+
xfs_dquot_type(struct xfs_dquot *dqp)
118+
{
119+
if (XFS_QM_ISUDQ(dqp))
120+
return XFS_DQ_USER;
121+
if (XFS_QM_ISGDQ(dqp))
122+
return XFS_DQ_GROUP;
123+
ASSERT(XFS_QM_ISPDQ(dqp));
124+
return XFS_DQ_PROJ;
125+
}
126+
116127
extern void xfs_trans_mod_dquot(struct xfs_trans *tp, struct xfs_dquot *dqp,
117128
uint field, int64_t delta);
118129
extern void xfs_trans_dqjoin(struct xfs_trans *, struct xfs_dquot *);
@@ -164,19 +175,19 @@ extern int xfs_qm_scall_quotaon(struct xfs_mount *, uint);
164175
extern int xfs_qm_scall_quotaoff(struct xfs_mount *, uint);
165176

166177
static inline struct xfs_def_quota *
167-
xfs_get_defquota(struct xfs_dquot *dqp, struct xfs_quotainfo *qi)
178+
xfs_get_defquota(struct xfs_quotainfo *qi, int type)
168179
{
169-
struct xfs_def_quota *defq;
170-
171-
if (XFS_QM_ISUDQ(dqp))
172-
defq = &qi->qi_usr_default;
173-
else if (XFS_QM_ISGDQ(dqp))
174-
defq = &qi->qi_grp_default;
175-
else {
176-
ASSERT(XFS_QM_ISPDQ(dqp));
177-
defq = &qi->qi_prj_default;
180+
switch (type) {
181+
case XFS_DQ_USER:
182+
return &qi->qi_usr_default;
183+
case XFS_DQ_GROUP:
184+
return &qi->qi_grp_default;
185+
case XFS_DQ_PROJ:
186+
return &qi->qi_prj_default;
187+
default:
188+
ASSERT(0);
189+
return NULL;
178190
}
179-
return defq;
180191
}
181192

182193
#endif /* __XFS_QM_H__ */

fs/xfs/xfs_qm_syscalls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ xfs_qm_scall_setqlim(
479479
goto out_unlock;
480480
}
481481

482-
defq = xfs_get_defquota(dqp, q);
482+
defq = xfs_get_defquota(q, xfs_dquot_type(dqp));
483483
xfs_dqunlock(dqp);
484484

485485
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_setqlim, 0, 0, 0, &tp);

fs/xfs/xfs_trans_dquot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ xfs_trans_dqresv(
591591

592592
xfs_dqlock(dqp);
593593

594-
defq = xfs_get_defquota(dqp, q);
594+
defq = xfs_get_defquota(q, xfs_dquot_type(dqp));
595595

596596
if (flags & XFS_TRANS_DQ_RES_BLKS) {
597597
hardlimit = be64_to_cpu(dqp->q_core.d_blk_hardlimit);

0 commit comments

Comments
 (0)