public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: remove dead assignment in prepare_one_folio()
@ 2025-11-28 17:47 Massimiliano Pellizzer
  2025-12-03 21:21 ` Boris Burkov
  0 siblings, 1 reply; 3+ messages in thread
From: Massimiliano Pellizzer @ 2025-11-28 17:47 UTC (permalink / raw)
  To: clm, dsterba; +Cc: linux-btrfs, linux-kernel, Massimiliano Pellizzer

In the error path of prepare_one_folio(), we assign ret = 0
before jumping to the again label to retry the operation.
However, ret is immediately overwritten by
ret = set_folio_extent_mapped(folio).

The zero assignment is never observerd by any code path,
therefore it can be safely removed.

No functional change.

Signed-off-by: Massimiliano Pellizzer <mpellizzer.dev@gmail.com>
---
 fs/btrfs/file.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 7a501e73d880..7d875aa261d1 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -877,7 +877,6 @@ static noinline int prepare_one_folio(struct inode *inode, struct folio **folio_
 		/* The folio is already unlocked. */
 		folio_put(folio);
 		if (!nowait && ret == -EAGAIN) {
-			ret = 0;
 			goto again;
 		}
 		return ret;
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: remove dead assignment in prepare_one_folio()
  2025-11-28 17:47 [PATCH] btrfs: remove dead assignment in prepare_one_folio() Massimiliano Pellizzer
@ 2025-12-03 21:21 ` Boris Burkov
  2025-12-04 20:51   ` Massimiliano Pellizzer
  0 siblings, 1 reply; 3+ messages in thread
From: Boris Burkov @ 2025-12-03 21:21 UTC (permalink / raw)
  To: Massimiliano Pellizzer; +Cc: clm, dsterba, linux-btrfs, linux-kernel

On Fri, Nov 28, 2025 at 05:47:55PM +0000, Massimiliano Pellizzer wrote:
> In the error path of prepare_one_folio(), we assign ret = 0
> before jumping to the again label to retry the operation.
> However, ret is immediately overwritten by
> ret = set_folio_extent_mapped(folio).
> 
> The zero assignment is never observerd by any code path,
> therefore it can be safely removed.
> 
> No functional change.

This looks fine to me. But given the fact that we are setting ret = 0
before entering the again: loop, this code is maintaining that
(unneeded) invariant. So I think we should remove both or neither.

I would lean towards removing both, but I don't feel strongly about it.

Thanks,
Boris

> 
> Signed-off-by: Massimiliano Pellizzer <mpellizzer.dev@gmail.com>
> ---
>  fs/btrfs/file.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index 7a501e73d880..7d875aa261d1 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -877,7 +877,6 @@ static noinline int prepare_one_folio(struct inode *inode, struct folio **folio_
>  		/* The folio is already unlocked. */
>  		folio_put(folio);
>  		if (!nowait && ret == -EAGAIN) {
> -			ret = 0;
>  			goto again;
>  		}
>  		return ret;
> -- 
> 2.51.0
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: remove dead assignment in prepare_one_folio()
  2025-12-03 21:21 ` Boris Burkov
@ 2025-12-04 20:51   ` Massimiliano Pellizzer
  0 siblings, 0 replies; 3+ messages in thread
From: Massimiliano Pellizzer @ 2025-12-04 20:51 UTC (permalink / raw)
  To: Boris Burkov; +Cc: clm, dsterba, linux-btrfs, linux-kernel

On Wed, Dec 3, 2025 at 10:21 PM Boris Burkov <boris@bur.io> wrote:
>
> On Fri, Nov 28, 2025 at 05:47:55PM +0000, Massimiliano Pellizzer wrote:
> > In the error path of prepare_one_folio(), we assign ret = 0
> > before jumping to the again label to retry the operation.
> > However, ret is immediately overwritten by
> > ret = set_folio_extent_mapped(folio).
> >
> > The zero assignment is never observerd by any code path,
> > therefore it can be safely removed.
> >
> > No functional change.
>
> This looks fine to me. But given the fact that we are setting ret = 0
> before entering the again: loop, this code is maintaining that
> (unneeded) invariant. So I think we should remove both or neither.
>
> I would lean towards removing both, but I don't feel strongly about it.
>
> Thanks,
> Boris
>

Hi Boris,

Good point. You are right, both assignments serve no purpose
since ret is immediately overwritten after the again label.

I'll send a v2 that removes both the initialization and the assignment
before the goto.

Thanks for the review,
Massimiliano

> >
> > Signed-off-by: Massimiliano Pellizzer <mpellizzer.dev@gmail.com>
> > ---
> >  fs/btrfs/file.c | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> > index 7a501e73d880..7d875aa261d1 100644
> > --- a/fs/btrfs/file.c
> > +++ b/fs/btrfs/file.c
> > @@ -877,7 +877,6 @@ static noinline int prepare_one_folio(struct inode *inode, struct folio **folio_
> >               /* The folio is already unlocked. */
> >               folio_put(folio);
> >               if (!nowait && ret == -EAGAIN) {
> > -                     ret = 0;
> >                       goto again;
> >               }
> >               return ret;
> > --
> > 2.51.0
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-04 20:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-28 17:47 [PATCH] btrfs: remove dead assignment in prepare_one_folio() Massimiliano Pellizzer
2025-12-03 21:21 ` Boris Burkov
2025-12-04 20:51   ` Massimiliano Pellizzer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox