Commit 77d63522 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Make replicas_delta_list smaller

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent fbc519ab
...@@ -587,9 +587,11 @@ static inline int do_btree_insert_at(struct btree_trans *trans, ...@@ -587,9 +587,11 @@ static inline int do_btree_insert_at(struct btree_trans *trans,
bch2_journal_res_put(&c->journal, &trans->journal_res); bch2_journal_res_put(&c->journal, &trans->journal_res);
out_clear_replicas: out_clear_replicas:
if (trans->fs_usage_deltas) { if (trans->fs_usage_deltas) {
memset(&trans->fs_usage_deltas->fs_usage, 0,
sizeof(trans->fs_usage_deltas->fs_usage));
trans->fs_usage_deltas->used = 0; trans->fs_usage_deltas->used = 0;
memset((void *) trans->fs_usage_deltas +
offsetof(struct replicas_delta_list, memset_start), 0,
(void *) &trans->fs_usage_deltas->memset_end -
(void *) &trans->fs_usage_deltas->memset_start);
} }
return ret; return ret;
......
...@@ -585,9 +585,14 @@ void bch2_replicas_delta_list_apply(struct bch_fs *c, ...@@ -585,9 +585,14 @@ void bch2_replicas_delta_list_apply(struct bch_fs *c,
{ {
struct replicas_delta *d = r->d; struct replicas_delta *d = r->d;
struct replicas_delta *top = (void *) r->d + r->used; struct replicas_delta *top = (void *) r->d + r->used;
unsigned i;
fs_usage->nr_inodes += r->nr_inodes;
acc_u64s((u64 *) fs_usage, for (i = 0; i < BCH_REPLICAS_MAX; i++) {
(u64 *) &r->fs_usage, sizeof(*fs_usage) / sizeof(u64)); fs_usage->reserved += r->persistent_reserved[i];
fs_usage->persistent_reserved[i] += r->persistent_reserved[i];
}
while (d != top) { while (d != top) {
BUG_ON((void *) d > (void *) top); BUG_ON((void *) d > (void *) top);
...@@ -1739,9 +1744,9 @@ int bch2_trans_mark_key(struct btree_trans *trans, struct bkey_s_c k, ...@@ -1739,9 +1744,9 @@ int bch2_trans_mark_key(struct btree_trans *trans, struct bkey_s_c k,
d = replicas_deltas_realloc(trans, 0); d = replicas_deltas_realloc(trans, 0);
if (!(flags & BCH_BUCKET_MARK_OVERWRITE)) if (!(flags & BCH_BUCKET_MARK_OVERWRITE))
d->fs_usage.nr_inodes++; d->nr_inodes++;
else else
d->fs_usage.nr_inodes--; d->nr_inodes--;
return 0; return 0;
case KEY_TYPE_reservation: { case KEY_TYPE_reservation: {
unsigned replicas = bkey_s_c_to_reservation(k).v->nr_replicas; unsigned replicas = bkey_s_c_to_reservation(k).v->nr_replicas;
...@@ -1750,10 +1755,9 @@ int bch2_trans_mark_key(struct btree_trans *trans, struct bkey_s_c k, ...@@ -1750,10 +1755,9 @@ int bch2_trans_mark_key(struct btree_trans *trans, struct bkey_s_c k,
sectors *= replicas; sectors *= replicas;
replicas = clamp_t(unsigned, replicas, 1, replicas = clamp_t(unsigned, replicas, 1,
ARRAY_SIZE(d->fs_usage.persistent_reserved)); ARRAY_SIZE(d->persistent_reserved));
d->fs_usage.reserved += sectors; d->persistent_reserved[replicas - 1] += sectors;
d->fs_usage.persistent_reserved[replicas - 1] += sectors;
return 0; return 0;
} }
case KEY_TYPE_reflink_p: case KEY_TYPE_reflink_p:
......
...@@ -100,7 +100,11 @@ struct replicas_delta { ...@@ -100,7 +100,11 @@ struct replicas_delta {
struct replicas_delta_list { struct replicas_delta_list {
unsigned size; unsigned size;
unsigned used; unsigned used;
struct bch_fs_usage fs_usage;
struct {} memset_start;
u64 nr_inodes;
u64 persistent_reserved[BCH_REPLICAS_MAX];
struct {} memset_end;
struct replicas_delta d[0]; struct replicas_delta d[0];
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment