summaryrefslogtreecommitdiff
path: root/fs/bcachefs/quota.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs/quota.c')
-rw-r--r--fs/bcachefs/quota.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/fs/bcachefs/quota.c b/fs/bcachefs/quota.c
index 95ff0caea199..3a6a00e15c77 100644
--- a/fs/bcachefs/quota.c
+++ b/fs/bcachefs/quota.c
@@ -217,17 +217,19 @@ static int bch2_quota_check_limit(struct bch_fs *c,
return 0;
}
-int bch2_quota_acct(struct bch_fs *c, struct bch_qid qid,
- enum quota_counters counter, s64 v,
- enum quota_acct_mode mode)
+int __bch2_quota_acct(struct bch_fs *c, unsigned qtypes,
+ struct bch_qid qid,
+ enum quota_counters counter, s64 v,
+ enum quota_acct_mode mode)
{
- unsigned qtypes = enabled_qtypes(c);
struct bch_memquota_type *q;
struct bch_memquota *mq[QTYP_NR];
struct quota_msgs msgs;
unsigned i;
int ret = 0;
+ qtypes &= enabled_qtypes(c);
+
memset(&msgs, 0, sizeof(msgs));
for_each_set_qtype(c, i, q, qtypes)
@@ -256,6 +258,13 @@ err:
return ret;
}
+int bch2_quota_acct(struct bch_fs *c, struct bch_qid qid,
+ enum quota_counters counter, s64 v,
+ enum quota_acct_mode mode)
+{
+ return __bch2_quota_acct(c, ~0, qid, counter, v, mode);
+}
+
static void __bch2_quota_transfer(struct bch_memquota *src_q,
struct bch_memquota *dst_q,
enum quota_counters counter, s64 v)
@@ -269,7 +278,8 @@ static void __bch2_quota_transfer(struct bch_memquota *src_q,
int bch2_quota_transfer(struct bch_fs *c, unsigned qtypes,
struct bch_qid dst,
- struct bch_qid src, u64 space)
+ struct bch_qid src, u64 space,
+ enum quota_acct_mode mode)
{
struct bch_memquota_type *q;
struct bch_memquota *src_q[3], *dst_q[3];
@@ -295,13 +305,13 @@ int bch2_quota_transfer(struct bch_fs *c, unsigned qtypes,
ret = bch2_quota_check_limit(c, i, dst_q[i], &msgs, Q_SPC,
dst_q[i]->c[Q_SPC].v + space,
- KEY_TYPE_QUOTA_PREALLOC);
+ mode);
if (ret)
goto err;
ret = bch2_quota_check_limit(c, i, dst_q[i], &msgs, Q_INO,
dst_q[i]->c[Q_INO].v + 1,
- KEY_TYPE_QUOTA_PREALLOC);
+ mode);
if (ret)
goto err;
}