mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-07 17:27:11 -04:00
bcachefs: Don't add unknown accounting types to eytzinger tree
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
@@ -729,6 +729,16 @@ int bch2_accounting_read(struct bch_fs *c)
|
||||
BTREE_ITER_prefetch|BTREE_ITER_all_snapshots, k, ({
|
||||
struct bkey u;
|
||||
struct bkey_s_c k = bch2_btree_path_peek_slot_exact(btree_iter_path(trans, &iter), &u);
|
||||
|
||||
if (k.k->type != KEY_TYPE_accounting)
|
||||
continue;
|
||||
|
||||
struct disk_accounting_pos acc_k;
|
||||
bpos_to_disk_accounting_pos(&acc_k, k.k->p);
|
||||
|
||||
if (!bch2_accounting_is_mem(acc_k))
|
||||
continue;
|
||||
|
||||
accounting_read_key(trans, k);
|
||||
}));
|
||||
if (ret)
|
||||
@@ -740,6 +750,12 @@ int bch2_accounting_read(struct bch_fs *c)
|
||||
|
||||
darray_for_each(*keys, i) {
|
||||
if (i->k->k.type == KEY_TYPE_accounting) {
|
||||
struct disk_accounting_pos acc_k;
|
||||
bpos_to_disk_accounting_pos(&acc_k, i->k->k.p);
|
||||
|
||||
if (!bch2_accounting_is_mem(acc_k))
|
||||
continue;
|
||||
|
||||
struct bkey_s_c k = bkey_i_to_s_c(i->k);
|
||||
unsigned idx = eytzinger0_find(acc->k.data, acc->k.nr,
|
||||
sizeof(acc->k.data[0]),
|
||||
|
||||
@@ -114,6 +114,12 @@ enum bch_accounting_mode {
|
||||
int bch2_accounting_mem_insert(struct bch_fs *, struct bkey_s_c_accounting, enum bch_accounting_mode);
|
||||
void bch2_accounting_mem_gc(struct bch_fs *);
|
||||
|
||||
static inline bool bch2_accounting_is_mem(struct disk_accounting_pos acc)
|
||||
{
|
||||
return acc.type < BCH_DISK_ACCOUNTING_TYPE_NR &&
|
||||
acc.type != BCH_DISK_ACCOUNTING_inum;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update in memory counters so they match the btree update we're doing; called
|
||||
* from transaction commit path
|
||||
@@ -130,7 +136,7 @@ static inline int bch2_accounting_mem_mod_locked(struct btree_trans *trans,
|
||||
|
||||
EBUG_ON(gc && !acc->gc_running);
|
||||
|
||||
if (acc_k.type == BCH_DISK_ACCOUNTING_inum)
|
||||
if (!bch2_accounting_is_mem(acc_k))
|
||||
return 0;
|
||||
|
||||
if (mode == BCH_ACCOUNTING_normal) {
|
||||
|
||||
Reference in New Issue
Block a user