Re: [PATCH 03/27] btrfs: use async_chunk::async_cow to replace the confusing pending pointer
From: Nikolay Borisov <hidden>
Date: 2021-07-13 07:36:51
From: Nikolay Borisov <hidden>
Date: 2021-07-13 07:36:51
On 13.07.21 г. 9:14, Qu Wenruo wrote:
For structure async_chunk, we use a very strange member layout to grab structure async_cow who owns this async_chunk. At initialization, it goes like this: async_chunk[i].pending = &ctx->num_chunks; Then at async_cow_free() we do a super weird freeing: /* * Since the pointer to 'pending' is at the beginning of the array of * async_chunk's, freeing it ensures the whole array has been freed. */ if (atomic_dec_and_test(async_chunk->pending)) kvfree(async_chunk->pending); This is absolutely an abuse of kvfree(). Replace async_chunk::pending with async_chunk::async_cow, so that we can grab the async_cow structure directly, without this strange dancing. And with this change, there is no requirement for any specific member location. Signed-off-by: Qu Wenruo <redacted>
Reviewed-by: Nikolay Borisov <redacted>