]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: create xfs_dqtype_t to represent quota types
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 4 Sep 2020 20:07:20 +0000 (16:07 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 4 Sep 2020 20:07:20 +0000 (16:07 -0400)
Source kernel commit: 1a7ed271653a4f418a6398465f861ee795d34468

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 <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/check.c
libxfs/xfs_dquot_buf.c
libxfs/xfs_format.h
libxfs/xfs_quota_defs.h
repair/quotacheck.c
repair/quotacheck.h

index 9f15f892a162eff48412f3ecbc614aa67511f7cf..9479a697231165afe5b0f806c00d39c091063441 100644 (file)
@@ -3436,7 +3436,7 @@ process_quota(
        int             cb;
        xfs_dqblk_t     *dqb;
        xfs_dqid_t      dqid;
-       uint8_t         exp_flags = 0;
+       xfs_dqtype_t    exp_flags = 0;
        uint            i;
        uint            perblock;
        xfs_fileoff_t   qbno;
index 2f881df5da046d8eed63d19c4d09d372048bdfa7..431b06fcedfbfa2babbcf48e4dacc6a8634b2b8e 100644 (file)
@@ -107,7 +107,7 @@ xfs_dqblk_repair(
        struct xfs_mount        *mp,
        struct xfs_dqblk        *dqb,
        xfs_dqid_t              id,
-       uint                    type)
+       xfs_dqtype_t            type)
 {
        /*
         * Typically, a repair is only requested by quotacheck.
index 0c56c70e2f52a02beb52c05aecbb1cbfe4d9fe08..820b0223516c9ad08a11d16943b3b69cc47265e2 100644 (file)
@@ -1149,6 +1149,15 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev)
 #define XFS_DQUOT_MAGIC                0x4451          /* 'DQ' */
 #define XFS_DQUOT_VERSION      (uint8_t)0x01   /* latest version number */
 
+#define XFS_DQTYPE_USER                0x01            /* user dquot record */
+#define XFS_DQTYPE_PROJ                0x02            /* project dquot record */
+#define XFS_DQTYPE_GROUP       0x04            /* group dquot record */
+
+/* bitmask to determine if this is a user/group/project dquot */
+#define XFS_DQTYPE_REC_MASK    (XFS_DQTYPE_USER | \
+                                XFS_DQTYPE_PROJ | \
+                                XFS_DQTYPE_GROUP)
+
 /*
  * This is the main portion of the on-disk representation of quota information
  * for a user.  We pad this with some more expansion room to construct the on
index baf6c4ad88afe4861741bcdd4c40d5622117bc02..076bdc7037ee61b90436b526cbd480de7afeb625 100644 (file)
 typedef uint64_t       xfs_qcnt_t;
 typedef uint16_t       xfs_qwarncnt_t;
 
+typedef uint8_t                xfs_dqtype_t;
+
+#define XFS_DQTYPE_STRINGS \
+       { XFS_DQTYPE_USER,      "USER" }, \
+       { XFS_DQTYPE_PROJ,      "PROJ" }, \
+       { XFS_DQTYPE_GROUP,     "GROUP" }
+
 /*
  * flags for q_flags field in the dquot.
  */
-#define XFS_DQTYPE_USER                0x0001          /* a user quota */
-#define XFS_DQTYPE_PROJ                0x0002          /* project quota */
-#define XFS_DQTYPE_GROUP       0x0004          /* a group quota */
-#define XFS_DQFLAG_DIRTY       0x0008          /* dquot is dirty */
-#define XFS_DQFLAG_FREEING     0x0010          /* dquot is being torn down */
-
-#define XFS_DQTYPE_REC_MASK    (XFS_DQTYPE_USER | \
-                                XFS_DQTYPE_PROJ | \
-                                XFS_DQTYPE_GROUP)
+#define XFS_DQFLAG_DIRTY       (1 << 0)        /* dquot is dirty */
+#define XFS_DQFLAG_FREEING     (1 << 1)        /* dquot is being torn down */
 
 #define XFS_DQFLAG_STRINGS \
-       { XFS_DQTYPE_USER,      "USER" }, \
-       { XFS_DQTYPE_PROJ,      "PROJ" }, \
-       { XFS_DQTYPE_GROUP,     "GROUP" }, \
        { XFS_DQFLAG_DIRTY,     "DIRTY" }, \
        { XFS_DQFLAG_FREEING,   "FREEING" }
 
@@ -144,6 +141,6 @@ extern xfs_failaddr_t xfs_dqblk_verify(struct xfs_mount *mp,
                struct xfs_dqblk *dqb, xfs_dqid_t id);
 extern int xfs_calc_dquots_per_chunk(unsigned int nbblks);
 extern void xfs_dqblk_repair(struct xfs_mount *mp, struct xfs_dqblk *dqb,
-               xfs_dqid_t id, uint type);
+               xfs_dqid_t id, xfs_dqtype_t type);
 
 #endif /* __XFS_QUOTA_H__ */
index a115806fe991593fc686be1539183729f894abe3..8cbbfa2e6978665bdf0746e0775bdfe04052f845 100644 (file)
@@ -40,7 +40,7 @@ struct qc_dquots {
        struct avl64tree_desc   tree;
 
        /* One of XFS_DQTYPE_USER/PROJ/GROUP */
-       uint16_t                type;
+       xfs_dqtype_t            type;
 };
 
 #define qc_dquots_foreach(dquots, pos, n) \
@@ -68,7 +68,7 @@ struct qc_rec {
 
 static const char *
 qflags_typestr(
-       unsigned int            type)
+       xfs_dqtype_t            type)
 {
        if (type & XFS_DQTYPE_USER)
                return _("user quota");
@@ -333,7 +333,7 @@ _("cannot read %s inode %"PRIu64", block %"PRIu64", disk block %"PRIu64", err=%d
 void
 quotacheck_verify(
        struct xfs_mount        *mp,
-       unsigned int            type)
+       xfs_dqtype_t            type)
 {
        struct xfs_bmbt_irec    map;
        struct xfs_iext_cursor  icur;
@@ -427,7 +427,7 @@ err:
 static inline bool
 qc_has_quotafile(
        struct xfs_mount        *mp,
-       unsigned int            type)
+       xfs_dqtype_t            type)
 {
        bool                    lost;
        xfs_ino_t               ino;
@@ -465,7 +465,7 @@ qc_has_quotafile(
 /* Initialize an incore dquot tree. */
 static struct qc_dquots *
 qc_dquots_init(
-       uint16_t                type)
+       xfs_dqtype_t            type)
 {
        struct qc_dquots        *dquots;
 
index d745696fad37633d455728bd13be99cf7ee36197..dcbf1623947b4895039b9594b2a05380900f521e 100644 (file)
@@ -8,7 +8,7 @@
 
 void quotacheck_skip(void);
 void quotacheck_adjust(struct xfs_mount *mp, xfs_ino_t ino);
-void quotacheck_verify(struct xfs_mount *mp, unsigned int type);
+void quotacheck_verify(struct xfs_mount *mp, xfs_dqtype_t type);
 uint16_t quotacheck_results(void);
 int quotacheck_setup(struct xfs_mount *mp);
 void quotacheck_teardown(void);