From: Dan Carpenter <dan.carpenter@oracle.com>
To: Gao Xiang <hsiangkao@linux.alibaba.com>
Cc: Gao Xiang <xiang@kernel.org>, Chao Yu <chao@kernel.org>,
Yue Hu <huyue2@coolpad.com>,
Jeffle Xu <jefflexu@linux.alibaba.com>,
linux-erofs@lists.ozlabs.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] erofs: clean up a loop
Date: Mon, 18 Jul 2022 15:23:13 +0300 [thread overview]
Message-ID: <20220718122313.GX2316@kadam> (raw)
In-Reply-To: <YtVFrpFdaR2Iwf2x@B-P7TQMD6M-0146.local>
On Mon, Jul 18, 2022 at 07:36:14PM +0800, Gao Xiang wrote:
> Hi Dan,
>
> On Mon, Jul 18, 2022 at 02:20:08PM +0300, Dan Carpenter wrote:
> > It's easier to see what this loop is doing when the decrement is in
> > the normal place.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > fs/erofs/zdata.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
> > index 601cfcb07c50..2691100eb231 100644
> > --- a/fs/erofs/zdata.c
> > +++ b/fs/erofs/zdata.c
> > @@ -419,8 +419,8 @@ static bool z_erofs_try_inplace_io(struct z_erofs_decompress_frontend *fe,
> > {
> > struct z_erofs_pcluster *const pcl = fe->pcl;
> >
> > - while (fe->icur > 0) {
> > - if (!cmpxchg(&pcl->compressed_bvecs[--fe->icur].page,
> > + while (fe->icur--) {
>
> Thanks for your patch!
> Yet at a quick glance, on my side, that doesn't equal
> to be honest...
>
> .. What we're trying to do here is to find a free slot
> for inplace i/o, but also need to leave fe->icur as 0
> when going out the loop since z_erofs_try_inplace_io()
> can be called again the next time when attaching
> another page but it will overflow then...
Ah. Sorry. I never thought about it being called twice in a row.
regards,
dan carpenter
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Gao Xiang <hsiangkao@linux.alibaba.com>
Cc: kernel-janitors@vger.kernel.org, Yue Hu <huyue2@coolpad.com>,
linux-erofs@lists.ozlabs.org
Subject: Re: [PATCH] erofs: clean up a loop
Date: Mon, 18 Jul 2022 15:23:13 +0300 [thread overview]
Message-ID: <20220718122313.GX2316@kadam> (raw)
In-Reply-To: <YtVFrpFdaR2Iwf2x@B-P7TQMD6M-0146.local>
On Mon, Jul 18, 2022 at 07:36:14PM +0800, Gao Xiang wrote:
> Hi Dan,
>
> On Mon, Jul 18, 2022 at 02:20:08PM +0300, Dan Carpenter wrote:
> > It's easier to see what this loop is doing when the decrement is in
> > the normal place.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > fs/erofs/zdata.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
> > index 601cfcb07c50..2691100eb231 100644
> > --- a/fs/erofs/zdata.c
> > +++ b/fs/erofs/zdata.c
> > @@ -419,8 +419,8 @@ static bool z_erofs_try_inplace_io(struct z_erofs_decompress_frontend *fe,
> > {
> > struct z_erofs_pcluster *const pcl = fe->pcl;
> >
> > - while (fe->icur > 0) {
> > - if (!cmpxchg(&pcl->compressed_bvecs[--fe->icur].page,
> > + while (fe->icur--) {
>
> Thanks for your patch!
> Yet at a quick glance, on my side, that doesn't equal
> to be honest...
>
> .. What we're trying to do here is to find a free slot
> for inplace i/o, but also need to leave fe->icur as 0
> when going out the loop since z_erofs_try_inplace_io()
> can be called again the next time when attaching
> another page but it will overflow then...
Ah. Sorry. I never thought about it being called twice in a row.
regards,
dan carpenter
next prev parent reply other threads:[~2022-07-18 12:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-18 11:20 [PATCH] erofs: clean up a loop Dan Carpenter
2022-07-18 11:20 ` Dan Carpenter
2022-07-18 11:36 ` Gao Xiang
2022-07-18 11:36 ` Gao Xiang
2022-07-18 12:23 ` Dan Carpenter [this message]
2022-07-18 12:23 ` Dan Carpenter
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=20220718122313.GX2316@kadam \
--to=dan.carpenter@oracle.com \
--cc=chao@kernel.org \
--cc=hsiangkao@linux.alibaba.com \
--cc=huyue2@coolpad.com \
--cc=jefflexu@linux.alibaba.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=xiang@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.