[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yir8lBR2gyN1CJ8D@B-P7TQMD6M-0146.local>
Date: Fri, 11 Mar 2022 15:39:00 +0800
From: Gao Xiang <hsiangkao@...ux.alibaba.com>
To: Yue Hu <zbestahu@...il.com>
Cc: linux-erofs@...ts.ozlabs.org, LKML <linux-kernel@...r.kernel.org>,
huyue2@...lpad.com, zhangwen@...lpad.com
Subject: Re: [PATCH 1/2] erofs: clean up z_erofs_extent_lookback
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@...ux.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@...ux.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.
Thanks,
Gao Xiang
>
> Thanks,
> Gao Xiang
Powered by blists - more mailing lists