Commit 2ecc6171 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix double counting when gc is running

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 39fbc5a4
...@@ -1088,8 +1088,7 @@ static void bch2_btree_set_root_inmem(struct btree_update *as, struct btree *b) ...@@ -1088,8 +1088,7 @@ static void bch2_btree_set_root_inmem(struct btree_update *as, struct btree *b)
bch2_btree_node_free_index(as, NULL, bch2_btree_node_free_index(as, NULL,
bkey_i_to_s_c(&old->key), bkey_i_to_s_c(&old->key),
fs_usage); fs_usage);
bch2_fs_usage_apply(c, fs_usage, &as->reserve->disk_res, bch2_fs_usage_apply(c, fs_usage, &as->reserve->disk_res);
gc_pos_btree_root(b->btree_id));
preempt_enable(); preempt_enable();
percpu_up_read(&c->mark_lock); percpu_up_read(&c->mark_lock);
...@@ -1192,8 +1191,7 @@ static void bch2_insert_fixup_btree_ptr(struct btree_update *as, struct btree *b ...@@ -1192,8 +1191,7 @@ static void bch2_insert_fixup_btree_ptr(struct btree_update *as, struct btree *b
bkey_disassemble(b, k, &tmp), bkey_disassemble(b, k, &tmp),
fs_usage); fs_usage);
bch2_fs_usage_apply(c, fs_usage, &as->reserve->disk_res, bch2_fs_usage_apply(c, fs_usage, &as->reserve->disk_res);
gc_pos_btree_node(b));
preempt_enable(); preempt_enable();
percpu_up_read(&c->mark_lock); percpu_up_read(&c->mark_lock);
...@@ -1993,8 +1991,7 @@ static void __bch2_btree_node_update_key(struct bch_fs *c, ...@@ -1993,8 +1991,7 @@ static void __bch2_btree_node_update_key(struct bch_fs *c,
bch2_btree_node_free_index(as, NULL, bch2_btree_node_free_index(as, NULL,
bkey_i_to_s_c(&b->key), bkey_i_to_s_c(&b->key),
fs_usage); fs_usage);
bch2_fs_usage_apply(c, fs_usage, &as->reserve->disk_res, bch2_fs_usage_apply(c, fs_usage, &as->reserve->disk_res);
gc_pos_btree_root(b->btree_id));
percpu_up_read(&c->mark_lock); percpu_up_read(&c->mark_lock);
mutex_unlock(&c->btree_interior_update_lock); mutex_unlock(&c->btree_interior_update_lock);
......
...@@ -255,8 +255,7 @@ static bool bucket_became_unavailable(struct bucket_mark old, ...@@ -255,8 +255,7 @@ static bool bucket_became_unavailable(struct bucket_mark old,
int bch2_fs_usage_apply(struct bch_fs *c, int bch2_fs_usage_apply(struct bch_fs *c,
struct bch_fs_usage *fs_usage, struct bch_fs_usage *fs_usage,
struct disk_reservation *disk_res, struct disk_reservation *disk_res)
struct gc_pos gc_pos)
{ {
s64 added = fs_usage->s.data + fs_usage->s.reserved; s64 added = fs_usage->s.data + fs_usage->s.reserved;
s64 should_not_have_added; s64 should_not_have_added;
...@@ -285,13 +284,6 @@ int bch2_fs_usage_apply(struct bch_fs *c, ...@@ -285,13 +284,6 @@ int bch2_fs_usage_apply(struct bch_fs *c,
acc_u64s((u64 *) this_cpu_ptr(c->usage[0]), acc_u64s((u64 *) this_cpu_ptr(c->usage[0]),
(u64 *) fs_usage, (u64 *) fs_usage,
sizeof(*fs_usage) / sizeof(u64) + c->replicas.nr); sizeof(*fs_usage) / sizeof(u64) + c->replicas.nr);
if (gc_visited(c, gc_pos)) {
BUG_ON(!c->usage[1]);
acc_u64s((u64 *) this_cpu_ptr(c->usage[1]),
(u64 *) fs_usage,
sizeof(*fs_usage) / sizeof(u64) + c->replicas.nr);
}
preempt_enable(); preempt_enable();
return ret; return ret;
...@@ -1001,7 +993,7 @@ void bch2_mark_update(struct btree_insert *trans, ...@@ -1001,7 +993,7 @@ void bch2_mark_update(struct btree_insert *trans,
bch2_btree_node_iter_advance(&node_iter, b); bch2_btree_node_iter_advance(&node_iter, b);
} }
if (bch2_fs_usage_apply(c, fs_usage, trans->disk_res, pos) && if (bch2_fs_usage_apply(c, fs_usage, trans->disk_res) &&
!warned_disk_usage && !warned_disk_usage &&
!xchg(&warned_disk_usage, 1)) { !xchg(&warned_disk_usage, 1)) {
char buf[200]; char buf[200];
......
...@@ -260,7 +260,7 @@ int bch2_mark_key(struct bch_fs *, struct bkey_s_c, ...@@ -260,7 +260,7 @@ int bch2_mark_key(struct bch_fs *, struct bkey_s_c,
struct bch_fs_usage *, u64, unsigned); struct bch_fs_usage *, u64, unsigned);
void bch2_mark_update(struct btree_insert *, struct btree_insert_entry *); void bch2_mark_update(struct btree_insert *, struct btree_insert_entry *);
int bch2_fs_usage_apply(struct bch_fs *, struct bch_fs_usage *, int bch2_fs_usage_apply(struct bch_fs *, struct bch_fs_usage *,
struct disk_reservation *, struct gc_pos); struct disk_reservation *);
/* disk reservations: */ /* disk reservations: */
......
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