Skip to content

Commit 1a7ed27

Browse files
committed
xfs: create xfs_dqtype_t to represent quota types
Create a new type (xfs_dqtype_t) to represent the type of an incore dquot (user, group, project, or none). Rename the incore dquot's dq_flags field to q_type. This allows us to replace all the "uint type" arguments to the quota functions with "xfs_dqtype_t type", to make it obvious when we're passing a quota type argument into a function. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 74ddd6b commit 1a7ed27

15 files changed

+126
-101
lines changed

fs/xfs/libxfs/xfs_dquot_buf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ xfs_dqblk_repair(
109109
struct xfs_mount *mp,
110110
struct xfs_dqblk *dqb,
111111
xfs_dqid_t id,
112-
uint type)
112+
xfs_dqtype_t type)
113113
{
114114
/*
115115
* Typically, a repair is only requested by quotacheck.

fs/xfs/libxfs/xfs_format.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,15 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev)
11491149
#define XFS_DQUOT_MAGIC 0x4451 /* 'DQ' */
11501150
#define XFS_DQUOT_VERSION (uint8_t)0x01 /* latest version number */
11511151

1152+
#define XFS_DQTYPE_USER 0x01 /* user dquot record */
1153+
#define XFS_DQTYPE_PROJ 0x02 /* project dquot record */
1154+
#define XFS_DQTYPE_GROUP 0x04 /* group dquot record */
1155+
1156+
/* bitmask to determine if this is a user/group/project dquot */
1157+
#define XFS_DQTYPE_REC_MASK (XFS_DQTYPE_USER | \
1158+
XFS_DQTYPE_PROJ | \
1159+
XFS_DQTYPE_GROUP)
1160+
11521161
/*
11531162
* This is the main portion of the on-disk representation of quota information
11541163
* for a user. We pad this with some more expansion room to construct the on

fs/xfs/libxfs/xfs_quota_defs.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,20 @@
1818
typedef uint64_t xfs_qcnt_t;
1919
typedef uint16_t xfs_qwarncnt_t;
2020

21+
typedef uint8_t xfs_dqtype_t;
22+
23+
#define XFS_DQTYPE_STRINGS \
24+
{ XFS_DQTYPE_USER, "USER" }, \
25+
{ XFS_DQTYPE_PROJ, "PROJ" }, \
26+
{ XFS_DQTYPE_GROUP, "GROUP" }
27+
2128
/*
2229
* flags for q_flags field in the dquot.
2330
*/
24-
#define XFS_DQTYPE_USER 0x0001 /* a user quota */
25-
#define XFS_DQTYPE_PROJ 0x0002 /* project quota */
26-
#define XFS_DQTYPE_GROUP 0x0004 /* a group quota */
27-
#define XFS_DQFLAG_DIRTY 0x0008 /* dquot is dirty */
28-
#define XFS_DQFLAG_FREEING 0x0010 /* dquot is being torn down */
29-
30-
#define XFS_DQTYPE_REC_MASK (XFS_DQTYPE_USER | \
31-
XFS_DQTYPE_PROJ | \
32-
XFS_DQTYPE_GROUP)
31+
#define XFS_DQFLAG_DIRTY (1 << 0) /* dquot is dirty */
32+
#define XFS_DQFLAG_FREEING (1 << 1) /* dquot is being torn down */
3333

3434
#define XFS_DQFLAG_STRINGS \
35-
{ XFS_DQTYPE_USER, "USER" }, \
36-
{ XFS_DQTYPE_PROJ, "PROJ" }, \
37-
{ XFS_DQTYPE_GROUP, "GROUP" }, \
3835
{ XFS_DQFLAG_DIRTY, "DIRTY" }, \
3936
{ XFS_DQFLAG_FREEING, "FREEING" }
4037

@@ -144,6 +141,6 @@ extern xfs_failaddr_t xfs_dqblk_verify(struct xfs_mount *mp,
144141
struct xfs_dqblk *dqb, xfs_dqid_t id);
145142
extern int xfs_calc_dquots_per_chunk(unsigned int nbblks);
146143
extern void xfs_dqblk_repair(struct xfs_mount *mp, struct xfs_dqblk *dqb,
147-
xfs_dqid_t id, uint type);
144+
xfs_dqid_t id, xfs_dqtype_t type);
148145

149146
#endif /* __XFS_QUOTA_H__ */

fs/xfs/scrub/quota.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "scrub/common.h"
1919

