xref: /openbmc/linux/fs/gfs2/quota.h (revision 0a7ab79c)
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;
15f2f7ba52SSteven Whitehouse 
16cd915493SSteven Whitehouse #define NO_QUOTA_CHANGE ((u32)-1)
17b3b94faaSDavid Teigland 
189ac1b4d9SSteven Whitehouse extern int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid);
199ac1b4d9SSteven Whitehouse extern void gfs2_quota_unhold(struct gfs2_inode *ip);
20b3b94faaSDavid Teigland 
219ac1b4d9SSteven Whitehouse extern int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid);
229ac1b4d9SSteven Whitehouse extern void gfs2_quota_unlock(struct gfs2_inode *ip);
23b3b94faaSDavid Teigland 
249ac1b4d9SSteven Whitehouse extern int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid);
259ac1b4d9SSteven Whitehouse extern void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
26cd915493SSteven Whitehouse 			      u32 uid, u32 gid);
27b3b94faaSDavid Teigland 
289ac1b4d9SSteven Whitehouse extern int gfs2_quota_sync(struct gfs2_sbd *sdp);
299ac1b4d9SSteven Whitehouse extern int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id);
30b3b94faaSDavid Teigland 
319ac1b4d9SSteven Whitehouse extern int gfs2_quota_init(struct gfs2_sbd *sdp);
329ac1b4d9SSteven Whitehouse extern void gfs2_quota_cleanup(struct gfs2_sbd *sdp);
339ac1b4d9SSteven Whitehouse extern int gfs2_quotad(void *data);
34b3b94faaSDavid Teigland 
35d82661d9SSteven Whitehouse static inline int gfs2_quota_lock_check(struct gfs2_inode *ip)
36d82661d9SSteven Whitehouse {
37d82661d9SSteven Whitehouse 	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
38d82661d9SSteven Whitehouse 	int ret;
39d82661d9SSteven Whitehouse 	if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
40d82661d9SSteven Whitehouse 		return 0;
41d82661d9SSteven Whitehouse 	ret = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
42d82661d9SSteven Whitehouse 	if (ret)
43d82661d9SSteven Whitehouse 		return ret;
44d82661d9SSteven Whitehouse 	if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
45d82661d9SSteven Whitehouse 		return 0;
46d82661d9SSteven Whitehouse 	ret = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
47d82661d9SSteven Whitehouse 	if (ret)
48d82661d9SSteven Whitehouse 		gfs2_quota_unlock(ip);
49d82661d9SSteven Whitehouse 	return ret;
50d82661d9SSteven Whitehouse }
51d82661d9SSteven Whitehouse 
520a7ab79cSAbhijith Das extern int gfs2_shrink_qd_memory(int nr, gfp_t gfp_mask);
530a7ab79cSAbhijith Das 
54b3b94faaSDavid Teigland #endif /* __QUOTA_DOT_H__ */
55