xref: /openbmc/linux/fs/gfs2/quota.h (revision 7336d0e6)
17336d0e6SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2b3b94faaSDavid Teigland /*
3b3b94faaSDavid Teigland  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
43a8a9a10SSteven Whitehouse  * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
5b3b94faaSDavid Teigland  */
6b3b94faaSDavid Teigland 
7b3b94faaSDavid Teigland #ifndef __QUOTA_DOT_H__
8b3b94faaSDavid Teigland #define __QUOTA_DOT_H__
9b3b94faaSDavid Teigland 
102147dbfdSSteven Whitehouse #include <linux/list_lru.h>
112147dbfdSSteven Whitehouse 
12f2f7ba52SSteven Whitehouse struct gfs2_inode;
13f2f7ba52SSteven Whitehouse struct gfs2_sbd;
14f2f7ba52SSteven Whitehouse 
15f4108a60SEric W. Biederman #define NO_UID_QUOTA_CHANGE INVALID_UID
16f4108a60SEric W. Biederman #define NO_GID_QUOTA_CHANGE INVALID_GID
17b3b94faaSDavid Teigland 
18b54e9a0bSBob Peterson extern int gfs2_qa_alloc(struct gfs2_inode *ip);
19a097dc7eSBob Peterson extern void gfs2_qa_delete(struct gfs2_inode *ip, atomic_t *wcount);
207c06b5d6SEric W. Biederman extern int gfs2_quota_hold(struct gfs2_inode *ip, kuid_t uid, kgid_t gid);
219ac1b4d9SSteven Whitehouse extern void gfs2_quota_unhold(struct gfs2_inode *ip);
22b3b94faaSDavid Teigland 
237c06b5d6SEric W. Biederman extern int gfs2_quota_lock(struct gfs2_inode *ip, kuid_t uid, kgid_t gid);
249ac1b4d9SSteven Whitehouse extern void gfs2_quota_unlock(struct gfs2_inode *ip);
25b3b94faaSDavid Teigland 
26b8fbf471SAbhi Das extern int gfs2_quota_check(struct gfs2_inode *ip, kuid_t uid, kgid_t gid,
27b8fbf471SAbhi Das 			    struct gfs2_alloc_parms *ap);
289ac1b4d9SSteven Whitehouse extern void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
297c06b5d6SEric W. Biederman 			      kuid_t uid, kgid_t gid);
30b3b94faaSDavid Teigland 
31ceed1723SJan Kara extern int gfs2_quota_sync(struct super_block *sb, int type);
32ed87dabcSEric W. Biederman extern int gfs2_quota_refresh(struct gfs2_sbd *sdp, struct kqid qid);
33b3b94faaSDavid Teigland 
349ac1b4d9SSteven Whitehouse extern int gfs2_quota_init(struct gfs2_sbd *sdp);
359ac1b4d9SSteven Whitehouse extern void gfs2_quota_cleanup(struct gfs2_sbd *sdp);
369ac1b4d9SSteven Whitehouse extern int gfs2_quotad(void *data);
37b3b94faaSDavid Teigland 
383d3c10f2SBenjamin Marzinski extern void gfs2_wake_up_statfs(struct gfs2_sbd *sdp);
393d3c10f2SBenjamin Marzinski 
40b8fbf471SAbhi Das static inline int gfs2_quota_lock_check(struct gfs2_inode *ip,
41b8fbf471SAbhi Das 					struct gfs2_alloc_parms *ap)
42d82661d9SSteven Whitehouse {
43d82661d9SSteven Whitehouse 	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
44d82661d9SSteven Whitehouse 	int ret;
45174d1232SAndreas Gruenbacher 
46174d1232SAndreas Gruenbacher 	ap->allowed = UINT_MAX; /* Assume we are permitted a whole lot */
47d82661d9SSteven Whitehouse 	if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
48d82661d9SSteven Whitehouse 		return 0;
49f4108a60SEric W. Biederman 	ret = gfs2_quota_lock(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE);
50d82661d9SSteven Whitehouse 	if (ret)
51d82661d9SSteven Whitehouse 		return ret;
52d82661d9SSteven Whitehouse 	if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
53d82661d9SSteven Whitehouse 		return 0;
54b8fbf471SAbhi Das 	ret = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid, ap);
55d82661d9SSteven Whitehouse 	if (ret)
56d82661d9SSteven Whitehouse 		gfs2_quota_unlock(ip);
57d82661d9SSteven Whitehouse 	return ret;
58d82661d9SSteven Whitehouse }
59d82661d9SSteven Whitehouse 
60cc632e7fSSteven Whitehouse extern const struct quotactl_ops gfs2_quotactl_ops;
612147dbfdSSteven Whitehouse extern struct shrinker gfs2_qd_shrinker;
622147dbfdSSteven Whitehouse extern struct list_lru gfs2_qd_lru;
63c754fbbbSSteven Whitehouse extern void __init gfs2_quota_hash_init(void);
640a7ab79cSAbhijith Das 
65b3b94faaSDavid Teigland #endif /* __QUOTA_DOT_H__ */
66