2020
/* Convert a scrub type code to a DQ flag, or return 0 if error. */
21-
static inline uint
21+
static inline xfs_dqtype_t
2222
xchk_quota_to_dqtype(
2323
struct xfs_scrub *sc)
2424
{
@@ -40,7 +40,7 @@ xchk_setup_quota(
4040
struct xfs_scrub *sc,
4141
struct xfs_inode *ip)
4242
{
43-
uint dqtype;
43+
xfs_dqtype_t dqtype;
4444
int error;
4545

4646
if (!XFS_IS_QUOTA_RUNNING(sc->mp) || !XFS_IS_QUOTA_ON(sc->mp))
@@ -73,7 +73,7 @@ struct xchk_quota_info {
7373
STATIC int
7474
xchk_quota_item(
7575
struct xfs_dquot *dq,
76-
uint dqtype,
76+
xfs_dqtype_t dqtype,
7777
void *priv)
7878
{
7979
struct xchk_quota_info *sqi = priv;
@@ -214,7 +214,7 @@ xchk_quota(
214214
struct xchk_quota_info sqi;
215215
struct xfs_mount *mp = sc->mp;
216216
struct xfs_quotainfo *qi = mp->m_quotainfo;
217-
uint dqtype;
217+
xfs_dqtype_t dqtype;
218218
int error = 0;
219219

220220
dqtype = xchk_quota_to_dqtype(sc);

fs/xfs/scrub/repair.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,11 +899,11 @@ xrep_find_ag_btree_roots(
899899
void
900900
xrep_force_quotacheck(
901901
struct xfs_scrub *sc,
902-
uint dqtype)
902+
xfs_dqtype_t type)
903903
{
904904
uint flag;
905905

906-
flag = xfs_quota_chkd_flag(dqtype);
906+
flag = xfs_quota_chkd_flag(type);
907907
if (!(flag & sc->mp->m_qflags))
908908
return;
909909

fs/xfs/scrub/repair.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#ifndef __XFS_SCRUB_REPAIR_H__
77
#define __XFS_SCRUB_REPAIR_H__
88

9+
#include "xfs_quota_defs.h"
10+
911
static inline int xrep_notsupported(struct xfs_scrub *sc)
1012
{
1113
return -EOPNOTSUPP;
@@ -49,7 +51,7 @@ struct xrep_find_ag_btree {
4951

5052
int xrep_find_ag_btree_roots(struct xfs_scrub *sc, struct xfs_buf *agf_bp,
5153
struct xrep_find_ag_btree *btree_info, struct xfs_buf *agfl_bp);
52-
void xrep_force_quotacheck(struct xfs_scrub *sc, uint dqtype);
54+
void xrep_force_quotacheck(struct xfs_scrub *sc, xfs_dqtype_t type);
5355
int xrep_ino_dqattach(struct xfs_scrub *sc);
5456

5557
/* Metadata repairers */

fs/xfs/xfs_dquot.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ xfs_qm_init_dquot_blk(
158158
struct xfs_trans *tp,
159159
struct xfs_mount *mp,
160160
xfs_dqid_t id,
161-
uint type,
161+
xfs_dqtype_t type,
162162
struct xfs_buf *bp)
163163
{
164164
struct xfs_quotainfo *q = mp->m_quotainfo;
@@ -273,7 +273,7 @@ xfs_dquot_disk_alloc(
273273
struct xfs_trans *tp = *tpp;
274274
struct xfs_mount *mp = tp->t_mountp;
275275
struct xfs_buf *bp;
276-
uint qtype = xfs_dquot_type(dqp);
276+
xfs_dqtype_t qtype = xfs_dquot_type(dqp);
277277
struct xfs_inode *quotip = xfs_quota_inode(mp, qtype);
278278
int nmaps = 1;
279279
int error;
@@ -365,7 +365,7 @@ xfs_dquot_disk_read(
365365
{
366366
struct xfs_bmbt_irec map;
367367
struct xfs_buf *bp;
368-
uint qtype = xfs_dquot_type(dqp);
368+
xfs_dqtype_t qtype = xfs_dquot_type(dqp);
369369
struct xfs_inode *quotip = xfs_quota_inode(mp, qtype);
370370
uint lock_mode;
371371
int nmaps = 1;
@@ -424,13 +424,13 @@ STATIC struct xfs_dquot *
424424
xfs_dquot_alloc(
425425
struct xfs_mount *mp,
426426
xfs_dqid_t id,
427-
uint type)
427+
xfs_dqtype_t type)
428428
{
429429
struct xfs_dquot *dqp;
430430

431431
dqp = kmem_zone_zalloc(xfs_qm_dqzone, 0);
432432

433-
dqp->dq_flags = type;
433+
dqp->q_type = type;
434434
dqp->q_id = id;
435435
dqp->q_mount = mp;
436436
INIT_LIST_HEAD(&dqp->q_lru);
@@ -498,6 +498,7 @@ xfs_dquot_from_disk(
498498
}
499499

500500
/* copy everything from disk dquot to the incore dquot */
501+
dqp->q_type = ddqp->d_flags;
501502
dqp->q_blk.hardlimit = be64_to_cpu(ddqp->d_blk_hardlimit);
502503
dqp->q_blk.softlimit = be64_to_cpu(ddqp->d_blk_softlimit);
503504
dqp->q_ino.hardlimit = be64_to_cpu(ddqp->d_ino_hardlimit);
@@ -538,7 +539,7 @@ xfs_dquot_to_disk(
538539
{
539540
ddqp->d_magic = cpu_to_be16(XFS_DQUOT_MAGIC);
540541
ddqp->d_version = XFS_DQUOT_VERSION;
541-
ddqp->d_flags = dqp->dq_flags & XFS_DQTYPE_REC_MASK;
542+
ddqp->d_flags = dqp->q_type;
542543
ddqp->d_id = cpu_to_be32(dqp->q_id);
543544
ddqp->d_pad0 = 0;
544545
ddqp->d_pad = 0;
@@ -609,7 +610,7 @@ static int
609610
xfs_qm_dqread(
610611
struct xfs_mount *mp,
611612
xfs_dqid_t id,
612-
uint type,
613+
xfs_dqtype_t type,
613614
bool can_alloc,
614615
struct xfs_dquot **dqpp)
615616
{
@@ -657,7 +658,7 @@ xfs_qm_dqread(
657658
static int
658659
xfs_dq_get_next_id(
659660
struct xfs_mount *mp,
660-
uint type,
661+
xfs_dqtype_t type,
661662
xfs_dqid_t *id)
662663
{
663664
struct xfs_inode *quotip = xfs_quota_inode(mp, type);
@@ -781,7 +782,7 @@ xfs_qm_dqget_cache_insert(
781782
static int
782783
xfs_qm_dqget_checks(
783784
struct xfs_mount *mp,
784-
uint type)
785+
xfs_dqtype_t type)
785786
{
786787
if (WARN_ON_ONCE(!XFS_IS_QUOTA_RUNNING(mp)))
787788
return -ESRCH;
@@ -813,7 +814,7 @@ int
813814
xfs_qm_dqget(
814815
struct xfs_mount *mp,
815816
xfs_dqid_t id,
816-
uint type,
817+
xfs_dqtype_t type,
817818
bool can_alloc,
818819
struct xfs_dquot **O_dqpp)
819820
{
@@ -863,7 +864,7 @@ int
863864
xfs_qm_dqget_uncached(
864865
struct xfs_mount *mp,
865866
xfs_dqid_t id,
866-
uint type,
867+
xfs_dqtype_t type,
867868
struct xfs_dquot **dqpp)
868869
{
869870
int error;
@@ -879,7 +880,7 @@ xfs_qm_dqget_uncached(
879880
xfs_dqid_t
880881
xfs_qm_id_for_quotatype(
881882
struct xfs_inode *ip,
882-
uint type)
883+
xfs_dqtype_t type)
883884
{
884885
switch (type) {
885886
case XFS_DQTYPE_USER:
@@ -901,7 +902,7 @@ xfs_qm_id_for_quotatype(
901902
int
902903
xfs_qm_dqget_inode(
903904
struct xfs_inode *ip,
904-
uint type,
905+
xfs_dqtype_t type,
905906
bool can_alloc,
906907
struct xfs_dquot **O_dqpp)
907908
{
@@ -987,7 +988,7 @@ int
987988
xfs_qm_dqget_next(
988989
struct xfs_mount *mp,
989990
xfs_dqid_t id,
990-
uint type,
991+
xfs_dqtype_t type,
991992
struct xfs_dquot **dqpp)
992993
{
993994
struct xfs_dquot *dqp;
@@ -1122,7 +1123,7 @@ static xfs_failaddr_t
11221123
xfs_qm_dqflush_check(
11231124
struct xfs_dquot *dqp)
11241125
{
1125-
__u8 type = dqp->dq_flags & XFS_DQTYPE_REC_MASK;
1126+
xfs_dqtype_t type = xfs_dquot_type(dqp);
11261127

11271128
if (type != XFS_DQTYPE_USER &&
11281129
type != XFS_DQTYPE_GROUP &&
@@ -1317,7 +1318,7 @@ xfs_qm_exit(void)
13171318
int
13181319
xfs_qm_dqiterate(
13191320
struct xfs_mount *mp,
1320-
uint dqtype,
1321+
xfs_dqtype_t type,
13211322
xfs_qm_dqiterate_fn iter_fn,
13221323
void *priv)
13231324
{
@@ -1326,13 +1327,13 @@ xfs_qm_dqiterate(
13261327
int error;
13271328

13281329
do {
1329-
error = xfs_qm_dqget_next(mp, id, dqtype, &dq);
1330+
error = xfs_qm_dqget_next(mp, id, type, &dq);
13301331
if (error == -ENOENT)
13311332
return 0;
13321333
if (error)
13331334
return error;
13341335

1335-
error = iter_fn(dq, dqtype, priv);
1336+
error = iter_fn(dq, type, priv);
13361337
id = dq->q_id;
13371338
xfs_qm_dqput(dq);
13381339
} while (error == 0 && id != 0);

fs/xfs/xfs_dquot.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct xfs_dquot_res {
6060
struct xfs_dquot {
6161
struct list_head q_lru;
6262
struct xfs_mount *q_mount;
63-
uint8_t dq_flags;
63+
xfs_dqtype_t q_type;
6464
uint16_t q_flags;
6565
xfs_dqid_t q_id;
6666
uint q_nrefs;
@@ -131,10 +131,10 @@ static inline void xfs_dqunlock(struct xfs_dquot *dqp)
131131
static inline int
132132
xfs_dquot_type(const struct xfs_dquot *dqp)
133133
{
134-
return dqp->dq_flags & XFS_DQTYPE_REC_MASK;
134+
return dqp->q_type & XFS_DQTYPE_REC_MASK;
135135
}
136136

137-
static inline int xfs_this_quota_on(struct xfs_mount *mp, int type)
137+
static inline int xfs_this_quota_on(struct xfs_mount *mp, xfs_dqtype_t type)
138138
{
139139
switch (type) {
140140
case XFS_DQTYPE_USER:
@@ -148,7 +148,9 @@ static inline int xfs_this_quota_on(struct xfs_mount *mp, int type)
148148
}
149149
}
150150

151-
static inline struct xfs_dquot *xfs_inode_dquot(struct xfs_inode *ip, int type)
151+
static inline struct xfs_dquot *xfs_inode_dquot(
152+
struct xfs_inode *ip,
153+
xfs_dqtype_t type)
152154
{
153155
switch (type) {
154156
case XFS_DQTYPE_USER:
@@ -205,18 +207,17 @@ void xfs_qm_dqunpin_wait(struct xfs_dquot *dqp);
205207
void xfs_qm_adjust_dqtimers(struct xfs_dquot *d);
206208
void xfs_qm_adjust_dqlimits(struct xfs_dquot *d);
207209
xfs_dqid_t xfs_qm_id_for_quotatype(struct xfs_inode *ip,
208-
uint type);
210+
xfs_dqtype_t type);
209211
int xfs_qm_dqget(struct xfs_mount *mp, xfs_dqid_t id,
210-
uint type, bool can_alloc,
211-
struct xfs_dquot **dqpp);
212-
int xfs_qm_dqget_inode(struct xfs_inode *ip, uint type,
213-
bool can_alloc,
214-
struct xfs_dquot **dqpp);
212+
xfs_dqtype_t type, bool can_alloc,
213+
struct xfs_dquot **dqpp);
214+
int xfs_qm_dqget_inode(struct xfs_inode *ip, xfs_dqtype_t type,
215+
bool can_alloc, struct xfs_dquot **dqpp);
215216
int xfs_qm_dqget_next(struct xfs_mount *mp, xfs_dqid_t id,
216-
uint type, struct xfs_dquot **dqpp);
217+
xfs_dqtype_t type, struct xfs_dquot **dqpp);
217218
int xfs_qm_dqget_uncached(struct xfs_mount *mp,
218-
xfs_dqid_t id, uint type,
219-
struct xfs_dquot **dqpp);
219+
xfs_dqid_t id, xfs_dqtype_t type,
220+
struct xfs_dquot **dqpp);
220221
void xfs_qm_dqput(struct xfs_dquot *dqp);
221222

222223
void xfs_dqlock2(struct xfs_dquot *, struct xfs_dquot *);
@@ -231,9 +232,9 @@ static inline struct xfs_dquot *xfs_qm_dqhold(struct xfs_dquot *dqp)
231232
return dqp;
232233
}
233234

234-
typedef int (*xfs_qm_dqiterate_fn)(struct xfs_dquot *dq, uint dqtype,
235-
void *priv);
236-
int xfs_qm_dqiterate(struct xfs_mount *mp, uint dqtype,
235+
typedef int (*xfs_qm_dqiterate_fn)(struct xfs_dquot *dq,
236+
xfs_dqtype_t type, void *priv);
237+
int xfs_qm_dqiterate(struct xfs_mount *mp, xfs_dqtype_t type,
237238
xfs_qm_dqiterate_fn iter_fn, void *priv);
238239

239240
#endif /* __XFS_DQUOT_H__ */

0 commit comments

Comments
 (0)