]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/quota.h
b5536be94ed407620c61c4911c23b79c34a963cb
[bcachefs-tools-debian] / libbcachefs / quota.h
1 #ifndef _BCACHEFS_QUOTA_H
2 #define _BCACHEFS_QUOTA_H
3
4 #include "quota_types.h"
5
6 extern const struct bkey_ops bch2_bkey_quota_ops;
7
8 enum quota_acct_mode {
9         BCH_QUOTA_PREALLOC,
10         BCH_QUOTA_WARN,
11         BCH_QUOTA_NOCHECK,
12 };
13
14 static inline struct bch_qid bch_qid(struct bch_inode_unpacked *u)
15 {
16         return (struct bch_qid) {
17                 .q[QTYP_USR] = u->bi_uid,
18                 .q[QTYP_GRP] = u->bi_gid,
19                 .q[QTYP_PRJ] = u->bi_project,
20         };
21 }
22
23 #ifdef CONFIG_BCACHEFS_QUOTA
24
25 int bch2_quota_acct(struct bch_fs *, struct bch_qid, enum quota_counters,
26                     s64, enum quota_acct_mode);
27
28 int bch2_quota_transfer(struct bch_fs *, unsigned, struct bch_qid,
29                         struct bch_qid, u64);
30
31 void bch2_fs_quota_exit(struct bch_fs *);
32 void bch2_fs_quota_init(struct bch_fs *);
33 int bch2_fs_quota_read(struct bch_fs *);
34
35 extern const struct quotactl_ops bch2_quotactl_operations;
36
37 #else
38
39 static inline int bch2_quota_acct(struct bch_fs *c, struct bch_qid qid,
40                                   enum quota_counters counter, s64 v,
41                                   enum quota_acct_mode mode)
42 {
43         return 0;
44 }
45
46 static inline int bch2_quota_transfer(struct bch_fs *c, unsigned qtypes,
47                                       struct bch_qid dst,
48                                       struct bch_qid src, u64 space)
49 {
50         return 0;
51 }
52
53 static inline void bch2_fs_quota_exit(struct bch_fs *c) {}
54 static inline void bch2_fs_quota_init(struct bch_fs *c) {}
55 static inline int bch2_fs_quota_read(struct bch_fs *c) { return 0; }
56
57 #endif
58
59 #endif /* _BCACHEFS_QUOTA_H */