Blame view

fs/xfs/xfs_quota.h 5.69 KB
0b61f8a40   Dave Chinner   xfs: convert to S...
1
  // SPDX-License-Identifier: GPL-2.0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
  /*
7b7187698   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
   */
  #ifndef __XFS_QUOTA_H__
  #define __XFS_QUOTA_H__
76456fc2a   Dave Chinner   xfs: introduce xf...
8
  #include "xfs_quota_defs.h"
fcafb71b5   Christoph Hellwig   xfs: get rid of i...
9

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10
  /*
76456fc2a   Dave Chinner   xfs: introduce xf...
11
   * Kernel only quota definitions and functions
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
12
   */
c8ad20ffe   Nathan Scott   [XFS] Add support...
13

76456fc2a   Dave Chinner   xfs: introduce xf...
14
  struct xfs_trans;
6f5de1808   Dave Chinner   xfs: use direct c...
15
  struct xfs_buf;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
16

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17
18
  /*
   * This check is done typically without holding the inode lock;
c41564b5a   Nathan Scott   [XFS] We really s...
19
   * that may seem racy, but it is harmless in the context that it is used.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
20
21
22
23
24
25
   * 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.
   */
92f8ff73f   Chandra Seetharaman   xfs: Add pquota f...
26
27
28
29
  #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))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30

c8ad20ffe   Nathan Scott   [XFS] Add support...
31
32
33
34
  #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) && \
83e782e1a   Chandra Seetharaman   xfs: Remove incor...
35
  		(mp->m_sb.sb_qflags & XFS_GQUOTA_CHKD) == 0) || \
c8ad20ffe   Nathan Scott   [XFS] Add support...
36
  	 (XFS_IS_PQUOTA_ON(mp) && \
83e782e1a   Chandra Seetharaman   xfs: Remove incor...
37
  		(mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
38

7e85bc6c8   Darrick J. Wong   xfs: add helpers ...
39
40
  static inline uint
  xfs_quota_chkd_flag(
1a7ed2716   Darrick J. Wong   xfs: create xfs_d...
41
  	xfs_dqtype_t		type)
7e85bc6c8   Darrick J. Wong   xfs: add helpers ...
42
  {
1a7ed2716   Darrick J. Wong   xfs: create xfs_d...
43
  	switch (type) {
8cd4901da   Darrick J. Wong   xfs: rename XFS_D...
44
  	case XFS_DQTYPE_USER:
7e85bc6c8   Darrick J. Wong   xfs: add helpers ...
45
  		return XFS_UQUOTA_CHKD;
8cd4901da   Darrick J. Wong   xfs: rename XFS_D...
46
  	case XFS_DQTYPE_GROUP:
7e85bc6c8   Darrick J. Wong   xfs: add helpers ...
47
  		return XFS_GQUOTA_CHKD;
8cd4901da   Darrick J. Wong   xfs: rename XFS_D...
48
  	case XFS_DQTYPE_PROJ:
7e85bc6c8   Darrick J. Wong   xfs: add helpers ...
49
50
51
52
53
  		return XFS_PQUOTA_CHKD;
  	default:
  		return 0;
  	}
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
54
55
56
57
  /*
   * The structure kept inside the xfs_trans_t keep track of dquot changes
   * within a transaction and apply them later.
   */
078f4a7d3   Darrick J. Wong   xfs: kill the xfs...
58
  struct xfs_dqtrx {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
59
  	struct xfs_dquot *qt_dquot;	  /* the dquot this refers to */
903b1fc27   Darrick J. Wong   xfs: widen quota ...
60
61
62
63
64
65
66
67
68
69
70
71
72
  
  	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 */
078f4a7d3   Darrick J. Wong   xfs: kill the xfs...
73
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
74

7d095257e   Christoph Hellwig   xfs: kill xfs_qmops
75
76
77
78
  #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 *,
903b1fc27   Darrick J. Wong   xfs: widen quota ...
79
  		uint, int64_t);
7d095257e   Christoph Hellwig   xfs: kill xfs_qmops
80
81
82
  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 *,
903b1fc27   Darrick J. Wong   xfs: widen quota ...
83
  		struct xfs_inode *, int64_t, long, uint);
7d095257e   Christoph Hellwig   xfs: kill xfs_qmops
84
85
  extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *,
  		struct xfs_mount *, struct xfs_dquot *,
903b1fc27   Darrick J. Wong   xfs: widen quota ...
86
  		struct xfs_dquot *, struct xfs_dquot *, int64_t, long, uint);
7d095257e   Christoph Hellwig   xfs: kill xfs_qmops
87

542951592   Christoph Hellwig   xfs: remove the i...
88
  extern int xfs_qm_vop_dqalloc(struct xfs_inode *, kuid_t, kgid_t,
7aab1b288   Dwight Engen   xfs: convert kuid...
89
90
  		prid_t, uint, struct xfs_dquot **, struct xfs_dquot **,
  		struct xfs_dquot **);
7d095257e   Christoph Hellwig   xfs: kill xfs_qmops
91
  extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *,
92f8ff73f   Chandra Seetharaman   xfs: Add pquota f...
92
  		struct xfs_dquot *, struct xfs_dquot *, struct xfs_dquot *);
