2018-06-05 19:42:14 -07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
2005-11-02 14:59:41 +11:00
|
|
|
* Copyright (c) 2000-2005 Silicon Graphics, Inc.
|
|
|
|
* All Rights Reserved.
|
2005-04-16 15:20:36 -07:00
|
|
|
*/
|
|
|
|
#ifndef __XFS_QM_H__
|
|
|
|
#define __XFS_QM_H__
|
|
|
|
|
|
|
|
#include "xfs_dquot_item.h"
|
|
|
|
#include "xfs_dquot.h"
|
|
|
|
|
|
|
|
struct xfs_inode;
|
|
|
|
|
2021-10-12 11:09:23 -07:00
|
|
|
extern struct kmem_cache *xfs_dqtrx_cache;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2013-11-23 00:15:43 +08:00
|
|
|
/*
|
|
|
|
* Number of bmaps that we ask from bmapi when doing a quotacheck.
|
|
|
|
* We make this restriction to keep the memory usage to a minimum.
|
|
|
|
*/
|
|
|
|
#define XFS_DQITER_MAP_SIZE 10
|
|
|
|
|
|
|
|
#define XFS_IS_DQUOT_UNINITIALIZED(dqp) ( \
|
2020-07-14 10:37:31 -07:00
|
|
|
!dqp->q_blk.hardlimit && \
|
|
|
|
!dqp->q_blk.softlimit && \
|
|
|
|
!dqp->q_rtb.hardlimit && \
|
|
|
|
!dqp->q_rtb.softlimit && \
|
|
|
|
!dqp->q_ino.hardlimit && \
|
|
|
|
!dqp->q_ino.softlimit && \
|
2020-07-14 10:37:31 -07:00
|
|
|
!dqp->q_blk.count && \
|
|
|
|
!dqp->q_rtb.count && \
|
|
|
|
!dqp->q_ino.count)
|
2013-11-23 00:15:43 +08:00
|
|
|
|
2020-07-14 10:37:32 -07:00
|
|
|
struct xfs_quota_limits {
|
|
|
|
xfs_qcnt_t hard; /* default hard limit */
|
|
|
|
xfs_qcnt_t soft; /* default soft limit */
|
|
|
|
time64_t time; /* limit for timers */
|
|
|
|
};
|
|
|
|
|
2020-05-21 13:07:01 -07:00
|
|
|
/* Defaults for each quota type: time limits, warn limits, usage limits */
|
2016-02-08 11:27:55 +11:00
|
|
|
struct xfs_def_quota {
|
2020-07-14 10:37:32 -07:00
|
|
|
struct xfs_quota_limits blk;
|
|
|
|
struct xfs_quota_limits ino;
|
|
|
|
struct xfs_quota_limits rtb;
|
2016-02-08 11:27:55 +11:00
|
|
|
};
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
* Various quota information for individual filesystems.
|
|
|
|
* The mount structure keeps a pointer to this.
|
|
|
|
*/
|
2019-11-12 17:04:26 -08:00
|
|
|
struct xfs_quotainfo {
|
2020-05-21 13:07:00 -07:00
|
|
|
struct radix_tree_root qi_uquota_tree;
|
|
|
|
struct radix_tree_root qi_gquota_tree;
|
|
|
|
struct radix_tree_root qi_pquota_tree;
|
|
|
|
struct mutex qi_tree_lock;
|
2013-07-11 00:00:40 -05:00
|
|
|
struct xfs_inode *qi_uquotaip; /* user quota inode */
|
|
|
|
struct xfs_inode *qi_gquotaip; /* group quota inode */
|
|
|
|
struct xfs_inode *qi_pquotaip; /* project quota inode */
|
2024-12-02 10:57:25 -08:00
|
|
|
struct xfs_inode *qi_dirip; /* quota metadir */
|
2020-05-21 13:07:00 -07:00
|
|
|
struct list_lru qi_lru;
|
|
|
|
int qi_dquots;
|
|
|
|
struct mutex qi_quotaofflock;/* to serialize quotaoff */
|
|
|
|
xfs_filblks_t qi_dqchunklen; /* # BBs in a chunk of dqs */
|
|
|
|
uint qi_dqperchunk; /* # ondisk dq in above chunk */
|
2016-02-08 11:27:55 +11:00
|
|
|
struct xfs_def_quota qi_usr_default;
|
|
|
|
struct xfs_def_quota qi_grp_default;
|
|
|
|
struct xfs_def_quota qi_prj_default;
|
2023-09-11 17:44:35 +08:00
|
|
|
struct shrinker *qi_shrinker;
|
2020-08-17 09:58:36 -07:00
|
|
|
|
|
|
|
/* Minimum and maximum quota expiration timestamp values. */
|
|
|
|
time64_t qi_expiry_min;
|
|
|
|
time64_t qi_expiry_max;
|
2024-02-22 12:30:55 -08:00
|
|
|
|
|
|
|
/* Hook to feed quota counter updates to an active online repair. */
|
|
|
|
struct xfs_hooks qi_mod_ino_dqtrx_hooks;
|
|
|
|
struct xfs_hooks qi_apply_dqtrx_hooks;
|
2019-11-12 17:04:26 -08:00
|
|
|
};
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2013-06-27 17:25:05 -05:00
|
|
|
static inline struct radix_tree_root *
|
|
|
|
xfs_dquot_tree(
|
|
|
|
struct xfs_quotainfo *qi,
|
2020-07-15 17:53:43 -07:00
|
|
|
xfs_dqtype_t type)
|
2013-06-27 17:25:05 -05:00
|
|
|
{
|
|
|
|
switch (type) {
|
2020-07-15 17:42:36 -07:00
|
|
|
case XFS_DQTYPE_USER:
|
2013-06-27 17:25:05 -05:00
|
|
|
return &qi->qi_uquota_tree;
|
2020-07-15 17:42:36 -07:00
|
|
|
case XFS_DQTYPE_GROUP:
|
2013-06-27 17:25:05 -05:00
|
|
|
return &qi->qi_gquota_tree;
|
2020-07-15 17:42:36 -07:00
|
|
|
case XFS_DQTYPE_PROJ:
|
2013-07-11 00:00:40 -05:00
|
|
|
return &qi->qi_pquota_tree;
|
2013-06-27 17:25:05 -05:00
|
|
|
default:
|
|
|
|
ASSERT(0);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-06-27 17:25:06 -05:00
|
|
|
|
|
|
|
static inline struct xfs_inode *
|
2020-07-15 17:53:43 -07:00
|
|
|
xfs_quota_inode(struct xfs_mount *mp, xfs_dqtype_t type)
|
2013-06-27 17:25:06 -05:00
|
|
|
{
|
2020-07-15 17:53:43 -07:00
|
|
|
switch (type) {
|
2020-07-15 17:42:36 -07:00
|
|
|
case XFS_DQTYPE_USER:
|
2016-02-08 11:23:23 +11:00
|
|
|
return mp->m_quotainfo->qi_uquotaip;
|
2020-07-15 17:42:36 -07:00
|
|
|
case XFS_DQTYPE_GROUP:
|
2016-02-08 11:23:23 +11:00
|
|
|
return mp->m_quotainfo->qi_gquotaip;
|
2020-07-15 17:42:36 -07:00
|
|
|
case XFS_DQTYPE_PROJ:
|
2016-02-08 11:23:23 +11:00
|
|
|
return mp->m_quotainfo->qi_pquotaip;
|
2013-06-27 17:25:06 -05:00
|
|
|
default:
|
|
|
|
ASSERT(0);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2024-02-22 12:30:55 -08:00
|
|
|
/*
|
|
|
|
* Parameters for tracking dqtrx changes on behalf of an inode. The hook
|
|
|
|
* function arg parameter is the field being updated.
|
|
|
|
*/
|
|
|
|
struct xfs_mod_ino_dqtrx_params {
|
|
|
|
uintptr_t tx_id;
|
|
|
|
xfs_ino_t ino;
|
|
|
|
xfs_dqtype_t q_type;
|
|
|
|
xfs_dqid_t q_id;
|
|
|
|
int64_t delta;
|
|
|
|
};
|
|
|
|
|
2019-04-17 16:30:24 -07:00
|
|
|
extern void xfs_trans_mod_dquot(struct xfs_trans *tp, struct xfs_dquot *dqp,
|
|
|
|
uint field, int64_t delta);
|
2013-06-27 17:25:07 -05:00
|
|
|
extern void xfs_trans_dqjoin(struct xfs_trans *, struct xfs_dquot *);
|
|
|
|
extern void xfs_trans_log_dquot(struct xfs_trans *, struct xfs_dquot *);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/*
|
2013-07-11 00:00:40 -05:00
|
|
|
* We keep the usr, grp, and prj dquots separately so that locking will be
|
|
|
|
* easier to do at commit time. All transactions that we know of at this point
|
2005-04-16 15:20:36 -07:00
|
|
|
* affect no more than two dquots of one type. Hence, the TRANS_MAXDQS value.
|
|
|
|
*/
|
2013-06-27 17:25:09 -05:00
|
|
|
enum {
|
|
|
|
XFS_QM_TRANS_USR = 0,
|
|
|
|
XFS_QM_TRANS_GRP,
|
2013-07-11 00:00:40 -05:00
|
|
|
XFS_QM_TRANS_PRJ,
|
2013-06-27 17:25:09 -05:00
|
|
|
XFS_QM_TRANS_DQTYPES
|
|
|
|
};
|
2024-04-15 14:55:12 -07:00
|
|
|
#define XFS_QM_TRANS_MAXDQS 5
|
2013-06-27 17:25:09 -05:00
|
|
|
struct xfs_dquot_acct {
|
|
|
|
struct xfs_dqtrx dqs[XFS_QM_TRANS_DQTYPES][XFS_QM_TRANS_MAXDQS];
|
|
|
|
};
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Users are allowed to have a usage exceeding their softlimit for
|
|
|
|
* a period this long.
|
|
|
|
*/
|
|
|
|
#define XFS_QM_BTIMELIMIT (7 * 24*60*60) /* 1 week */
|
|
|
|
#define XFS_QM_RTBTIMELIMIT (7 * 24*60*60) /* 1 week */
|
|
|
|
#define XFS_QM_ITIMELIMIT (7 * 24*60*60) /* 1 week */
|
|
|
|
|
2013-06-27 17:25:07 -05:00
|
|
|
extern void xfs_qm_destroy_quotainfo(struct xfs_mount *);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-02-09 08:47:34 +01:00
|
|
|
/* quota ops */
|
2013-06-27 17:25:07 -05:00
|
|
|
extern int xfs_qm_scall_trunc_qfiles(struct xfs_mount *, uint);
|
2020-07-15 17:53:43 -07:00
|
|
|
extern int xfs_qm_scall_getquota(struct xfs_mount *mp,
|
|
|
|
xfs_dqid_t id,
|
|
|
|
xfs_dqtype_t type,
|
|
|
|
struct qc_dqblk *dst);
|
|
|
|
extern int xfs_qm_scall_getquota_next(struct xfs_mount *mp,
|
|
|
|
xfs_dqid_t *id,
|
|
|
|
xfs_dqtype_t type,
|
|
|
|
struct qc_dqblk *dst);
|
|
|
|
extern int xfs_qm_scall_setqlim(struct xfs_mount *mp,
|
|
|
|
xfs_dqid_t id,
|
|
|
|
xfs_dqtype_t type,
|
|
|
|
struct qc_dqblk *newlim);
|
2013-06-27 17:25:07 -05:00
|
|
|
extern int xfs_qm_scall_quotaon(struct xfs_mount *, uint);
|
|
|
|
extern int xfs_qm_scall_quotaoff(struct xfs_mount *, uint);
|
2009-02-09 08:47:34 +01:00
|
|
|
|
2016-02-08 11:27:55 +11:00
|
|
|
static inline struct xfs_def_quota *
|
2020-07-15 17:53:43 -07:00
|
|
|
xfs_get_defquota(struct xfs_quotainfo *qi, xfs_dqtype_t type)
|
2016-02-08 11:27:55 +11:00
|
|
|
{
|
2020-05-21 13:07:00 -07:00
|
|
|
switch (type) {
|
2020-07-15 17:42:36 -07:00
|
|
|
case XFS_DQTYPE_USER:
|
2020-05-21 13:07:00 -07:00
|
|
|
return &qi->qi_usr_default;
|
2020-07-15 17:42:36 -07:00
|
|
|
case XFS_DQTYPE_GROUP:
|
2020-05-21 13:07:00 -07:00
|
|
|
return &qi->qi_grp_default;
|
2020-07-15 17:42:36 -07:00
|
|
|
case XFS_DQTYPE_PROJ:
|
2020-05-21 13:07:00 -07:00
|
|
|
return &qi->qi_prj_default;
|
|
|
|
default:
|
|
|
|
ASSERT(0);
|
|
|
|
return NULL;
|
2016-02-08 11:27:55 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-30 15:37:17 -07:00
|
|
|
int xfs_qm_qino_load(struct xfs_mount *mp, xfs_dqtype_t type,
|
|
|
|
struct xfs_inode **ipp);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif /* __XFS_QM_H__ */
|