1 #ifndef _BCACHEFS_QUOTA_H
2 #define _BCACHEFS_QUOTA_H
5 #include "quota_types.h"
7 extern const struct bch_sb_field_ops bch_sb_field_ops_quota;
9 const char *bch2_quota_invalid(const struct bch_fs *, struct bkey_s_c);
10 int bch2_quota_to_text(struct bch_fs *, char *, size_t, struct bkey_s_c);
12 #define bch2_bkey_quota_ops (struct bkey_ops) { \
13 .key_invalid = bch2_quota_invalid, \
14 .val_to_text = bch2_quota_to_text, \
17 enum quota_acct_mode {
23 static inline struct bch_qid bch_qid(struct bch_inode_unpacked *u)
25 return (struct bch_qid) {
26 .q[QTYP_USR] = u->bi_uid,
27 .q[QTYP_GRP] = u->bi_gid,
28 .q[QTYP_PRJ] = u->bi_project,
32 static inline unsigned enabled_qtypes(struct bch_fs *c)
34 return ((c->opts.usrquota << QTYP_USR)|
35 (c->opts.grpquota << QTYP_GRP)|
36 (c->opts.prjquota << QTYP_PRJ));
39 #ifdef CONFIG_BCACHEFS_QUOTA
41 int bch2_quota_acct(struct bch_fs *, struct bch_qid, enum quota_counters,
42 s64, enum quota_acct_mode);
44 int bch2_quota_transfer(struct bch_fs *, unsigned, struct bch_qid,
47 void bch2_fs_quota_exit(struct bch_fs *);
48 void bch2_fs_quota_init(struct bch_fs *);
49 int bch2_fs_quota_read(struct bch_fs *);
51 extern const struct quotactl_ops bch2_quotactl_operations;
55 static inline int bch2_quota_acct(struct bch_fs *c, struct bch_qid qid,
56 enum quota_counters counter, s64 v,
57 enum quota_acct_mode mode)
62 static inline int bch2_quota_transfer(struct bch_fs *c, unsigned qtypes,
64 struct bch_qid src, u64 space)
69 static inline void bch2_fs_quota_exit(struct bch_fs *c) {}
70 static inline void bch2_fs_quota_init(struct bch_fs *c) {}
71 static inline int bch2_fs_quota_read(struct bch_fs *c) { return 0; }
75 #endif /* _BCACHEFS_QUOTA_H */