From: Gao Xiang <xiang@kernel.org>
To: Jingbo Xu <jefflexu@linux.alibaba.com>
Cc: hsiangkao@linux.alibaba.com, linux-erofs@lists.ozlabs.org,
huyue2@coolpad.com
Subject: Re: [PATCH v2] erofs-utils: lib: fix erofs_iterate_dir() recursion
Date: Sat, 22 Jul 2023 15:49:53 +0800 [thread overview]
Message-ID: <ZLuKIaKQZ2AYBL12@debian> (raw)
In-Reply-To: <3de999b5-b8b8-6229-5041-99046e9a0e1a@linux.alibaba.com>
On Sat, Jul 22, 2023 at 03:04:23PM +0800, Jingbo Xu wrote:
>
>
> On 7/22/23 2:20 PM, Gao Xiang wrote:
> > Hi Jingbo,
> >
> > On Sat, Jul 22, 2023 at 01:40:09PM +0800, Jingbo Xu wrote:
> >> ctx->dir may have changed when ctx is reused along erofs_iterate_dir()
> >> recursion.
> >>
> >> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
> >> ---
> >> changes since last version:
> >> since traverse_dirents() can be called multiple times in one single
> >> erofs_iterate_dir() call, ctx->dir may have changed at the entry of
> >> traverse_dirents(). The previous v1 shall be deprecated.
> >>
> >> v1: https://lore.kernel.org/all/20230718052101.124039-3-jefflexu@linux.alibaba.com/
> >
> > I plan to drop this commit directly. `struct erofs_dir_context` is not
> > designed for reusing recursively. It's not the case just due to
> > `ctx->dir` but also internal states.
> >
> > You need to build another ctx for recursion.
>
> It seems that ctx is reused to avoid stack overflow. So we have to
> allocate ctx on heap to avoid stack overflow?
It'd be better to use heap space for allocation in principle (even
avoid recursion), but I think it's just some userspace code and
stack space to enough in general.
Thanks,
Gao Xiang
>
> --
> Thanks,
> Jingbo
prev parent reply other threads:[~2023-07-22 7:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-22 5:40 [PATCH v2] erofs-utils: lib: fix erofs_iterate_dir() recursion Jingbo Xu
2023-07-22 6:20 ` Gao Xiang
2023-07-22 7:04 ` Jingbo Xu
2023-07-22 7:49 ` Gao Xiang [this message]
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=ZLuKIaKQZ2AYBL12@debian \
--to=xiang@kernel.org \
--cc=hsiangkao@linux.alibaba.com \
--cc=huyue2@coolpad.com \
--cc=jefflexu@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
/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