xref: /openbmc/linux/fs/gfs2/quota.h (revision f4108a60)
1b3b94faaSDavid Teigland /*
2b3b94faaSDavid Teigland  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
33a8a9a10SSteven Whitehouse  * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
4b3b94faaSDavid Teigland  *
5b3b94faaSDavid Teigland  * This copyrighted material is made available to anyone wishing to use,
6b3b94faaSDavid Teigland  * modify, copy, or redistribute it subject to the terms and conditions
7e9fc2aa0SSteven Whitehouse  * of the GNU General Public License version 2.
8b3b94faaSDavid Teigland  */
9b3b94faaSDavid Teigland 
10b3b94faaSDavid Teigland #ifndef __QUOTA_DOT_H__
11b3b94faaSDavid Teigland #define __QUOTA_DOT_H__
12b3b94faaSDavid Teigland 
13f2f7ba52SSteven Whitehouse struct gfs2_inode;
14f2f7ba52SSteven Whitehouse struct gfs2_sbd;
151495f230SYing Han struct shrink_control;
16f2f7ba52SSteven Whitehouse 
17f4108a60SEric W. Biederman #define NO_UID_QUOTA_CHANGE INVALID_UID
18f4108a60SEric W. Biederman #define NO_GID_QUOTA_CHANGE INVALID_GID
19b3b94faaSDavid Teigland 
209ac1b4d9SSteven Whitehouse extern int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid);
219ac1b4d9SSteven Whitehouse extern void gfs2_quota_unhold(struct gfs2_inode *ip);
22b3b94faaSDavid Teigland 
239ac1b4d9SSteven Whitehouse extern int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid);
249ac1b4d9SSteven Whitehouse extern void gfs2_quota_unlock(struct gfs2_inode *ip);
25b3b94faaSDavid Teigland 
269ac1b4d9SSteven Whitehouse extern int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid);
279ac1b4d9SSteven Whitehouse extern void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
28cd915493SSteven Whitehouse 			      u32 uid, u32 gid);
29b3b94faaSDavid Teigland 
30ceed1723SJan Kara extern int gfs2_quota_sync(struct super_block *sb, int type);
319ac1b4d9SSteven Whitehouse extern int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id);
32b3b94faaSDavid Teigland 
339ac1b4d9SSteven Whitehouse extern int gfs2_quota_init(struct gfs2_sbd *sdp);
349ac1b4d9SSteven Whitehouse extern void gfs2_quota_cleanup(struct gfs2_sbd *sdp);
359ac1b4d9SSteven Whitehouse extern int gfs2_quotad(void *data);
36b3b94faaSDavid Teigland 
373d3c10f2SBenjamin Marzinski extern void gfs2_wake_up_statfs(struct gfs2_sbd *sdp);
383d3c10f2SBenjamin Marzinski 
39d82661d9SSteven Whitehouse static inline int gfs2_quota_lock_check(struct gfs2_inode *ip)
40d82661d9SSteven Whitehouse {
41d82661d9SSteven Whitehouse 	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
42d82661d9SSteven Whitehouse 	int ret;
43d82661d9SSteven Whitehouse 	if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
44d82661d9SSteven Whitehouse 		return 0;
45f4108a60SEric W. Biederman 	ret = gfs2_quota_lock(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE);
46d82661d9SSteven Whitehouse 	if (ret)
47d82661d9SSteven Whitehouse 		return ret;
48d82661d9SSteven Whitehouse 	if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
49d82661d9SSteven Whitehouse 		return 0;
50d82661d9SSteven Whitehouse 	ret = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
51d82661d9SSteven Whitehouse 	if (ret)
52d82661d9SSteven Whitehouse 		gfs2_quota_unlock(ip);
53d82661d9SSteven Whitehouse 	return ret;
54d82661d9SSteven Whitehouse }
55d82661d9SSteven Whitehouse 
561495f230SYing Han extern int gfs2_shrink_qd_memory(struct shrinker *shrink,
571495f230SYing Han 				 struct shrink_control *sc);
58cc632e7fSSteven Whitehouse extern const struct quotactl_ops gfs2_quotactl_ops;
590a7ab79cSAbhijith Das 
60b3b94faaSDavid Teigland #endif /* __QUOTA_DOT_H__ */
61