2018-06-06 10:42:14 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2005-11-02 11:58:39 +08:00
|
|
|
* Copyright (c) 2000-2005 Silicon Graphics, Inc.
|
|
|
|
* All Rights Reserved.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
#ifndef __XFS_QUOTA_H__
|
|
|
|
#define __XFS_QUOTA_H__
|
|
|
|
|
2013-08-12 18:49:30 +08:00
|
|
|
#include "xfs_quota_defs.h"
|
2009-02-09 15:47:34 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2013-08-12 18:49:30 +08:00
|
|
|
* Kernel only quota definitions and functions
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2005-06-21 13:38:48 +08:00
|
|
|
|
2013-08-12 18:49:30 +08:00
|
|
|
struct xfs_trans;
|
2020-06-30 05:48:59 +08:00
|
|
|
struct xfs_buf;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This check is done typically without holding the inode lock;
|
2006-03-29 06:55:14 +08:00
|
|
|
* that may seem racy, but it is harmless in the context that it is used.
|
2005-04-17 06:20:36 +08:00
|
|
|
* The inode cannot go inactive as long a reference is kept, and
|
|
|
|
* therefore if dquot(s) were attached, they'll stay consistent.
|
|
|
|
* If, for example, the ownership of the inode changes while
|
|
|
|
* we didn't have the inode locked, the appropriate dquot(s) will be
|
|
|
|
* attached atomically.
|
|
|
|
*/
|
2013-07-11 13:00:40 +08:00
|
|
|
#define XFS_NOT_DQATTACHED(mp, ip) \
|
|
|
|
((XFS_IS_UQUOTA_ON(mp) && (ip)->i_udquot == NULL) || \
|
|
|
|
(XFS_IS_GQUOTA_ON(mp) && (ip)->i_gdquot == NULL) || \
|
|
|
|
(XFS_IS_PQUOTA_ON(mp) && (ip)->i_pdquot == NULL))
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-06-21 13:38:48 +08:00
|
|
|
#define XFS_QM_NEED_QUOTACHECK(mp) \
|
|
|
|
((XFS_IS_UQUOTA_ON(mp) && \
|
|
|
|
(mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \
|
|
|
|
(XFS_IS_GQUOTA_ON(mp) && \
|
2013-06-28 06:25:10 +08:00
|
|
|
(mp->m_sb.sb_qflags & XFS_GQUOTA_CHKD) == 0) || \
|
2005-06-21 13:38:48 +08:00
|
|
|
(XFS_IS_PQUOTA_ON(mp) && \
|
2013-06-28 06:25:10 +08:00
|
|
|
(mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0))
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-05-30 13:18:11 +08:00
|
|
|
static inline uint
|
|
|
|
xfs_quota_chkd_flag(
|
2020-07-16 08:53:43 +08:00
|
|
|
xfs_dqtype_t type)
|
2018-05-30 13:18:11 +08:00
|
|
|
{
|
2020-07-16 08:53:43 +08:00
|
|
|
switch (type) {
|
2020-07-16 08:42:36 +08:00
|
|
|
case XFS_DQTYPE_USER:
|
2018-05-30 13:18:11 +08:00
|
|
|
return XFS_UQUOTA_CHKD;
|
2020-07-16 08:42:36 +08:00
|
|
|
case XFS_DQTYPE_GROUP:
|
2018-05-30 13:18:11 +08:00
|
|
|
return XFS_GQUOTA_CHKD;
|
2020-07-16 08:42:36 +08:00
|
|
|
case XFS_DQTYPE_PROJ:
|
2018-05-30 13:18:11 +08:00
|
|
|
return XFS_PQUOTA_CHKD;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* The structure kept inside the xfs_trans_t keep track of dquot changes
|
|
|
|
* within a transaction and apply them later.
|
|
|
|
*/
|
2019-04-18 07:30:24 +08:00
|
|
|
struct xfs_dqtrx {
|
2005-04-17 06:20:36 +08:00
|
|
|
struct xfs_dquot *qt_dquot; /* the dquot this refers to */
|
2019-04-18 07:30:24 +08:00
|
|
|
|
|
|
|
uint64_t qt_blk_res; /* blks reserved on a dquot */
|
|
|
|
int64_t qt_bcount_delta; /* dquot blk count changes */
|
|
|
|
int64_t qt_delbcnt_delta; /* delayed dquot blk count changes */
|
|
|
|
|
|
|
|
uint64_t qt_rtblk_res; /* # blks reserved on a dquot */
|
|
|
|
uint64_t qt_rtblk_res_used;/* # blks used from reservation */
|
|
|
|
int64_t qt_rtbcount_delta;/* dquot realtime blk changes */
|
|
|
|
int64_t qt_delrtb_delta; /* delayed RT blk count changes */
|
|
|
|
|
|
|
|
uint64_t qt_ino_res; /* inode reserved on a dquot */
|
|
|
|
uint64_t qt_ino_res_used; /* inodes used from the reservation */
|
|
|
|
int64_t qt_icount_delta; /* dquot inode count changes */
|
2019-04-18 07:30:24 +08:00
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-06-08 21:33:32 +08:00
|
|
|
#ifdef CONFIG_XFS_QUOTA
|
|
|
|
extern void xfs_trans_dup_dqinfo(struct xfs_trans *, struct xfs_trans *);
|
|
|
|
extern void xfs_trans_free_dqinfo(struct xfs_trans *);
|
|
|
|
extern void xfs_trans_mod_dquot_byino(struct xfs_trans *, struct xfs_inode *,
|
2019-04-18 07:30:24 +08:00
|
|
|
uint, int64_t);
|
2009-06-08 21:33:32 +08:00
|
|
|
extern void xfs_trans_apply_dquot_deltas(struct xfs_trans *);
|
|
|
|
extern void xfs_trans_unreserve_and_mod_dquots(struct xfs_trans *);
|
|
|
|
extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *,
|
2019-04-18 07:30:24 +08:00
|
|
|
struct xfs_inode *, int64_t, long, uint);
|
2009-06-08 21:33:32 +08:00
|
|
|
extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *,
|
|
|
|
struct xfs_mount *, struct xfs_dquot *,
|
2019-04-18 07:30:24 +08:00
|
|
|
struct xfs_dquot *, struct xfs_dquot *, int64_t, long, uint);
|
2009-06-08 21:33:32 +08:00
|
|
|
|
2020-02-22 00:31:27 +08:00
|
|
|
extern int xfs_qm_vop_dqalloc(struct xfs_inode *, kuid_t, kgid_t,
|
2013-08-16 02:08:01 +08:00
|
|
|
prid_t, uint, struct xfs_dquot **, struct xfs_dquot **,
|
|
|
|
struct xfs_dquot **);
|
2009-06-08 21:33:32 +08:00
|
|
|
extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *,
|
2013-07-11 13:00:40 +08:00
|
|
|
struct xfs_dquot *, struct xfs_dquot *, struct xfs_dquot *);
|
2009-06-08 21:33:32 +08:00
|
|
|
extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **);
|
|
|
|
extern struct xfs_dquot *xfs_qm_vop_chown(struct xfs_trans *,
|
|
|
|
struct xfs_inode *, struct xfs_dquot **, struct xfs_dquot *);
|
|
|
|
extern int xfs_qm_vop_chown_reserve(struct xfs_trans *, struct xfs_inode *,
|
2013-07-11 13:00:40 +08:00
|
|
|
struct xfs_dquot *, struct xfs_dquot *,
|
|
|
|
struct xfs_dquot *, uint);
|
2018-05-05 06:30:21 +08:00
|
|
|
extern int xfs_qm_dqattach(struct xfs_inode *);
|
2018-05-05 06:30:22 +08:00
|
|
|
extern int xfs_qm_dqattach_locked(struct xfs_inode *ip, bool doalloc);
|
2009-06-08 21:33:32 +08:00
|
|
|
extern void xfs_qm_dqdetach(struct xfs_inode *);
|
|
|
|
extern void xfs_qm_dqrele(struct xfs_dquot *);
|
|
|
|
extern void xfs_qm_statvfs(struct xfs_inode *, struct kstatfs *);
|
|
|
|
extern int xfs_qm_newmount(struct xfs_mount *, uint *, uint *);
|
|
|
|
extern void xfs_qm_mount_quotas(struct xfs_mount *);
|
|
|
|
extern void xfs_qm_unmount(struct xfs_mount *);
|
|
|
|
extern void xfs_qm_unmount_quotas(struct xfs_mount *);
|
|
|
|
|
|
|
|
#else
|
2009-06-12 23:34:55 +08:00
|
|
|
static inline int
|
2020-02-22 00:31:27 +08:00
|
|
|
xfs_qm_vop_dqalloc(struct xfs_inode *ip, kuid_t kuid, kgid_t kgid,
|
2013-08-16 02:08:01 +08:00
|
|
|
prid_t prid, uint flags, struct xfs_dquot **udqp,
|
|
|
|
struct xfs_dquot **gdqp, struct xfs_dquot **pdqp)
|
2009-06-12 23:34:55 +08:00
|
|
|
{
|
|
|
|
*udqp = NULL;
|
|
|
|
*gdqp = NULL;
|
2013-07-11 13:00:40 +08:00
|
|
|
*pdqp = NULL;
|
2009-06-12 23:34:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2009-06-08 21:33:32 +08:00
|
|
|
#define xfs_trans_dup_dqinfo(tp, tp2)
|
|
|
|
#define xfs_trans_free_dqinfo(tp)
|
|
|
|
#define xfs_trans_mod_dquot_byino(tp, ip, fields, delta)
|
|
|
|
#define xfs_trans_apply_dquot_deltas(tp)
|
|
|
|
#define xfs_trans_unreserve_and_mod_dquots(tp)
|
2010-11-06 19:42:56 +08:00
|
|
|
static inline int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp,
|
2019-04-18 07:30:24 +08:00
|
|
|
struct xfs_inode *ip, int64_t nblks, long ninos, uint flags)
|
2010-11-06 19:42:56 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
|
|
|
|
struct xfs_mount *mp, struct xfs_dquot *udqp,
|
2013-07-11 13:00:40 +08:00
|
|
|
struct xfs_dquot *gdqp, struct xfs_dquot *pdqp,
|
2019-04-18 07:30:24 +08:00
|
|
|
int64_t nblks, long nions, uint flags)
|
2010-11-06 19:42:56 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2013-07-11 13:00:40 +08:00
|
|
|
#define xfs_qm_vop_create_dqattach(tp, ip, u, g, p)
|
2009-06-08 21:33:32 +08:00
|
|
|
#define xfs_qm_vop_rename_dqattach(it) (0)
|
|
|
|
#define xfs_qm_vop_chown(tp, ip, old, new) (NULL)
|
2013-07-11 13:00:40 +08:00
|
|
|
#define xfs_qm_vop_chown_reserve(tp, ip, u, g, p, fl) (0)
|
2018-05-05 06:30:21 +08:00
|
|
|
#define xfs_qm_dqattach(ip) (0)
|
2009-06-08 21:33:32 +08:00
|
|
|
#define xfs_qm_dqattach_locked(ip, fl) (0)
|
|
|
|
#define xfs_qm_dqdetach(ip)
|
|
|
|
#define xfs_qm_dqrele(d)
|
|
|
|
#define xfs_qm_statvfs(ip, s)
|
|
|
|
#define xfs_qm_newmount(mp, a, b) (0)
|
|
|
|
#define xfs_qm_mount_quotas(mp)
|
|
|
|
#define xfs_qm_unmount(mp)
|
2010-11-06 19:42:56 +08:00
|
|
|
#define xfs_qm_unmount_quotas(mp)
|
2009-06-08 21:33:32 +08:00
|
|
|
#endif /* CONFIG_XFS_QUOTA */
|
|
|
|
|
|
|
|
#define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \
|
|
|
|
xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags)
|
2013-07-11 13:00:40 +08:00
|
|
|
#define xfs_trans_reserve_quota(tp, mp, ud, gd, pd, nb, ni, f) \
|
|
|
|
xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \
|
2005-04-17 06:20:36 +08:00
|
|
|
f | XFS_QMOPT_RES_REGBLKS)
|
|
|
|
|
2005-09-05 06:24:10 +08:00
|
|
|
extern int xfs_mount_reset_sbqflags(struct xfs_mount *);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#endif /* __XFS_QUOTA_H__ */
|