[PATCH RESEND] erofs-utils: lib: fix `last_mapped_block` in erofs_bflush()
Jingbo Xu
jefflexu at linux.alibaba.com
Fri Sep 1 15:06:48 AEST 2023
On 9/1/23 11:16 AM, Gao Xiang wrote:
> Currently, calling erofs_bflush() multiple times is broken due to
> outdated `last_mapped_block`.
>
> Fixes: 82dee4501c5a ("erofs-utils: mkfs: enable xattr name filter feature by default")
> Fixes: 185b0bcdef4b ("erofs-utils: optimize buffer allocation logic")
> Cc: Jingbo Xu <jefflexu at linux.alibaba.com>
> Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
Reviewed-by: Jingbo Xu <jefflexu at linux.alibaba.com>
> ---
> RESEND:
> - fix my mismatch svb.
>
> lib/cache.c | 26 ++++++++++++++------------
> 1 file changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/lib/cache.c b/lib/cache.c
> index d6e9b47..925054a 100644
> --- a/lib/cache.c
> +++ b/lib/cache.c
> @@ -349,6 +349,18 @@ erofs_blk_t erofs_mapbh(struct erofs_buffer_block *bb)
> return tail_blkaddr;
> }
>
> +static void erofs_bfree(struct erofs_buffer_block *bb)
> +{
> + DBG_BUGON(!list_empty(&bb->buffers.list));
> +
> + if (bb == last_mapped_block)
> + last_mapped_block = list_prev_entry(bb, list);
> +
> + list_del(&bb->mapped_list);
> + list_del(&bb->list);
> + free(bb);
> +}
> +
> bool erofs_bflush(struct erofs_buffer_block *bb)
> {
> const unsigned int blksiz = erofs_blksiz(&sbi);
> @@ -384,13 +396,8 @@ bool erofs_bflush(struct erofs_buffer_block *bb)
> dev_fillzero(&sbi, erofs_pos(&sbi, blkaddr) - padding,
> padding, true);
>
> - DBG_BUGON(!list_empty(&p->buffers.list));
> -
> erofs_dbg("block %u to %u flushed", p->blkaddr, blkaddr - 1);
> -
> - list_del(&p->mapped_list);
> - list_del(&p->list);
> - free(p);
> + erofs_bfree(p);
> }
> return true;
> }
> @@ -412,12 +419,7 @@ void erofs_bdrop(struct erofs_buffer_head *bh, bool tryrevoke)
> if (!list_empty(&bb->buffers.list))
> return;
>
> - if (bb == last_mapped_block)
> - last_mapped_block = list_prev_entry(bb, list);
> -
> - list_del(&bb->mapped_list);
> - list_del(&bb->list);
> - free(bb);
> + erofs_bfree(bb);
>
> if (rollback)
> tail_blkaddr = blkaddr;
--
Thanks,
Jingbo
More information about the Linux-erofs
mailing list