2005-04-16 16:20:36 -06:00
|
|
|
/*
|
2005-11-01 20:59:41 -07:00
|
|
|
* Copyright (c) 2000-2005 Silicon Graphics, Inc.
|
|
|
|
* All Rights Reserved.
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
2005-11-01 20:59:41 -07:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
2005-04-16 16:20:36 -06:00
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
2005-11-01 20:59:41 -07:00
|
|
|
* This program is distributed in the hope that it would be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
2005-11-01 20:59:41 -07:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
|
|
|
#ifndef __XFS_QM_H__
|
|
|
|
#define __XFS_QM_H__
|
|
|
|
|
|
|
|
#include "xfs_dquot_item.h"
|
|
|
|
#include "xfs_dquot.h"
|
|
|
|
|
|
|
|
struct xfs_inode;
|
|
|
|
|
2012-03-13 02:52:37 -06:00
|
|
|
extern struct kmem_zone *xfs_qm_dqtrxzone;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2013-11-22 09:15:43 -07: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) ( \
|
|
|
|
!dqp->q_core.d_blk_hardlimit && \
|
|
|
|
!dqp->q_core.d_blk_softlimit && \
|
|
|
|
!dqp->q_core.d_rtb_hardlimit && \
|
|
|
|
!dqp->q_core.d_rtb_softlimit && \
|
|
|
|
!dqp->q_core.d_ino_hardlimit && \
|
|
|
|
!dqp->q_core.d_ino_softlimit && \
|
|
|
|
!dqp->q_core.d_bcount && \
|
|
|
|
!dqp->q_core.d_rtbcount && \
|
|
|
|
!dqp->q_core.d_icount)
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* This defines the unit of allocation of dquots.
|
|
|
|
* Currently, it is just one file system block, and a 4K blk contains 30
|
|
|
|
* (136 * 30 = 4080) dquots. It's probably not worth trying to make
|
|
|
|
* this more dynamic.
|
|
|
|
* XXXsup However, if this number is changed, we have to make sure that we don't
|
|
|
|
* implicitly assume that we do allocations in chunks of a single filesystem
|
|
|
|
* block in the dquot/xqm code.
|
|
|
|
*/
|
|
|
|
#define XFS_DQUOT_CLUSTER_SIZE_FSB (xfs_filblks_t)1
|
|
|
|
|
2016-02-07 17:27:55 -07:00
|
|
|
struct xfs_def_quota {
|
|
|
|
xfs_qcnt_t bhardlimit; /* default data blk hard limit */
|
|
|
|
xfs_qcnt_t bsoftlimit; /* default data blk soft limit */
|
|
|
|
xfs_qcnt_t ihardlimit; /* default inode count hard limit */
|
|
|
|
xfs_qcnt_t isoftlimit; /* default inode count soft limit */
|
|
|
|
xfs_qcnt_t rtbhardlimit; /* default realtime blk hard limit */
|
|
|
|
xfs_qcnt_t rtbsoftlimit; /* default realtime blk soft limit */
|
|
|
|
};
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Various quota information for individual filesystems.
|
|
|
|
* The mount structure keeps a pointer to this.
|
|
|
|
*/
|
|
|
|
typedef struct xfs_quotainfo {
|
2012-03-13 02:52:35 -06:00
|
|
|
struct radix_tree_root qi_uquota_tree;
|
|
|
|
struct radix_tree_root qi_gquota_tree;
|
2013-07-10 23:00:40 -06:00
|
|
|
struct radix_tree_root qi_pquota_tree;
|
2012-03-13 02:52:35 -06:00
|
|
|
struct mutex qi_tree_lock;
|
2013-07-10 23:00:40 -06: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 */
|
2013-08-27 18:18:07 -06:00
|
|
|
struct list_lru qi_lru;
|
2010-04-12 23:06:48 -06:00
|
|
|
int qi_dquots;
|
2005-04-16 16:20:36 -06:00
|
|
|
time_t qi_btimelimit; /* limit for blks timer */
|
|
|
|
time_t qi_itimelimit; /* limit for inodes timer */
|
|
|
|
time_t qi_rtbtimelimit;/* limit for rt blks timer */
|
2005-06-20 23:48:47 -06:00
|
|
|
xfs_qwarncnt_t qi_bwarnlimit; /* limit for blks warnings */
|
|
|
|
xfs_qwarncnt_t qi_iwarnlimit; /* limit for inodes warnings */
|
|
|
|
xfs_qwarncnt_t qi_rtbwarnlimit;/* limit for rt blks warnings */
|
2009-03-29 01:51:00 -06:00
|
|
|
struct mutex qi_quotaofflock;/* to serialize quotaoff */
|
2005-04-16 16:20:36 -06:00
|
|
|
xfs_filblks_t qi_dqchunklen; /* # BBs in a chunk of dqs */
|
|
|
|
uint qi_dqperchunk; /* # ondisk dqs in above chunk */
|
2016-02-07 17:27:55 -07:00
|
|
|
struct xfs_def_quota qi_usr_default;
|
|
|
|
struct xfs_def_quota qi_grp_default;
|
|
|
|
struct xfs_def_quota qi_prj_default;
|
2012-03-13 02:52:34 -06:00
|
|
|
struct shrinker qi_shrinker;
|
2005-04-16 16:20:36 -06:00
|
|
|
} xfs_quotainfo_t;
|
|
|
|
|
2013-06-27 16:25:05 -06:00
|
|
|
static inline struct radix_tree_root *
|
|
|
|
xfs_dquot_tree(
|
|
|
|
struct xfs_quotainfo *qi,
|
|
|
|
int type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case XFS_DQ_USER:
|
|
|
|
return &qi->qi_uquota_tree;
|
|
|
|
case XFS_DQ_GROUP:
|
|
|
|
return &qi->qi_gquota_tree;
|
2013-07-10 23:00:40 -06:00
|
|
|
case XFS_DQ_PROJ:
|
|
|
|
return &qi->qi_pquota_tree;
|
2013-06-27 16:25:05 -06:00
|
|
|
default:
|
|
|
|
ASSERT(0);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-06-27 16:25:06 -06:00
|
|
|
|
|
|
|
static inline struct xfs_inode *
|
2016-02-07 17:23:23 -07:00
|
|
|
xfs_quota_inode(xfs_mount_t *mp, uint dq_flags)
|
2013-06-27 16:25:06 -06:00
|
|
|
{
|
2016-02-07 17:23:23 -07:00
|
|
|
switch (dq_flags & XFS_DQ_ALLTYPES) {
|
2013-06-27 16:25:06 -06:00
|
|
|
case XFS_DQ_USER:
|
2016-02-07 17:23:23 -07:00
|
|
|
return mp->m_quotainfo->qi_uquotaip;
|
2013-06-27 16:25:06 -06:00
|
|
|
case XFS_DQ_GROUP:
|
2016-02-07 17:23:23 -07:00
|
|
|
return mp->m_quotainfo->qi_gquotaip;
|
2013-07-10 23:00:40 -06:00
|
|
|
case XFS_DQ_PROJ:
|
2016-02-07 17:23:23 -07:00
|
|
|
return mp->m_quotainfo->qi_pquotaip;
|
2013-06-27 16:25:06 -06:00
|
|
|
default:
|
|
|
|
ASSERT(0);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-06-27 16:25:07 -06:00
|
|
|
extern void xfs_trans_mod_dquot(struct xfs_trans *,
|
|
|
|
struct xfs_dquot *, uint, long);
|
|
|
|
extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *,
|
|
|
|
struct xfs_mount *, struct xfs_dquot *,
|
2013-07-10 23:00:40 -06:00
|
|
|
struct xfs_dquot *, struct xfs_dquot *,
|
|
|
|
long, long, uint);
|
2013-06-27 16:25:07 -06: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 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
2013-07-10 23:00:40 -06: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 16:20:36 -06:00
|
|
|
* affect no more than two dquots of one type. Hence, the TRANS_MAXDQS value.
|
|
|
|
*/
|
2013-06-27 16:25:09 -06:00
|
|
|
enum {
|
|
|
|
XFS_QM_TRANS_USR = 0,
|
|
|
|
XFS_QM_TRANS_GRP,
|
2013-07-10 23:00:40 -06:00
|
|
|
XFS_QM_TRANS_PRJ,
|
2013-06-27 16:25:09 -06:00
|
|
|
XFS_QM_TRANS_DQTYPES
|
|
|
|
};
|
2005-04-16 16:20:36 -06:00
|
|
|
#define XFS_QM_TRANS_MAXDQS 2
|
2013-06-27 16:25:09 -06:00
|
|
|
struct xfs_dquot_acct {
|
|
|
|
struct xfs_dqtrx dqs[XFS_QM_TRANS_DQTYPES][XFS_QM_TRANS_MAXDQS];
|
|
|
|
};
|
2005-04-16 16:20:36 -06: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 */
|
|
|
|
|
|
|
|
#define XFS_QM_BWARNLIMIT 5
|
|
|
|
#define XFS_QM_IWARNLIMIT 5
|
2005-06-20 23:48:47 -06:00
|
|
|
#define XFS_QM_RTBWARNLIMIT 5
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2013-06-27 16:25:07 -06:00
|
|
|
extern void xfs_qm_destroy_quotainfo(struct xfs_mount *);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* dquot stuff */
|
2013-06-27 16:25:07 -06:00
|
|
|
extern void xfs_qm_dqpurge_all(struct xfs_mount *, uint);
|
|
|
|
extern void xfs_qm_dqrele_all_inodes(struct xfs_mount *, uint);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2009-02-09 00:47:34 -07:00
|
|
|
/* quota ops */
|
2013-06-27 16:25:07 -06:00
|
|
|
extern int xfs_qm_scall_trunc_qfiles(struct xfs_mount *, uint);
|
2016-02-07 17:27:38 -07:00
|
|
|
extern int xfs_qm_scall_getquota(struct xfs_mount *, xfs_dqid_t *,
|
|
|
|
uint, struct qc_dqblk *, uint);
|
2013-03-18 08:51:46 -06:00
|
|
|
extern int xfs_qm_scall_setqlim(struct xfs_mount *, xfs_dqid_t, uint,
|
2014-10-09 08:03:13 -06:00
|
|
|
struct qc_dqblk *);
|
2013-06-27 16:25:07 -06:00
|
|
|
extern int xfs_qm_scall_quotaon(struct xfs_mount *, uint);
|
|
|
|
extern int xfs_qm_scall_quotaoff(struct xfs_mount *, uint);
|
2009-02-09 00:47:34 -07:00
|
|
|
|
2016-02-07 17:27:55 -07:00
|
|
|
static inline struct xfs_def_quota *
|
|
|
|
xfs_get_defquota(struct xfs_dquot *dqp, struct xfs_quotainfo *qi)
|
|
|
|
{
|
|
|
|
struct xfs_def_quota *defq;
|
|
|
|
|
|
|
|
if (XFS_QM_ISUDQ(dqp))
|
|
|
|
defq = &qi->qi_usr_default;
|
|
|
|
else if (XFS_QM_ISGDQ(dqp))
|
|
|
|
defq = &qi->qi_grp_default;
|
|
|
|
else {
|
|
|
|
ASSERT(XFS_QM_ISPDQ(dqp));
|
|
|
|
defq = &qi->qi_prj_default;
|
|
|
|
}
|
|
|
|
return defq;
|
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif /* __XFS_QM_H__ */
|