Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 98DB8CA0FE1 for ; Fri, 1 Sep 2023 05:07:10 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RcQxm6Mhbz3c01 for ; Fri, 1 Sep 2023 15:07:08 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.alibaba.com (client-ip=115.124.30.131; helo=out30-131.freemail.mail.aliyun.com; envelope-from=jefflexu@linux.alibaba.com; receiver=lists.ozlabs.org) Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4RcQxd0cPjz2ym1 for ; Fri, 1 Sep 2023 15:06:59 +1000 (AEST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R731e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=2;SR=0;TI=SMTPD_---0Vr0WGWc_1693544811; Received: from 192.168.31.58(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0Vr0WGWc_1693544811) by smtp.aliyun-inc.com; Fri, 01 Sep 2023 13:06:52 +0800 Message-ID: Date: Fri, 1 Sep 2023 13:06:48 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH RESEND] erofs-utils: lib: fix `last_mapped_block` in erofs_bflush() Content-Language: en-US To: Gao Xiang , linux-erofs@lists.ozlabs.org References: <20230901031244.108189-1-hsiangkao@linux.alibaba.com> <20230901031634.115999-1-hsiangkao@linux.alibaba.com> From: Jingbo Xu In-Reply-To: <20230901031634.115999-1-hsiangkao@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" 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 > Signed-off-by: Gao Xiang Reviewed-by: Jingbo Xu > --- > 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