^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #ifndef __QUOTA_DOT_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define __QUOTA_DOT_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/list_lru.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct gfs2_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) struct gfs2_sbd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define NO_UID_QUOTA_CHANGE INVALID_UID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define NO_GID_QUOTA_CHANGE INVALID_GID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) extern int gfs2_qa_get(struct gfs2_inode *ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) extern void gfs2_qa_put(struct gfs2_inode *ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) extern int gfs2_quota_hold(struct gfs2_inode *ip, kuid_t uid, kgid_t gid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) extern void gfs2_quota_unhold(struct gfs2_inode *ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) extern int gfs2_quota_lock(struct gfs2_inode *ip, kuid_t uid, kgid_t gid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) extern void gfs2_quota_unlock(struct gfs2_inode *ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) extern int gfs2_quota_check(struct gfs2_inode *ip, kuid_t uid, kgid_t gid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct gfs2_alloc_parms *ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) extern void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) kuid_t uid, kgid_t gid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) extern int gfs2_quota_sync(struct super_block *sb, int type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) extern int gfs2_quota_refresh(struct gfs2_sbd *sdp, struct kqid qid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) extern int gfs2_quota_init(struct gfs2_sbd *sdp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) extern void gfs2_quota_cleanup(struct gfs2_sbd *sdp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) extern int gfs2_quotad(void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) extern void gfs2_wake_up_statfs(struct gfs2_sbd *sdp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static inline int gfs2_quota_lock_check(struct gfs2_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct gfs2_alloc_parms *ap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) ap->allowed = UINT_MAX; /* Assume we are permitted a whole lot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) if (capable(CAP_SYS_RESOURCE) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) ret = gfs2_quota_lock(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) ret = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid, ap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) gfs2_quota_unlock(ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) extern const struct quotactl_ops gfs2_quotactl_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) extern struct shrinker gfs2_qd_shrinker;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) extern struct list_lru gfs2_qd_lru;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) extern void __init gfs2_quota_hash_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #endif /* __QUOTA_DOT_H__ */