123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- #ifndef __XFS_DQUOT_H__
- #define __XFS_DQUOT_H__
- struct xfs_mount;
- struct xfs_trans;
- enum {
- XFS_QLOWSP_1_PCNT = 0,
- XFS_QLOWSP_3_PCNT,
- XFS_QLOWSP_5_PCNT,
- XFS_QLOWSP_MAX
- };
- typedef struct xfs_dquot {
- uint dq_flags;
- struct list_head q_lru;
- struct xfs_mount*q_mount;
- struct xfs_trans*q_transp;
- uint q_nrefs;
- xfs_daddr_t q_blkno;
- int q_bufoffset;
- xfs_fileoff_t q_fileoffset;
- xfs_disk_dquot_t q_core;
- xfs_dq_logitem_t q_logitem;
- xfs_qcnt_t q_res_bcount;
- xfs_qcnt_t q_res_icount;
- xfs_qcnt_t q_res_rtbcount;
- xfs_qcnt_t q_prealloc_lo_wmark;
- xfs_qcnt_t q_prealloc_hi_wmark;
- int64_t q_low_space[XFS_QLOWSP_MAX];
- struct mutex q_qlock;
- struct completion q_flush;
- atomic_t q_pincount;
- wait_queue_head_t q_pinwait;
- } xfs_dquot_t;
- enum {
- XFS_QLOCK_NORMAL = 0,
- XFS_QLOCK_NESTED,
- };
- static inline void xfs_dqflock(xfs_dquot_t *dqp)
- {
- wait_for_completion(&dqp->q_flush);
- }
- static inline bool xfs_dqflock_nowait(xfs_dquot_t *dqp)
- {
- return try_wait_for_completion(&dqp->q_flush);
- }
- static inline void xfs_dqfunlock(xfs_dquot_t *dqp)
- {
- complete(&dqp->q_flush);
- }
- static inline int xfs_dqlock_nowait(struct xfs_dquot *dqp)
- {
- return mutex_trylock(&dqp->q_qlock);
- }
- static inline void xfs_dqlock(struct xfs_dquot *dqp)
- {
- mutex_lock(&dqp->q_qlock);
- }
- static inline void xfs_dqunlock(struct xfs_dquot *dqp)
- {
- mutex_unlock(&dqp->q_qlock);
- }
- static inline int xfs_this_quota_on(struct xfs_mount *mp, int type)
- {
- switch (type & XFS_DQ_ALLTYPES) {
- case XFS_DQ_USER:
- return XFS_IS_UQUOTA_ON(mp);
- case XFS_DQ_GROUP:
- return XFS_IS_GQUOTA_ON(mp);
- case XFS_DQ_PROJ:
- return XFS_IS_PQUOTA_ON(mp);
- default:
- return 0;
- }
- }
- static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type)
- {
- switch (type & XFS_DQ_ALLTYPES) {
- case XFS_DQ_USER:
- return ip->i_udquot;
- case XFS_DQ_GROUP:
- return ip->i_gdquot;
- case XFS_DQ_PROJ:
- return ip->i_pdquot;
- default:
- return NULL;
- }
- }
- static inline bool xfs_dquot_lowsp(struct xfs_dquot *dqp)
- {
- int64_t freesp;
- freesp = be64_to_cpu(dqp->q_core.d_blk_hardlimit) - dqp->q_res_bcount;
- if (freesp < dqp->q_low_space[XFS_QLOWSP_1_PCNT])
- return true;
- return false;
- }
- #define XFS_DQ_IS_LOCKED(dqp) (mutex_is_locked(&((dqp)->q_qlock)))
- #define XFS_DQ_IS_DIRTY(dqp) ((dqp)->dq_flags & XFS_DQ_DIRTY)
- #define XFS_QM_ISUDQ(dqp) ((dqp)->dq_flags & XFS_DQ_USER)
- #define XFS_QM_ISPDQ(dqp) ((dqp)->dq_flags & XFS_DQ_PROJ)
- #define XFS_QM_ISGDQ(dqp) ((dqp)->dq_flags & XFS_DQ_GROUP)
- extern int xfs_qm_dqread(struct xfs_mount *, xfs_dqid_t, uint,
- uint, struct xfs_dquot **);
- extern void xfs_qm_dqdestroy(xfs_dquot_t *);
- extern int xfs_qm_dqflush(struct xfs_dquot *, struct xfs_buf **);
- extern void xfs_qm_dqunpin_wait(xfs_dquot_t *);
- extern void xfs_qm_adjust_dqtimers(xfs_mount_t *,
- xfs_disk_dquot_t *);
- extern void xfs_qm_adjust_dqlimits(struct xfs_mount *,
- struct xfs_dquot *);
- extern int xfs_qm_dqget(xfs_mount_t *, xfs_inode_t *,
- xfs_dqid_t, uint, uint, xfs_dquot_t **);
- extern void xfs_qm_dqput(xfs_dquot_t *);
- extern void xfs_dqlock2(struct xfs_dquot *, struct xfs_dquot *);
- extern void xfs_dquot_set_prealloc_limits(struct xfs_dquot *);
- static inline struct xfs_dquot *xfs_qm_dqhold(struct xfs_dquot *dqp)
- {
- xfs_dqlock(dqp);
- dqp->q_nrefs++;
- xfs_dqunlock(dqp);
- return dqp;
- }
- #endif
|