• Hongbo Li's avatar
    bcachefs: fix trans->mem realloc in __bch2_trans_kmalloc · 36f9ef10
    Hongbo Li authored
    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>
    36f9ef10
btree_iter.c 86.1 KB