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 void bch2_quota_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
12 #define bch2_bkey_ops_quota (struct bkey_ops) { \
13 .key_invalid = bch2_quota_invalid, \
14 .val_to_text = bch2_quota_to_text, \
17 static inline struct bch_qid bch_qid(struct bch_inode_unpacked *u)
19 return (struct bch_qid) {
20 .q[QTYP_USR] = u->bi_uid,
21 .q[QTYP_GRP] = u->bi_gid,
22 .q[QTYP_PRJ] = u->bi_project,
26 static inline unsigned enabled_qtypes(struct bch_fs *c)
28 return ((c->opts.usrquota << QTYP_USR)|
29 (c->opts.grpquota << QTYP_GRP)|
30 (c->opts.prjquota << QTYP_PRJ));
33 #ifdef CONFIG_BCACHEFS_QUOTA
35 int bch2_quota_acct(struct bch_fs *, struct bch_qid, enum quota_counters,
36 s64, enum quota_acct_mode);
38 int bch2_quota_transfer(struct bch_fs *, unsigned, struct bch_qid,
39 struct bch_qid, u64, enum quota_acct_mode);
41 void bch2_fs_quota_exit(struct bch_fs *);
42 void bch2_fs_quota_init(struct bch_fs *);
43 int bch2_fs_quota_read(struct bch_fs *);
45 extern const struct quotactl_ops bch2_quotactl_operations;
49 static inline int bch2_quota_acct(struct bch_fs *c, struct bch_qid qid,
50 enum quota_counters counter, s64 v,
51 enum quota_acct_mode mode)
56 static inline int bch2_quota_transfer(struct bch_fs *c, unsigned qtypes,
58 struct bch_qid src, u64 space)
63 static inline void bch2_fs_quota_exit(struct bch_fs *c) {}
64 static inline void bch2_fs_quota_init(struct bch_fs *c) {}
65 static inline int bch2_fs_quota_read(struct bch_fs *c) { return 0; }
69 #endif /* _BCACHEFS_QUOTA_H */