Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp757581pxp; Fri, 11 Mar 2022 14:19:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBUlaCZ3CPpMx8jZeMa3XwenqsJg5ZYMWHmTv4eT6zdQUF0eTjEgwVq9oNxamyYP4rJsB/ X-Received: by 2002:a63:6b81:0:b0:380:4fc1:ee7b with SMTP id g123-20020a636b81000000b003804fc1ee7bmr10409055pgc.298.1647037172891; Fri, 11 Mar 2022 14:19:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647037172; cv=none; d=google.com; s=arc-20160816; b=aPfd6cijH7ONinsxkRl4ZzAOzsAY2Buo3kcqvCmk24tR8344J0QEvpZz2h4V8JgGd0 JtcyJtOycCmPo5n4cevL2k/bTXgqZYRLgvhJApTYLVBjoAnbMNN6OMuOod+2yMPR/2gP hP7rt2ocZhbxJh4xXl3QvcUHDWQyg7GEBEq97Rvht8E+Yaq97pIQLqaB0Fp3/o2Q9KHW iUriOGkyU4ialw9mnPLcSmmmyYy2eYIzIdIsOs4qRdxjmosuhPe94RZLMmfSiFDsYnDa PexcUKl8SaNP2DTTLo5p/+C44q6tbH4p4L+Gmym/vR3s7eGaJa0BTjIqraRg54l+okg4 K90g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=ONI9/1zdr8/DE6C2lmkZITx9rLcA+MiCL//lYEbfVhA=; b=Czk6S5ZZAo5aWKT7zFytrSqnXYx0omKVvNusFnRUlpj9DUB5I230ufPUCR1ZEoyfF8 cfvCbFvak+y/1dS3Cu8V+gksiR13d+OJmEsbZV+rKKsfS29nfAmJycJGpR6aBOBxgTsp l0wmy/umdBuN6xEQJikvaMAY4zJfkCfHSVtL2KOjq32EEVRq3zPR6IjOfcguESoQ8/JW 1Rr3XnNE9wwYqJREuUH6KLzrGuLbGoB+r6CD1KfgLsYp05l4FjA2F1ryju9/cSFaJTog tr7EgFLcHHihCyu5dc5dwEgfVeJBRmBFA7PVD+2wMUJ812m3NpbG5Nf3etzHOFW3Ut1r 1W5A== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n15-20020a170903110f00b00151f3eea1aasi10497354plh.550.2022.03.11.14.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 14:19:32 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5890D239325; Fri, 11 Mar 2022 13:28:48 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241914AbiCKH3h (ORCPT + 99 others); Fri, 11 Mar 2022 02:29:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230505AbiCKH3g (ORCPT ); Fri, 11 Mar 2022 02:29:36 -0500 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E950B1B6E1F for ; Thu, 10 Mar 2022 23:28:33 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0V6t3gLV_1646983708; Received: from B-P7TQMD6M-0146.local(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0V6t3gLV_1646983708) by smtp.aliyun-inc.com(127.0.0.1); Fri, 11 Mar 2022 15:28:30 +0800 Date: Fri, 11 Mar 2022 15:28:28 +0800 From: Gao Xiang To: Yue Hu Cc: linux-erofs@lists.ozlabs.org, Chao Yu , LKML , zhangwen@coolpad.com, huyue2@coolpad.com Subject: Re: [PATCH 1/2] erofs: clean up z_erofs_extent_lookback Message-ID: References: <20220310182743.102365-1-hsiangkao@linux.alibaba.com> <20220311151232.00003619.zbestahu@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220311151232.00003619.zbestahu@gmail.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 11, 2022 at 03:12:32PM +0800, Yue Hu wrote: > On Fri, 11 Mar 2022 02:27:42 +0800 > Gao Xiang wrote: > > > Avoid the unnecessary tail recursion since it can be converted into > > a loop directly in order to prevent potential stack overflow. > > > > It's a pretty straightforward conversion. > > > > Signed-off-by: Gao Xiang > > --- > > fs/erofs/zmap.c | 67 ++++++++++++++++++++++++------------------------- > > 1 file changed, 33 insertions(+), 34 deletions(-) > > > > diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c > > index b4059b9c3bac..572f0b8151ba 100644 > > --- a/fs/erofs/zmap.c > > +++ b/fs/erofs/zmap.c > > @@ -431,48 +431,47 @@ static int z_erofs_extent_lookback(struct z_erofs_maprecorder *m, > > unsigned int lookback_distance) > > { > > struct erofs_inode *const vi = EROFS_I(m->inode); > > - struct erofs_map_blocks *const map = m->map; > > const unsigned int lclusterbits = vi->z_logical_clusterbits; > > - unsigned long lcn = m->lcn; > > - int err; > > > > - if (lcn < lookback_distance) { > > - erofs_err(m->inode->i_sb, > > - "bogus lookback distance @ nid %llu", vi->nid); > > - DBG_BUGON(1); > > - return -EFSCORRUPTED; > > - } > > + while (m->lcn >= lookback_distance) { > > + unsigned long lcn = m->lcn - lookback_distance; > > + int err; > > may better to declare variable 'lclusterbits' in loop just like 'err' usage? I'm fine with either way. Ok, will post the next version later. Thanks, Gao Xiang