mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yue Hu <zbestahu@gmail.com>
To: Gao Xiang <hsiangkao@linux.alibaba.com>
Cc: linux-erofs@lists.ozlabs.org, LKML <linux-kernel@vger.kernel.org>,
	huyue2@coolpad.com, zhangwen@coolpad.com
Subject: Re: [PATCH 1/2] erofs: clean up z_erofs_extent_lookback
Date: Fri, 11 Mar 2022 15:48:16 +0800	[thread overview]
Message-ID: <20220311154816.00004d23.zbestahu@gmail.com> (raw)
In-Reply-To: <Yir8lBR2gyN1CJ8D@B-P7TQMD6M-0146.local>

On Fri, 11 Mar 2022 15:39:00 +0800
Gao Xiang <hsiangkao@linux.alibaba.com> wrote:

> On Fri, Mar 11, 2022 at 03:28:28PM +0800, Gao Xiang wrote:
> > On Fri, Mar 11, 2022 at 03:12:32PM +0800, Yue Hu wrote:  
> > > On Fri, 11 Mar 2022 02:27:42 +0800
> > > Gao Xiang <hsiangkao@linux.alibaba.com> 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 <hsiangkao@linux.alibaba.com>
> > > > ---
> > > >  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.  
> 
> Oh, I just noticed that you mean `lclusterbits', I think it won't
> change in this function, so I don't tend to move it into the inner
> loop.

Ok, looks good to me.

Reviewed-by: Yue Hu <huyue2@coolpad.com>

> 
> Thanks,
> Gao Xiang
> 
> > 
> > Thanks,
> > Gao Xiang  


  reply	other threads:[~2022-03-11  7:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10 18:27 Gao Xiang
2022-03-10 18:27 ` [PATCH 2/2] erofs: refine managed inode stuffs Gao Xiang
2022-03-15  9:09   ` Chao Yu
2022-03-11  7:12 ` [PATCH 1/2] erofs: clean up z_erofs_extent_lookback Yue Hu
2022-03-11  7:28   ` Gao Xiang
2022-03-11  7:39     ` Gao Xiang
2022-03-11  7:48       ` Yue Hu [this message]
2022-03-15  9:08 ` Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220311154816.00004d23.zbestahu@gmail.com \
    --to=zbestahu@gmail.com \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=huyue2@coolpad.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zhangwen@coolpad.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®