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