2018-06-06 09:42:14 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
2005-11-02 10:58:39 +07:00
|
|
|
* Copyright (c) 2000-2005 Silicon Graphics, Inc.
|
|
|
|
* All Rights Reserved.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
#ifndef __XFS_QUOTA_H__
|
|
|
|
#define __XFS_QUOTA_H__
|
|
|
|
|
2013-08-12 17:49:30 +07:00
|
|
|
#include "xfs_quota_defs.h"
|
2009-02-09 14:47:34 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
2013-08-12 17:49:30 +07:00
|
|
|
* Kernel only quota definitions and functions
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
2005-06-21 12:38:48 +07:00
|
|
|
|
2013-08-12 17:49:30 +07:00
|
|
|
struct xfs_trans;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This check is done typically without holding the inode lock;
|
2006-03-29 05:55:14 +07:00
|
|
|
* that may seem racy, but it is harmless in the context that it is used.
|
2005-04-17 05:20:36 +07: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 12:00:40 +07: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 05:20:36 +07:00
|
|
|
|
2005-06-21 12:38:48 +07: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 05:25:10 +07:00
|
|
|
(mp->m_sb.sb_qflags & XFS_GQUOTA_CHKD) == 0) || \
|
2005-06-21 12:38:48 +07:00
|
|
|
(XFS_IS_PQUOTA_ON(mp) && \
|
2013-06-28 05:25:10 +07:00
|
|
|
(mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0))
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2018-05-30 12:18:11 +07:00
|
|
|
static inline uint
|
|
|
|
xfs_quota_chkd_flag(
|
|
|
|
uint dqtype)
|
|
|
|
{
|
|
|
|
switch (dqtype) {
|
|
|
|
case XFS_DQ_USER:
|
|
|
|
return XFS_UQUOTA_CHKD;
|
|
|
|
case XFS_DQ_GROUP:
|
|
|
|
return XFS_GQUOTA_CHKD;
|
|
|
|
case XFS_DQ_PROJ:
|
|
|
|
return XFS_PQUOTA_CHKD;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* The structure kept inside the xfs_trans_t keep track of dquot changes
|
|
|
|
* within a transaction and apply them later.
|
|
|
|
*/
|
2019-04-18 06:30:24 +07:00
|
|
|
struct xfs_dqtrx {
|
2005-04-17 05:20:36 +07:00
|
|
|
struct xfs_dquot *qt_dquot; /* the dquot this refers to */
|
2019-04-18 06:30:24 +07: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 06:30:24 +07:00
|
|
|
};
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-06-08 20:33:32 +07: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 06:30:24 +07:00
|
|
|
uint, int64_t);
|
2009-06-08 20:33:32 +07: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 06:30:24 +07:00
|
|
|
struct xfs_inode *, int64_t, long, uint);
|
2009-06-08 20:33:32 +07:00
|
|
|
extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *,
|
|
|
|
struct xfs_mount *, struct xfs_dquot *,
|
2019-04-18 06:30:24 +07:00
|
|
|
struct xfs_dquot *, struct xfs_dquot *, int64_t, long, uint);
|
2009-06-08 20:33:32 +07:00
|
|
|
|
2020-02-21 23:31:27 +07:00
|
|
|
extern int xfs_qm_vop_dqalloc(struct xfs_inode *, kuid_t, kgid_t,
|
2013-08-16 01:08:01 +07:00
|
|
|
prid_t, uint, struct xfs_dquot **, struct xfs_dquot **,
|
|
|
|
struct xfs_dquot **);
|
2009-06-08 20:33:32 +07:00
|
|
|
extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *,
|
2013-07-11 12:00:40 +07:00
|
|
|
struct xfs_dquot *, struct xfs_dquot *, struct xfs_dquot *);
|
2009-06-08 20:33:32 +07: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 12:00:40 +07:00
|
|
|
struct xfs_dquot *, struct xfs_dquot *,
|
|
|
|
struct xfs_dquot *, uint);
|
2018-05-05 05:30:21 +07:00
|
|
|
extern int xfs_qm_dqattach(struct xfs_inode *);
|
2018-05-05 05:30:22 +07:00
|
|
|
extern int xfs_qm_dqattach_locked(struct xfs_inode *ip, bool doalloc);
|
2009-06-08 20:33:32 +07: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 22:34:55 +07:00
|
|
|
static inline int
|
2020-02-21 23:31:27 +07:00
|
|
|
xfs_qm_vop_dqalloc(struct xfs_inode *ip, kuid_t kuid, kgid_t kgid,
|
2013-08-16 01:08:01 +07:00
|
|
|
prid_t prid, uint flags, struct xfs_dquot **udqp,
|
|
|
|
struct xfs_dquot **gdqp, struct xfs_dquot **pdqp)
|
2009-06-12 22:34:55 +07:00
|
|
|
{
|
|
|
|
*udqp = NULL;
|
|
|
|
*gdqp = NULL;
|
2013-07-11 12:00:40 +07:00
|
|
|
*pdqp = NULL;
|
2009-06-12 22:34:55 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2009-06-08 20:33:32 +07: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 18:42:56 +07:00
|
|
|
static inline int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp,
|
2019-04-18 06:30:24 +07:00
|
|
|
struct xfs_inode *ip, int64_t nblks, long ninos, uint flags)
|
2010-11-06 18:42:56 +07: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 12:00:40 +07:00
|
|
|
struct xfs_dquot *gdqp, struct xfs_dquot *pdqp,
|
2019-04-18 06:30:24 +07:00
|
|
|
int64_t nblks, long nions, uint flags)
|
2010-11-06 18:42:56 +07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2013-07-11 12:00:40 +07:00
|
|
|
#define xfs_qm_vop_create_dqattach(tp, ip, u, g, p)
|
2009-06-08 20:33:32 +07:00
|
|
|
#define xfs_qm_vop_rename_dqattach(it) (0)
|
|
|
|
#define xfs_qm_vop_chown(tp, ip, old, new) (NULL)
|
2013-07-11 12:00:40 +07:00
|
|
|
#define xfs_qm_vop_chown_reserve(tp, ip, u, g, p, fl) (0)
|
2018-05-05 05:30:21 +07:00
|
|
|
#define xfs_qm_dqattach(ip) (0)
|
2009-06-08 20:33:32 +07: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 18:42:56 +07:00
|
|
|
#define xfs_qm_unmount_quotas(mp)
|
2009-06-08 20:33:32 +07: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 12:00:40 +07: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 05:20:36 +07:00
|
|
|
f | XFS_QMOPT_RES_REGBLKS)
|
|
|
|
|
2005-09-05 05:24:10 +07:00
|
|
|
extern int xfs_mount_reset_sbqflags(struct xfs_mount *);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#endif /* __XFS_QUOTA_H__ */
|