Skip to content
Commit 36f9ef10 authored by Hongbo Li's avatar Hongbo Li Committed by Kent Overstreet
Browse files

bcachefs: fix trans->mem realloc in __bch2_trans_kmalloc



The old code doesn't consider the mem alloced from mempool when call
krealloc on trans->mem. Also in bch2_trans_put, using mempool_free to
free trans->mem by condition "trans->mem_bytes == BTREE_TRANS_MEM_MAX"
is inaccurate when trans->mem was allocated by krealloc function.
Instead, we use used_mempool stuff to record the situation, and realloc
or free the trans->mem in elegant way.

Also, after krealloc failed in __bch2_trans_kmalloc, the old data
should be copied to the new buffer when alloc from mempool_alloc.

Fixes: 31403dca ("bcachefs: optimize __bch2_trans_get(), kill DEBUG_TRANSACTIONS")
Signed-off-by: default avatarHongbo Li <lihongbo22@huawei.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 57339b24
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