xref: /openbmc/linux/include/linux/quotaops.h (revision 869b6ea1)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * Definitions for diskquota-operations. When diskquota is configured these
41da177e4SLinus Torvalds  * macros expand to the right source-code.
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  * Author:  Marco van Wieringen <mvw@planets.elm.net>
71da177e4SLinus Torvalds  */
81da177e4SLinus Torvalds #ifndef _LINUX_QUOTAOPS_
91da177e4SLinus Torvalds #define _LINUX_QUOTAOPS_
101da177e4SLinus Torvalds 
111da177e4SLinus Torvalds #include <linux/fs.h>
121da177e4SLinus Torvalds 
1356246f9aSEric Sandeen #define DQUOT_SPACE_WARN	0x1
1456246f9aSEric Sandeen #define DQUOT_SPACE_RESERVE	0x2
150e05842bSEric Sandeen #define DQUOT_SPACE_NOFAIL	0x4
1656246f9aSEric Sandeen 
sb_dqopt(struct super_block * sb)1703b06343SJan Kara static inline struct quota_info *sb_dqopt(struct super_block *sb)
1803b06343SJan Kara {
1903b06343SJan Kara 	return &sb->s_dquot;
2003b06343SJan Kara }
2174abb989SJan Kara 
2212755627SDmitry Monakhov /* i_mutex must being held */
is_quota_modification(struct mnt_idmap * idmap,struct inode * inode,struct iattr * ia)23f861646aSChristian Brauner static inline bool is_quota_modification(struct mnt_idmap *idmap,
2471e7b535SChristian Brauner 					 struct inode *inode, struct iattr *ia)
2512755627SDmitry Monakhov {
2635faf310SChristian Brauner 	return ((ia->ia_valid & ATTR_SIZE) ||
270dbe12f2SChristian Brauner 		i_uid_needs_update(idmap, ia, inode) ||
280dbe12f2SChristian Brauner 		i_gid_needs_update(idmap, ia, inode));
2912755627SDmitry Monakhov }
3012755627SDmitry Monakhov 
311da177e4SLinus Torvalds #if defined(CONFIG_QUOTA)
321da177e4SLinus Torvalds 
33fb5ffb0eSJiaying Zhang #define quota_error(sb, fmt, args...) \
34fb5ffb0eSJiaying Zhang 	__quota_error((sb), __func__, fmt , ## args)
35fb5ffb0eSJiaying Zhang 
36b9075fa9SJoe Perches extern __printf(3, 4)
37055adcbdSJoe Perches void __quota_error(struct super_block *sb, const char *func,
38fb5ffb0eSJiaying Zhang 		   const char *fmt, ...);
39fb5ffb0eSJiaying Zhang 
401da177e4SLinus Torvalds /*
411da177e4SLinus Torvalds  * declaration of quota_function calls in kernel.
421da177e4SLinus Torvalds  */
436184fc0bSJan Kara int dquot_initialize(struct inode *inode);
44b8cb5a54STahsin Erdogan bool dquot_initialize_needed(struct inode *inode);
459f754758SChristoph Hellwig void dquot_drop(struct inode *inode);
46aca645a6SEric W. Biederman struct dquot *dqget(struct super_block *sb, struct kqid qid);
dqgrab(struct dquot * dquot)479f985cb6SJan Kara static inline struct dquot *dqgrab(struct dquot *dquot)
489f985cb6SJan Kara {
499f985cb6SJan Kara 	/* Make sure someone else has active reference to dquot */
509f985cb6SJan Kara 	WARN_ON_ONCE(!atomic_read(&dquot->dq_count));
519f985cb6SJan Kara 	WARN_ON_ONCE(!test_bit(DQ_ACTIVE_B, &dquot->dq_flags));
529f985cb6SJan Kara 	atomic_inc(&dquot->dq_count);
539f985cb6SJan Kara 	return dquot;
549f985cb6SJan Kara }
55df4bb5d1SDmitry Monakhov 
dquot_is_busy(struct dquot * dquot)56df4bb5d1SDmitry Monakhov static inline bool dquot_is_busy(struct dquot *dquot)
57df4bb5d1SDmitry Monakhov {
58df4bb5d1SDmitry Monakhov 	if (test_bit(DQ_MOD_B, &dquot->dq_flags))
59df4bb5d1SDmitry Monakhov 		return true;
60*869b6ea1SJan Kara 	if (atomic_read(&dquot->dq_count) > 0)
61df4bb5d1SDmitry Monakhov 		return true;
62df4bb5d1SDmitry Monakhov 	return false;
63df4bb5d1SDmitry Monakhov }
64df4bb5d1SDmitry Monakhov 
653d9ea253SJan Kara void dqput(struct dquot *dquot);
6612c77527SJan Kara int dquot_scan_active(struct super_block *sb,
6712c77527SJan Kara 		      int (*fn)(struct dquot *dquot, unsigned long priv),
6812c77527SJan Kara 		      unsigned long priv);
697d9056baSJan Kara struct dquot *dquot_alloc(struct super_block *sb, int type);
707d9056baSJan Kara void dquot_destroy(struct dquot *dquot);
711da177e4SLinus Torvalds 
7256246f9aSEric Sandeen int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags);
7356246f9aSEric Sandeen void __dquot_free_space(struct inode *inode, qsize_t number, int flags);
745dd4056dSChristoph Hellwig 
756bab3596SJan Kara int dquot_alloc_inode(struct inode *inode);
761da177e4SLinus Torvalds 
775dd4056dSChristoph Hellwig int dquot_claim_space_nodirty(struct inode *inode, qsize_t number);
786bab3596SJan Kara void dquot_free_inode(struct inode *inode);
791c8924ebSJan Kara void dquot_reclaim_space_nodirty(struct inode *inode, qsize_t number);
801da177e4SLinus Torvalds 
810f0dd62fSChristoph Hellwig int dquot_disable(struct super_block *sb, int type, unsigned int flags);
820f0dd62fSChristoph Hellwig /* Suspend quotas on remount RO */
dquot_suspend(struct super_block * sb,int type)830f0dd62fSChristoph Hellwig static inline int dquot_suspend(struct super_block *sb, int type)
840f0dd62fSChristoph Hellwig {
850f0dd62fSChristoph Hellwig 	return dquot_disable(sb, type, DQUOT_SUSPENDED);
860f0dd62fSChristoph Hellwig }
870f0dd62fSChristoph Hellwig int dquot_resume(struct super_block *sb, int type);
880f0dd62fSChristoph Hellwig 
89b85f4b87SJan Kara int dquot_commit(struct dquot *dquot);
90b85f4b87SJan Kara int dquot_acquire(struct dquot *dquot);
91b85f4b87SJan Kara int dquot_release(struct dquot *dquot);
92b85f4b87SJan Kara int dquot_commit_info(struct super_block *sb, int type);
93be6257b2SJan Kara int dquot_get_next_id(struct super_block *sb, struct kqid *qid);
94b85f4b87SJan Kara int dquot_mark_dquot_dirty(struct dquot *dquot);
951da177e4SLinus Torvalds 
96907f4554SChristoph Hellwig int dquot_file_open(struct inode *inode, struct file *file);
97907f4554SChristoph Hellwig 
98c7d3d283SJan Kara int dquot_load_quota_sb(struct super_block *sb, int type, int format_id,
99c7d3d283SJan Kara 	unsigned int flags);
100dc19432aSJan Kara int dquot_load_quota_inode(struct inode *inode, int type, int format_id,
101f55abc0fSJan Kara 	unsigned int flags);
102f00c9e44SJan Kara int dquot_quota_on(struct super_block *sb, int type, int format_id,
1038c54ca9cSAl Viro 	const struct path *path);
104287a8095SChristoph Hellwig int dquot_quota_on_mount(struct super_block *sb, char *qf_name,
10584de856eSChristoph Hellwig  	int format_id, int type);
106287a8095SChristoph Hellwig int dquot_quota_off(struct super_block *sb, int type);
107ceed1723SJan Kara int dquot_writeback_dquots(struct super_block *sb, int type);
108ceed1723SJan Kara int dquot_quota_sync(struct super_block *sb, int type);
1090a240339SJan Kara int dquot_get_state(struct super_block *sb, struct qc_state *state);
1105eacb2acSJan Kara int dquot_set_dqinfo(struct super_block *sb, int type, struct qc_info *ii);
11174a8a103SEric W. Biederman int dquot_get_dqblk(struct super_block *sb, struct kqid id,
11214bf61ffSJan Kara 		struct qc_dqblk *di);
113be6257b2SJan Kara int dquot_get_next_dqblk(struct super_block *sb, struct kqid *id,
114be6257b2SJan Kara 		struct qc_dqblk *di);
11574a8a103SEric W. Biederman int dquot_set_dqblk(struct super_block *sb, struct kqid id,
11614bf61ffSJan Kara 		struct qc_dqblk *di);
117b85f4b87SJan Kara 
118bc8e5f07SJan Kara int __dquot_transfer(struct inode *inode, struct dquot **transfer_to);
119f861646aSChristian Brauner int dquot_transfer(struct mnt_idmap *idmap, struct inode *inode,
12071e7b535SChristian Brauner 		   struct iattr *iattr);
1211da177e4SLinus Torvalds 
sb_dqinfo(struct super_block * sb,int type)12203b06343SJan Kara static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
12303b06343SJan Kara {
12403b06343SJan Kara 	return sb_dqopt(sb)->info + type;
12503b06343SJan Kara }
12674abb989SJan Kara 
12774abb989SJan Kara /*
12874abb989SJan Kara  * Functions for checking status of quota
12974abb989SJan Kara  */
13074abb989SJan Kara 
sb_has_quota_usage_enabled(struct super_block * sb,int type)131ad1e6e8dSDmitry Monakhov static inline bool sb_has_quota_usage_enabled(struct super_block *sb, int type)
13203b06343SJan Kara {
133f55abc0fSJan Kara 	return sb_dqopt(sb)->flags &
134f55abc0fSJan Kara 				dquot_state_flag(DQUOT_USAGE_ENABLED, type);
13503b06343SJan Kara }
13674abb989SJan Kara 
sb_has_quota_limits_enabled(struct super_block * sb,int type)137ad1e6e8dSDmitry Monakhov static inline bool sb_has_quota_limits_enabled(struct super_block *sb, int type)
13803b06343SJan Kara {
139f55abc0fSJan Kara 	return sb_dqopt(sb)->flags &
140f55abc0fSJan Kara 				dquot_state_flag(DQUOT_LIMITS_ENABLED, type);
14103b06343SJan Kara }
14274abb989SJan Kara 
sb_has_quota_suspended(struct super_block * sb,int type)143ad1e6e8dSDmitry Monakhov static inline bool sb_has_quota_suspended(struct super_block *sb, int type)
14403b06343SJan Kara {
145f55abc0fSJan Kara 	return sb_dqopt(sb)->flags &
146f55abc0fSJan Kara 				dquot_state_flag(DQUOT_SUSPENDED, type);
14703b06343SJan Kara }
14874abb989SJan Kara 
sb_any_quota_suspended(struct super_block * sb)149ad1e6e8dSDmitry Monakhov static inline unsigned sb_any_quota_suspended(struct super_block *sb)
15003b06343SJan Kara {
15178197024SKonstantin Khlebnikov 	return dquot_state_types(sb_dqopt(sb)->flags, DQUOT_SUSPENDED);
15203b06343SJan Kara }
15374abb989SJan Kara 
154f55abc0fSJan Kara /* Does kernel know about any quota information for given sb + type? */
sb_has_quota_loaded(struct super_block * sb,int type)155ad1e6e8dSDmitry Monakhov static inline bool sb_has_quota_loaded(struct super_block *sb, int type)
156f55abc0fSJan Kara {
157f55abc0fSJan Kara 	/* Currently if anything is on, then quota usage is on as well */
158f55abc0fSJan Kara 	return sb_has_quota_usage_enabled(sb, type);
159f55abc0fSJan Kara }
160f55abc0fSJan Kara 
sb_any_quota_loaded(struct super_block * sb)161ad1e6e8dSDmitry Monakhov static inline unsigned sb_any_quota_loaded(struct super_block *sb)
162f55abc0fSJan Kara {
16378197024SKonstantin Khlebnikov 	return dquot_state_types(sb_dqopt(sb)->flags, DQUOT_USAGE_ENABLED);
164f55abc0fSJan Kara }
165f55abc0fSJan Kara 
sb_has_quota_active(struct super_block * sb,int type)166ad1e6e8dSDmitry Monakhov static inline bool sb_has_quota_active(struct super_block *sb, int type)
167f55abc0fSJan Kara {
168f55abc0fSJan Kara 	return sb_has_quota_loaded(sb, type) &&
169f55abc0fSJan Kara 	       !sb_has_quota_suspended(sb, type);
170f55abc0fSJan Kara }
171f55abc0fSJan Kara 
1721da177e4SLinus Torvalds /*
1731da177e4SLinus Torvalds  * Operations supported for diskquotas.
1741da177e4SLinus Torvalds  */
17561e225dcSAlexey Dobriyan extern const struct dquot_operations dquot_operations;
1763e2af67eSJan Kara extern const struct quotactl_ops dquot_quotactl_sysfile_ops;
1770ff5af83SJan Kara 
1781da177e4SLinus Torvalds #else
1791da177e4SLinus Torvalds 
sb_has_quota_usage_enabled(struct super_block * sb,int type)180f55abc0fSJan Kara static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type)
18103b06343SJan Kara {
18203b06343SJan Kara 	return 0;
18303b06343SJan Kara }
18403b06343SJan Kara 
sb_has_quota_limits_enabled(struct super_block * sb,int type)185f55abc0fSJan Kara static inline int sb_has_quota_limits_enabled(struct super_block *sb, int type)
18603b06343SJan Kara {
18703b06343SJan Kara 	return 0;
18803b06343SJan Kara }
18903b06343SJan Kara 
sb_has_quota_suspended(struct super_block * sb,int type)19003b06343SJan Kara static inline int sb_has_quota_suspended(struct super_block *sb, int type)
19103b06343SJan Kara {
19203b06343SJan Kara 	return 0;
19303b06343SJan Kara }
19403b06343SJan Kara 
sb_any_quota_suspended(struct super_block * sb)19503b06343SJan Kara static inline int sb_any_quota_suspended(struct super_block *sb)
19603b06343SJan Kara {
19703b06343SJan Kara 	return 0;
19803b06343SJan Kara }
19974abb989SJan Kara 
200f55abc0fSJan Kara /* Does kernel know about any quota information for given sb + type? */
sb_has_quota_loaded(struct super_block * sb,int type)201f55abc0fSJan Kara static inline int sb_has_quota_loaded(struct super_block *sb, int type)
202f55abc0fSJan Kara {
203f55abc0fSJan Kara 	return 0;
204f55abc0fSJan Kara }
205f55abc0fSJan Kara 
sb_any_quota_loaded(struct super_block * sb)206f55abc0fSJan Kara static inline int sb_any_quota_loaded(struct super_block *sb)
207f55abc0fSJan Kara {
208f55abc0fSJan Kara 	return 0;
209f55abc0fSJan Kara }
210f55abc0fSJan Kara 
sb_has_quota_active(struct super_block * sb,int type)211f55abc0fSJan Kara static inline int sb_has_quota_active(struct super_block *sb, int type)
212f55abc0fSJan Kara {
213f55abc0fSJan Kara 	return 0;
214f55abc0fSJan Kara }
215f55abc0fSJan Kara 
dquot_initialize(struct inode * inode)2166184fc0bSJan Kara static inline int dquot_initialize(struct inode *inode)
21750f8c370SAndrew Morton {
2186184fc0bSJan Kara 	return 0;
21950f8c370SAndrew Morton }
22050f8c370SAndrew Morton 
dquot_initialize_needed(struct inode * inode)221b8cb5a54STahsin Erdogan static inline bool dquot_initialize_needed(struct inode *inode)
222b8cb5a54STahsin Erdogan {
223b8cb5a54STahsin Erdogan 	return false;
224b8cb5a54STahsin Erdogan }
225b8cb5a54STahsin Erdogan 
dquot_drop(struct inode * inode)2269f754758SChristoph Hellwig static inline void dquot_drop(struct inode *inode)
22750f8c370SAndrew Morton {
22850f8c370SAndrew Morton }
22950f8c370SAndrew Morton 
dquot_alloc_inode(struct inode * inode)2306bab3596SJan Kara static inline int dquot_alloc_inode(struct inode *inode)
23150f8c370SAndrew Morton {
23250f8c370SAndrew Morton 	return 0;
23350f8c370SAndrew Morton }
23450f8c370SAndrew Morton 
dquot_free_inode(struct inode * inode)2356bab3596SJan Kara static inline void dquot_free_inode(struct inode *inode)
23650f8c370SAndrew Morton {
23750f8c370SAndrew Morton }
23850f8c370SAndrew Morton 
dquot_transfer(struct mnt_idmap * idmap,struct inode * inode,struct iattr * iattr)239f861646aSChristian Brauner static inline int dquot_transfer(struct mnt_idmap *idmap,
24071e7b535SChristian Brauner 				 struct inode *inode, struct iattr *iattr)
24150f8c370SAndrew Morton {
24250f8c370SAndrew Morton 	return 0;
24350f8c370SAndrew Morton }
24450f8c370SAndrew Morton 
__dquot_alloc_space(struct inode * inode,qsize_t number,int flags)2455dd4056dSChristoph Hellwig static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
24656246f9aSEric Sandeen 		int flags)
2471da177e4SLinus Torvalds {
24856246f9aSEric Sandeen 	if (!(flags & DQUOT_SPACE_RESERVE))
2495dd4056dSChristoph Hellwig 		inode_add_bytes(inode, number);
2501da177e4SLinus Torvalds 	return 0;
2511da177e4SLinus Torvalds }
2521da177e4SLinus Torvalds 
__dquot_free_space(struct inode * inode,qsize_t number,int flags)2535dd4056dSChristoph Hellwig static inline void __dquot_free_space(struct inode *inode, qsize_t number,
25456246f9aSEric Sandeen 		int flags)
2551da177e4SLinus Torvalds {
25656246f9aSEric Sandeen 	if (!(flags & DQUOT_SPACE_RESERVE))
2575dd4056dSChristoph Hellwig 		inode_sub_bytes(inode, number);
2585dd4056dSChristoph Hellwig }
2595dd4056dSChristoph Hellwig 
dquot_claim_space_nodirty(struct inode * inode,qsize_t number)2605dd4056dSChristoph Hellwig static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
2615dd4056dSChristoph Hellwig {
2625dd4056dSChristoph Hellwig 	inode_add_bytes(inode, number);
2631da177e4SLinus Torvalds 	return 0;
2641da177e4SLinus Torvalds }
2651da177e4SLinus Torvalds 
dquot_reclaim_space_nodirty(struct inode * inode,qsize_t number)2661c8924ebSJan Kara static inline int dquot_reclaim_space_nodirty(struct inode *inode,
2671c8924ebSJan Kara 					      qsize_t number)
2681c8924ebSJan Kara {
2691c8924ebSJan Kara 	inode_sub_bytes(inode, number);
2701c8924ebSJan Kara 	return 0;
2711c8924ebSJan Kara }
2721c8924ebSJan Kara 
dquot_disable(struct super_block * sb,int type,unsigned int flags)2730f0dd62fSChristoph Hellwig static inline int dquot_disable(struct super_block *sb, int type,
2740f0dd62fSChristoph Hellwig 		unsigned int flags)
2750f0dd62fSChristoph Hellwig {
2760f0dd62fSChristoph Hellwig 	return 0;
2770f0dd62fSChristoph Hellwig }
2780f0dd62fSChristoph Hellwig 
dquot_suspend(struct super_block * sb,int type)2790f0dd62fSChristoph Hellwig static inline int dquot_suspend(struct super_block *sb, int type)
2800f0dd62fSChristoph Hellwig {
2810f0dd62fSChristoph Hellwig 	return 0;
2820f0dd62fSChristoph Hellwig }
2830f0dd62fSChristoph Hellwig 
dquot_resume(struct super_block * sb,int type)2840f0dd62fSChristoph Hellwig static inline int dquot_resume(struct super_block *sb, int type)
2850f0dd62fSChristoph Hellwig {
2860f0dd62fSChristoph Hellwig 	return 0;
2870f0dd62fSChristoph Hellwig }
2880f0dd62fSChristoph Hellwig 
289871a2931SChristoph Hellwig #define dquot_file_open		generic_file_open
290871a2931SChristoph Hellwig 
dquot_writeback_dquots(struct super_block * sb,int type)291ceed1723SJan Kara static inline int dquot_writeback_dquots(struct super_block *sb, int type)
292ceed1723SJan Kara {
293ceed1723SJan Kara 	return 0;
294ceed1723SJan Kara }
295ceed1723SJan Kara 
2961da177e4SLinus Torvalds #endif /* CONFIG_QUOTA */
2971da177e4SLinus Torvalds 
dquot_alloc_space_nodirty(struct inode * inode,qsize_t nr)2985dd4056dSChristoph Hellwig static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr)
29903f6e92bSJan Kara {
30056246f9aSEric Sandeen 	return __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN);
30103f6e92bSJan Kara }
30203f6e92bSJan Kara 
dquot_alloc_space_nofail(struct inode * inode,qsize_t nr)3030e05842bSEric Sandeen static inline void dquot_alloc_space_nofail(struct inode *inode, qsize_t nr)
3040e05842bSEric Sandeen {
3050e05842bSEric Sandeen 	__dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN|DQUOT_SPACE_NOFAIL);
30643d2932dSJan Kara 	mark_inode_dirty_sync(inode);
30703f6e92bSJan Kara }
30803f6e92bSJan Kara 
dquot_alloc_space(struct inode * inode,qsize_t nr)3095dd4056dSChristoph Hellwig static inline int dquot_alloc_space(struct inode *inode, qsize_t nr)
31003f6e92bSJan Kara {
3115dd4056dSChristoph Hellwig 	int ret;
3125dd4056dSChristoph Hellwig 
3135dd4056dSChristoph Hellwig 	ret = dquot_alloc_space_nodirty(inode, nr);
314d530148aSShaohua Li 	if (!ret) {
315d530148aSShaohua Li 		/*
316d530148aSShaohua Li 		 * Mark inode fully dirty. Since we are allocating blocks, inode
317d530148aSShaohua Li 		 * would become fully dirty soon anyway and it reportedly
318250df6edSDave Chinner 		 * reduces lock contention.
319d530148aSShaohua Li 		 */
320d530148aSShaohua Li 		mark_inode_dirty(inode);
321d530148aSShaohua Li 	}
3225dd4056dSChristoph Hellwig 	return ret;
32303f6e92bSJan Kara }
32403f6e92bSJan Kara 
dquot_alloc_block_nodirty(struct inode * inode,qsize_t nr)3255dd4056dSChristoph Hellwig static inline int dquot_alloc_block_nodirty(struct inode *inode, qsize_t nr)
32603f6e92bSJan Kara {
3275dd4056dSChristoph Hellwig 	return dquot_alloc_space_nodirty(inode, nr << inode->i_blkbits);
32803f6e92bSJan Kara }
32903f6e92bSJan Kara 
dquot_alloc_block_nofail(struct inode * inode,qsize_t nr)3300e05842bSEric Sandeen static inline void dquot_alloc_block_nofail(struct inode *inode, qsize_t nr)
3310e05842bSEric Sandeen {
3320e05842bSEric Sandeen 	dquot_alloc_space_nofail(inode, nr << inode->i_blkbits);
3330e05842bSEric Sandeen }
3340e05842bSEric Sandeen 
dquot_alloc_block(struct inode * inode,qsize_t nr)3355dd4056dSChristoph Hellwig static inline int dquot_alloc_block(struct inode *inode, qsize_t nr)
33603f6e92bSJan Kara {
3375dd4056dSChristoph Hellwig 	return dquot_alloc_space(inode, nr << inode->i_blkbits);
33803f6e92bSJan Kara }
33903f6e92bSJan Kara 
dquot_prealloc_block_nodirty(struct inode * inode,qsize_t nr)3405dd4056dSChristoph Hellwig static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr)
341f18df228SMingming Cao {
34256246f9aSEric Sandeen 	return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0);
343f18df228SMingming Cao }
344f18df228SMingming Cao 
dquot_prealloc_block(struct inode * inode,qsize_t nr)3455dd4056dSChristoph Hellwig static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr)
346740d9dcdSMingming Cao {
3475dd4056dSChristoph Hellwig 	int ret;
3485dd4056dSChristoph Hellwig 
3495dd4056dSChristoph Hellwig 	ret = dquot_prealloc_block_nodirty(inode, nr);
3505dd4056dSChristoph Hellwig 	if (!ret)
35143d2932dSJan Kara 		mark_inode_dirty_sync(inode);
3525dd4056dSChristoph Hellwig 	return ret;
353740d9dcdSMingming Cao }
354740d9dcdSMingming Cao 
dquot_reserve_block(struct inode * inode,qsize_t nr)3555dd4056dSChristoph Hellwig static inline int dquot_reserve_block(struct inode *inode, qsize_t nr)
356740d9dcdSMingming Cao {
35756246f9aSEric Sandeen 	return __dquot_alloc_space(inode, nr << inode->i_blkbits,
35856246f9aSEric Sandeen 				DQUOT_SPACE_WARN|DQUOT_SPACE_RESERVE);
359740d9dcdSMingming Cao }
360740d9dcdSMingming Cao 
dquot_claim_block(struct inode * inode,qsize_t nr)3615dd4056dSChristoph Hellwig static inline int dquot_claim_block(struct inode *inode, qsize_t nr)
36203f6e92bSJan Kara {
3635dd4056dSChristoph Hellwig 	int ret;
3645dd4056dSChristoph Hellwig 
3655dd4056dSChristoph Hellwig 	ret = dquot_claim_space_nodirty(inode, nr << inode->i_blkbits);
3665dd4056dSChristoph Hellwig 	if (!ret)
36743d2932dSJan Kara 		mark_inode_dirty_sync(inode);
3685dd4056dSChristoph Hellwig 	return ret;
36903f6e92bSJan Kara }
37003f6e92bSJan Kara 
dquot_reclaim_block(struct inode * inode,qsize_t nr)3711c8924ebSJan Kara static inline void dquot_reclaim_block(struct inode *inode, qsize_t nr)
3721c8924ebSJan Kara {
3731c8924ebSJan Kara 	dquot_reclaim_space_nodirty(inode, nr << inode->i_blkbits);
3741c8924ebSJan Kara 	mark_inode_dirty_sync(inode);
3751c8924ebSJan Kara }
3761c8924ebSJan Kara 
dquot_free_space_nodirty(struct inode * inode,qsize_t nr)3775dd4056dSChristoph Hellwig static inline void dquot_free_space_nodirty(struct inode *inode, qsize_t nr)
37803f6e92bSJan Kara {
3795dd4056dSChristoph Hellwig 	__dquot_free_space(inode, nr, 0);
3805dd4056dSChristoph Hellwig }
3815dd4056dSChristoph Hellwig 
dquot_free_space(struct inode * inode,qsize_t nr)3825dd4056dSChristoph Hellwig static inline void dquot_free_space(struct inode *inode, qsize_t nr)
3835dd4056dSChristoph Hellwig {
3845dd4056dSChristoph Hellwig 	dquot_free_space_nodirty(inode, nr);
38543d2932dSJan Kara 	mark_inode_dirty_sync(inode);
3865dd4056dSChristoph Hellwig }
3875dd4056dSChristoph Hellwig 
dquot_free_block_nodirty(struct inode * inode,qsize_t nr)3885dd4056dSChristoph Hellwig static inline void dquot_free_block_nodirty(struct inode *inode, qsize_t nr)
3895dd4056dSChristoph Hellwig {
3905dd4056dSChristoph Hellwig 	dquot_free_space_nodirty(inode, nr << inode->i_blkbits);
3915dd4056dSChristoph Hellwig }
3925dd4056dSChristoph Hellwig 
dquot_free_block(struct inode * inode,qsize_t nr)3935dd4056dSChristoph Hellwig static inline void dquot_free_block(struct inode *inode, qsize_t nr)
3945dd4056dSChristoph Hellwig {
3955dd4056dSChristoph Hellwig 	dquot_free_space(inode, nr << inode->i_blkbits);
3965dd4056dSChristoph Hellwig }
3975dd4056dSChristoph Hellwig 
dquot_release_reservation_block(struct inode * inode,qsize_t nr)3985dd4056dSChristoph Hellwig static inline void dquot_release_reservation_block(struct inode *inode,
3995dd4056dSChristoph Hellwig 		qsize_t nr)
4005dd4056dSChristoph Hellwig {
40156246f9aSEric Sandeen 	__dquot_free_space(inode, nr << inode->i_blkbits, DQUOT_SPACE_RESERVE);
40203f6e92bSJan Kara }
4031da177e4SLinus Torvalds 
404d3b86324SJan Kara unsigned int qtype_enforce_flag(int type);
405d3b86324SJan Kara 
4061da177e4SLinus Torvalds #endif /* _LINUX_QUOTAOPS_ */
407