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