Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
0004  * All Rights Reserved.
0005  */
0006 #ifndef __XFS_QUOTA_DEFS_H__
0007 #define __XFS_QUOTA_DEFS_H__
0008 
0009 /*
0010  * Quota definitions shared between user and kernel source trees.
0011  */
0012 
0013 /*
0014  * Even though users may not have quota limits occupying all 64-bits,
0015  * they may need 64-bit accounting. Hence, 64-bit quota-counters,
0016  * and quota-limits. This is a waste in the common case, but hey ...
0017  */
0018 typedef uint64_t    xfs_qcnt_t;
0019 
0020 typedef uint8_t     xfs_dqtype_t;
0021 
0022 #define XFS_DQTYPE_STRINGS \
0023     { XFS_DQTYPE_USER,  "USER" }, \
0024     { XFS_DQTYPE_PROJ,  "PROJ" }, \
0025     { XFS_DQTYPE_GROUP, "GROUP" }, \
0026     { XFS_DQTYPE_BIGTIME,   "BIGTIME" }
0027 
0028 /*
0029  * flags for q_flags field in the dquot.
0030  */
0031 #define XFS_DQFLAG_DIRTY    (1u << 0)   /* dquot is dirty */
0032 #define XFS_DQFLAG_FREEING  (1u << 1)   /* dquot is being torn down */
0033 
0034 #define XFS_DQFLAG_STRINGS \
0035     { XFS_DQFLAG_DIRTY, "DIRTY" }, \
0036     { XFS_DQFLAG_FREEING,   "FREEING" }
0037 
0038 /*
0039  * We have the possibility of all three quota types being active at once, and
0040  * hence free space modification requires modification of all three current
0041  * dquots in a single transaction. For this case we need to have a reservation
0042  * of at least 3 dquots.
0043  *
0044  * However, a chmod operation can change both UID and GID in a single
0045  * transaction, resulting in requiring {old, new} x {uid, gid} dquots to be
0046  * modified. Hence for this case we need to reserve space for at least 4 dquots.
0047  *
0048  * And in the worst case, there's a rename operation that can be modifying up to
0049  * 4 inodes with dquots attached to them. In reality, the only inodes that can
0050  * have their dquots modified are the source and destination directory inodes
0051  * due to directory name creation and removal. That can require space allocation
0052  * and/or freeing on both directory inodes, and hence all three dquots on each
0053  * inode can be modified. And if the directories are world writeable, all the
0054  * dquots can be unique and so 6 dquots can be modified....
0055  *
0056  * And, of course, we also need to take into account the dquot log format item
0057  * used to describe each dquot.
0058  */
0059 #define XFS_DQUOT_LOGRES(mp)    \
0060     ((sizeof(struct xfs_dq_logformat) + sizeof(struct xfs_disk_dquot)) * 6)
0061 
0062 #define XFS_IS_QUOTA_ON(mp)     ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)
0063 #define XFS_IS_UQUOTA_ON(mp)        ((mp)->m_qflags & XFS_UQUOTA_ACCT)
0064 #define XFS_IS_PQUOTA_ON(mp)        ((mp)->m_qflags & XFS_PQUOTA_ACCT)
0065 #define XFS_IS_GQUOTA_ON(mp)        ((mp)->m_qflags & XFS_GQUOTA_ACCT)
0066 #define XFS_IS_UQUOTA_ENFORCED(mp)  ((mp)->m_qflags & XFS_UQUOTA_ENFD)
0067 #define XFS_IS_GQUOTA_ENFORCED(mp)  ((mp)->m_qflags & XFS_GQUOTA_ENFD)
0068 #define XFS_IS_PQUOTA_ENFORCED(mp)  ((mp)->m_qflags & XFS_PQUOTA_ENFD)
0069 
0070 /*
0071  * Flags to tell various functions what to do. Not all of these are meaningful
0072  * to a single function. None of these XFS_QMOPT_* flags are meant to have
0073  * persistent values (ie. their values can and will change between versions)
0074  */
0075 #define XFS_QMOPT_UQUOTA    (1u << 0) /* user dquot requested */
0076 #define XFS_QMOPT_GQUOTA    (1u << 1) /* group dquot requested */
0077 #define XFS_QMOPT_PQUOTA    (1u << 2) /* project dquot requested */
0078 #define XFS_QMOPT_FORCE_RES (1u << 3) /* ignore quota limits */
0079 #define XFS_QMOPT_SBVERSION (1u << 4) /* change superblock version num */
0080 
0081 /*
0082  * flags to xfs_trans_mod_dquot to indicate which field needs to be
0083  * modified.
0084  */
0085 #define XFS_QMOPT_RES_REGBLKS   (1u << 7)
0086 #define XFS_QMOPT_RES_RTBLKS    (1u << 8)
0087 #define XFS_QMOPT_BCOUNT    (1u << 9)
0088 #define XFS_QMOPT_ICOUNT    (1u << 10)
0089 #define XFS_QMOPT_RTBCOUNT  (1u << 11)
0090 #define XFS_QMOPT_DELBCOUNT (1u << 12)
0091 #define XFS_QMOPT_DELRTBCOUNT   (1u << 13)
0092 #define XFS_QMOPT_RES_INOS  (1u << 14)
0093 
0094 /*
0095  * flags for dqalloc.
0096  */
0097 #define XFS_QMOPT_INHERIT   (1u << 31)
0098 
0099 #define XFS_QMOPT_FLAGS \
0100     { XFS_QMOPT_UQUOTA,     "UQUOTA" }, \
0101     { XFS_QMOPT_PQUOTA,     "PQUOTA" }, \
0102     { XFS_QMOPT_FORCE_RES,      "FORCE_RES" }, \
0103     { XFS_QMOPT_SBVERSION,      "SBVERSION" }, \
0104     { XFS_QMOPT_GQUOTA,     "GQUOTA" }, \
0105     { XFS_QMOPT_INHERIT,        "INHERIT" }, \
0106     { XFS_QMOPT_RES_REGBLKS,    "RES_REGBLKS" }, \
0107     { XFS_QMOPT_RES_RTBLKS,     "RES_RTBLKS" }, \
0108     { XFS_QMOPT_BCOUNT,     "BCOUNT" }, \
0109     { XFS_QMOPT_ICOUNT,     "ICOUNT" }, \
0110     { XFS_QMOPT_RTBCOUNT,       "RTBCOUNT" }, \
0111     { XFS_QMOPT_DELBCOUNT,      "DELBCOUNT" }, \
0112     { XFS_QMOPT_DELRTBCOUNT,    "DELRTBCOUNT" }, \
0113     { XFS_QMOPT_RES_INOS,       "RES_INOS" }
0114 
0115 /*
0116  * flags to xfs_trans_mod_dquot.
0117  */
0118 #define XFS_TRANS_DQ_RES_BLKS   XFS_QMOPT_RES_REGBLKS
0119 #define XFS_TRANS_DQ_RES_RTBLKS XFS_QMOPT_RES_RTBLKS
0120 #define XFS_TRANS_DQ_RES_INOS   XFS_QMOPT_RES_INOS
0121 #define XFS_TRANS_DQ_BCOUNT XFS_QMOPT_BCOUNT
0122 #define XFS_TRANS_DQ_DELBCOUNT  XFS_QMOPT_DELBCOUNT
0123 #define XFS_TRANS_DQ_ICOUNT XFS_QMOPT_ICOUNT
0124 #define XFS_TRANS_DQ_RTBCOUNT   XFS_QMOPT_RTBCOUNT
0125 #define XFS_TRANS_DQ_DELRTBCOUNT XFS_QMOPT_DELRTBCOUNT
0126 
0127 
0128 #define XFS_QMOPT_QUOTALL   \
0129         (XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA)
0130 #define XFS_QMOPT_RESBLK_MASK   (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)
0131 
0132 
0133 extern xfs_failaddr_t xfs_dquot_verify(struct xfs_mount *mp,
0134         struct xfs_disk_dquot *ddq, xfs_dqid_t id);
0135 extern xfs_failaddr_t xfs_dqblk_verify(struct xfs_mount *mp,
0136         struct xfs_dqblk *dqb, xfs_dqid_t id);
0137 extern int xfs_calc_dquots_per_chunk(unsigned int nbblks);
0138 extern void xfs_dqblk_repair(struct xfs_mount *mp, struct xfs_dqblk *dqb,
0139         xfs_dqid_t id, xfs_dqtype_t type);
0140 
0141 struct xfs_dquot;
0142 time64_t xfs_dquot_from_disk_ts(struct xfs_disk_dquot *ddq,
0143         __be32 dtimer);
0144 __be32 xfs_dquot_to_disk_ts(struct xfs_dquot *ddq, time64_t timer);
0145 
0146 #endif  /* __XFS_QUOTA_H__ */