7d095257e   Christoph Hellwig   xfs: kill xfs_qmops
93
94
95
96
  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 *,
92f8ff73f   Chandra Seetharaman   xfs: Add pquota f...
97
98
  		struct xfs_dquot *, struct xfs_dquot *,
  		struct xfs_dquot *, uint);
c14cfccab   Darrick J. Wong   xfs: remove unnec...
99
  extern int xfs_qm_dqattach(struct xfs_inode *);
4882c19d2   Darrick J. Wong   xfs: split out dq...
100
  extern int xfs_qm_dqattach_locked(struct xfs_inode *ip, bool doalloc);
7d095257e   Christoph Hellwig   xfs: kill xfs_qmops
101
102
103
  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 *);
7d095257e   Christoph Hellwig   xfs: kill xfs_qmops
104
105
106
107
108
109
  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 *);
  
  #else
493b87e5e   Christoph Hellwig   xfs: fix warnings...
110
  static inline int
542951592   Christoph Hellwig   xfs: remove the i...
111
  xfs_qm_vop_dqalloc(struct xfs_inode *ip, kuid_t kuid, kgid_t kgid,
7aab1b288   Dwight Engen   xfs: convert kuid...
112
113
  		prid_t prid, uint flags, struct xfs_dquot **udqp,
  		struct xfs_dquot **gdqp, struct xfs_dquot **pdqp)
493b87e5e   Christoph Hellwig   xfs: fix warnings...
114
115
116
  {
  	*udqp = NULL;
  	*gdqp = NULL;
92f8ff73f   Chandra Seetharaman   xfs: Add pquota f...
117
  	*pdqp = NULL;
493b87e5e   Christoph Hellwig   xfs: fix warnings...
118
119
  	return 0;
  }
7d095257e   Christoph Hellwig   xfs: kill xfs_qmops
120
121
122
123
124
  #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)
5d2bf8a55   Christoph Hellwig   xfs: fix a few co...
125
  static inline int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp,
903b1fc27   Darrick J. Wong   xfs: widen quota ...
126
  		struct xfs_inode *ip, int64_t nblks, long ninos, uint flags)
5d2bf8a55   Christoph Hellwig   xfs: fix a few co...
127
128
129
130
131
  {
  	return 0;
  }
  static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
  		struct xfs_mount *mp, struct xfs_dquot *udqp,
92f8ff73f   Chandra Seetharaman   xfs: Add pquota f...
132
  		struct xfs_dquot *gdqp, struct xfs_dquot *pdqp,
903b1fc27   Darrick J. Wong   xfs: widen quota ...
133
  		int64_t nblks, long nions, uint flags)
5d2bf8a55   Christoph Hellwig   xfs: fix a few co...
134
135
136
  {
  	return 0;
  }
92f8ff73f   Chandra Seetharaman   xfs: Add pquota f...
137
  #define xfs_qm_vop_create_dqattach(tp, ip, u, g, p)
7d095257e   Christoph Hellwig   xfs: kill xfs_qmops
138
139
  #define xfs_qm_vop_rename_dqattach(it)					(0)
  #define xfs_qm_vop_chown(tp, ip, old, new)				(NULL)
92f8ff73f   Chandra Seetharaman   xfs: Add pquota f...
140
  #define xfs_qm_vop_chown_reserve(tp, ip, u, g, p, fl)			(0)
c14cfccab   Darrick J. Wong   xfs: remove unnec...
141
  #define xfs_qm_dqattach(ip)						(0)
7d095257e   Christoph Hellwig   xfs: kill xfs_qmops
142
143
144
145
  #define xfs_qm_dqattach_locked(ip, fl)					(0)
  #define xfs_qm_dqdetach(ip)
  #define xfs_qm_dqrele(d)
  #define xfs_qm_statvfs(ip, s)
7d095257e   Christoph Hellwig   xfs: kill xfs_qmops
146
147
148
  #define xfs_qm_newmount(mp, a, b)					(0)
  #define xfs_qm_mount_quotas(mp)
  #define xfs_qm_unmount(mp)
5d2bf8a55   Christoph Hellwig   xfs: fix a few co...
149
  #define xfs_qm_unmount_quotas(mp)
7d095257e   Christoph Hellwig   xfs: kill xfs_qmops
150
151
152
153
  #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)
92f8ff73f   Chandra Seetharaman   xfs: Add pquota f...
154
155
  #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, \
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
156
  				f | XFS_QMOPT_RES_REGBLKS)
4cd4a034a   Tim Shimmin   [XFS] Need to be ...
157
  extern int xfs_mount_reset_sbqflags(struct xfs_mount *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
158

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
159
  #endif	/* __XFS_QUOTA_H__ */