]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/quota.h
Update bcachefs sources to e99d29e402 bcachefs: zstd support, compression refactoring
[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 static inline unsigned enabled_qtypes(struct bch_fs *c)
24 {
25         return ((c->opts.usrquota << QTYP_USR)|
26                 (c->opts.grpquota << QTYP_GRP)|
27                 (c->opts.prjquota << QTYP_PRJ));
28 }
29
30 #ifdef CONFIG_BCACHEFS_QUOTA
31
32 int bch2_quota_acct(struct bch_fs *, struct bch_qid, enum quota_counters,
33                     s64, enum quota_acct_mode);
34
35 int bch2_quota_transfer(struct bch_fs *, unsigned, struct bch_qid,
36                         struct bch_qid, u64);
37
38 void bch2_fs_quota_exit(struct bch_fs *);
39 void bch2_fs_quota_init(struct bch_fs *);
40 int bch2_fs_quota_read(struct bch_fs *);
41
42 extern const struct quotactl_ops bch2_quotactl_operations;
43
44 #else
45
46 static inline int bch2_quota_acct(struct bch_fs *c, struct bch_qid qid,
47                                   enum quota_counters counter, s64 v,
48                                   enum quota_acct_mode mode)
49 {
50         return 0;
51 }
52
53 static inline int bch2_quota_transfer(struct bch_fs *c, unsigned qtypes,
54                                       struct bch_qid dst,
55                                       struct bch_qid src, u64 space)
56 {
57         return 0;
58 }
59
60 static inline void bch2_fs_quota_exit(struct bch_fs *c) {}
61 static inline void bch2_fs_quota_init(struct bch_fs *c) {}
62 static inline int bch2_fs_quota_read(struct bch_fs *c) { return 0; }
63
64 #endif
65
66 #endif /* _BCACHEFS_QUOTA_H */