* [PATCH] erofs: clean up a loop
@ 2022-07-18 11:20 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2022-07-18 11:20 UTC (permalink / raw)
To: Gao Xiang; +Cc: Chao Yu, Yue Hu, Jeffle Xu, linux-erofs, kernel-janitors
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--) {
+ if (!cmpxchg(&pcl->compressed_bvecs[fe->icur].page,
NULL, bvec->page)) {
pcl->compressed_bvecs[fe->icur] = *bvec;
return true;
--
2.35.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH] erofs: clean up a loop
@ 2022-07-18 11:20 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2022-07-18 11:20 UTC (permalink / raw)
To: Gao Xiang; +Cc: kernel-janitors, linux-erofs, Yue Hu
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--) {
+ if (!cmpxchg(&pcl->compressed_bvecs[fe->icur].page,
NULL, bvec->page)) {
pcl->compressed_bvecs[fe->icur] = *bvec;
return true;
--
2.35.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] erofs: clean up a loop
2022-07-18 11:20 ` Dan Carpenter
@ 2022-07-18 11:36 ` Gao Xiang
-1 siblings, 0 replies; 6+ messages in thread
From: Gao Xiang @ 2022-07-18 11:36 UTC (permalink / raw)
To: Dan Carpenter
Cc: Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu, linux-erofs,
kernel-janitors
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...
Thanks,
Gao Xiang
> + if (!cmpxchg(&pcl->compressed_bvecs[fe->icur].page,
> NULL, bvec->page)) {
> pcl->compressed_bvecs[fe->icur] = *bvec;
> return true;
> --
> 2.35.1
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] erofs: clean up a loop
@ 2022-07-18 11:36 ` Gao Xiang
0 siblings, 0 replies; 6+ messages in thread
From: Gao Xiang @ 2022-07-18 11:36 UTC (permalink / raw)
To: Dan Carpenter; +Cc: kernel-janitors, Yue Hu, linux-erofs
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...
Thanks,
Gao Xiang
> + if (!cmpxchg(&pcl->compressed_bvecs[fe->icur].page,
> NULL, bvec->page)) {
> pcl->compressed_bvecs[fe->icur] = *bvec;
> return true;
> --
> 2.35.1
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] erofs: clean up a loop
2022-07-18 11:36 ` Gao Xiang
@ 2022-07-18 12:23 ` Dan Carpenter
-1 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2022-07-18 12:23 UTC (permalink / raw)
To: Gao Xiang
Cc: Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu, linux-erofs,
kernel-janitors
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
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] erofs: clean up a loop
@ 2022-07-18 12:23 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2022-07-18 12:23 UTC (permalink / raw)
To: Gao Xiang; +Cc: kernel-janitors, Yue Hu, linux-erofs
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-07-18 12:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2022-07-18 12:23 ` Dan Carpenter
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.