Blame view

fs/xfs/xfs_qm.h 5.7 KB
0b61f8a40   Dave Chinner   xfs: convert to S...
1
  // SPDX-License-Identifier: GPL-2.0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
  /*
4ce3121f6   Nathan Scott   [XFS] Update lice...
3
4
   * Copyright (c) 2000-2005 Silicon Graphics, Inc.
   * All Rights Reserved.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5
6
7
8
9
10
   */
  #ifndef __XFS_QM_H__
  #define __XFS_QM_H__
  
  #include "xfs_dquot_item.h"
  #include "xfs_dquot.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
11

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
12
  struct xfs_inode;
a05931ceb   Christoph Hellwig   xfs: remove the g...
13
  extern struct kmem_zone	*xfs_qm_dqtrxzone;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
14
15
  
  /*
afbd123db   Jie Liu   xfs: integrate xf...
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
   * 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)
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
33
34
35
36
37
38
39
40
41
   * 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
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
42

be6079461   Carlos Maiolino   xfs: Split defaul...
43
44
45
46
47
48
49
50
  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 */
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
51
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
52
53
54
55
   * Various quota information for individual filesystems.
   * The mount structure keeps a pointer to this.
   */
  typedef struct xfs_quotainfo {
9f920f116   Christoph Hellwig   xfs: use per-file...
56
57
  	struct radix_tree_root qi_uquota_tree;
  	struct radix_tree_root qi_gquota_tree;
92f8ff73f   Chandra Seetharaman   xfs: Add pquota f...
58
  	struct radix_tree_root qi_pquota_tree;
9f920f116   Christoph Hellwig   xfs: use per-file...
59
  	struct mutex qi_tree_lock;
92f8ff73f   Chandra Seetharaman   xfs: Add pquota f...
60
61
62
  	struct xfs_inode	*qi_uquotaip;	/* user quota inode */
  	struct xfs_inode	*qi_gquotaip;	/* group quota inode */
  	struct xfs_inode	*qi_pquotaip;	/* project quota inode */
cd56a39a5   Dave Chinner   xfs: convert dquo...
63
  	struct list_lru	 qi_lru;
3a25404b3   Dave Chinner   xfs: convert the ...
64
  	int		 qi_dquots;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
65
66
67
  	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 */
06d10dd9c   Nathan Scott   [XFS] Merge fixes...
68
69
70
  	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 */
a0b0b8a5b   Christoph Hellwig   xfs: kill mutex_t...
71
  	struct mutex	 qi_quotaofflock;/* to serialize quotaoff */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
72
73
  	xfs_filblks_t	 qi_dqchunklen;	 /* # BBs in a chunk of dqs */
  	uint		 qi_dqperchunk;	 /* # ondisk dqs in above chunk */
be6079461   Carlos Maiolino   xfs: Split defaul...
74
75
76
  	struct xfs_def_quota	qi_usr_default;
  	struct xfs_def_quota	qi_grp_default;
  	struct xfs_def_quota	qi_prj_default;
f8739c3ce   Christoph Hellwig   xfs: per-filesyst...
77
  	struct shrinker  qi_shrinker;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
78
  } xfs_quotainfo_t;
329e08752   Chandra Seetharaman   xfs: Replace macr...
79
80
81
82
83
84
85
86
87
  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:
329e08752   Chandra Seetharaman   xfs: Replace macr...
88
  		return &qi->qi_gquota_tree;
92f8ff73f   Chandra Seetharaman   xfs: Add pquota f...
89
90
  	case XFS_DQ_PROJ:
  		return &qi->qi_pquota_tree;
329e08752   Chandra Seetharaman   xfs: Replace macr...
91
92
93
94
95
  	default:
  		ASSERT(0);
  	}
  	return NULL;
  }
995961c45   Chandra Seetharaman   xfs: Replace macr...
96
97
  
  static inline struct xfs_inode *
4d4d9523b   Eric Sandeen   xfs: get quota in...
98
  xfs_quota_inode(xfs_mount_t *mp, uint dq_flags)
995961c45   Chandra Seetharaman   xfs: Replace macr...
99
  {
4d4d9523b   Eric Sandeen   xfs: get quota in...
100
  	switch (dq_flags & XFS_DQ_ALLTYPES) {
995961c45   Chandra Seetharaman   xfs: Replace macr...
101
  	case XFS_DQ_USER:
4d4d9523b   Eric Sandeen   xfs: get quota in...
102
  		return mp->m_quotainfo->qi_uquotaip;
995961c45   Chandra Seetharaman   xfs: Replace macr...
103
  	case XFS_DQ_GROUP:
4d4d9523b   Eric Sandeen   xfs: get quota in...
104
  		return mp->m_quotainfo->qi_gquotaip;
92f8ff73f   Chandra Seetharaman   xfs: Add pquota f...
105
  	case XFS_DQ_PROJ:
4d4d9523b   Eric Sandeen   xfs: get quota in...
106
  		return mp->m_quotainfo->qi_pquotaip;
995961c45   Chandra Seetharaman   xfs: Replace macr...
107
108
109
110
111
  	default:
  		ASSERT(0);
  	}
  	return NULL;
  }
113a56835   Chandra Seetharaman   xfs: Code cleanup...
112
113
114
115
  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 *,
92f8ff73f   Chandra Seetharaman   xfs: Add pquota f...
116
117
  			struct xfs_dquot *, struct xfs_dquot *,
  			long, long, uint);
113a56835   Chandra Seetharaman   xfs: Code cleanup...
118
119
  extern void	xfs_trans_dqjoin(struct xfs_trans *, struct xfs_dquot *);
  extern void	xfs_trans_log_dquot(struct xfs_trans *, struct xfs_dquot *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
120
121
  
  /*
92f8ff73f   Chandra Seetharaman   xfs: Add pquota f...
122
123
   * 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
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
124
125
   * affect no more than two dquots of one type. Hence, the TRANS_MAXDQS value.
   */
0e6436d99   Chandra Seetharaman   xfs: Change xfs_d...
126
127
128
  enum {
  	XFS_QM_TRANS_USR = 0,
  	XFS_QM_TRANS_GRP,
92f8ff73f   Chandra Seetharaman   xfs: Add pquota f...
129
  	XFS_QM_TRANS_PRJ,
0e6436d99   Chandra Seetharaman   xfs: Change xfs_d...
130
131
  	XFS_QM_TRANS_DQTYPES
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
132
  #define XFS_QM_TRANS_MAXDQS		2
0e6436d99   Chandra Seetharaman   xfs: Change xfs_d...
133
134
135
  struct xfs_dquot_acct {
  	struct xfs_dqtrx	dqs[XFS_QM_TRANS_DQTYPES][XFS_QM_TRANS_MAXDQS];
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
136
137
138
139
140
141
142
143
144
145
146
  
  /*
   * 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
06d10dd9c   Nathan Scott   [XFS] Merge fixes...
147
  #define XFS_QM_RTBWARNLIMIT	5
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
148

113a56835   Chandra Seetharaman   xfs: Code cleanup...
149
  extern void		xfs_qm_destroy_quotainfo(struct xfs_mount *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
150
151
  
  /* dquot stuff */
113a56835   Chandra Seetharaman   xfs: Code cleanup...
152
153
  extern void		xfs_qm_dqpurge_all(struct xfs_mount *, uint);
  extern void		xfs_qm_dqrele_all_inodes(struct xfs_mount *, uint);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
154

fcafb71b5   Christoph Hellwig   xfs: get rid of i...
155
  /* quota ops */
113a56835   Chandra Seetharaman   xfs: Code cleanup...
156
  extern int		xfs_qm_scall_trunc_qfiles(struct xfs_mount *, uint);
2e330e76e   Darrick J. Wong   xfs: refactor XFS...
157
158
159
160
  extern int		xfs_qm_scall_getquota(struct xfs_mount *, xfs_dqid_t,
  					uint, struct qc_dqblk *);
  extern int		xfs_qm_scall_getquota_next(struct xfs_mount *,
  					xfs_dqid_t *, uint, struct qc_dqblk *);
b13664511   Brian Foster   xfs: xfs_dquot pr...
161
  extern int		xfs_qm_scall_setqlim(struct xfs_mount *, xfs_dqid_t, uint,
14bf61ffe   Jan Kara   quota: Switch ->g...
162
  					struct qc_dqblk *);
113a56835   Chandra Seetharaman   xfs: Code cleanup...
163
164
  extern int		xfs_qm_scall_quotaon(struct xfs_mount *, uint);
  extern int		xfs_qm_scall_quotaoff(struct xfs_mount *, uint);
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
165

be6079461   Carlos Maiolino   xfs: Split defaul...
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
  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;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
181
  #endif /* __XFS_QM_H__ */