mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] btrfs: send: propagate errors from is_inode_existent()
@ 2026-08-10  9:47 Avi Weiss
  2026-08-11  5:26 ` Qu Wenruo
  2026-08-25 12:38 ` Filipe Manana
  0 siblings, 2 replies; 4+ messages in thread
From: Avi Weiss @ 2026-08-10  9:47 UTC (permalink / raw)
  To: David Sterba
  Cc: Chris Mason, Filipe Manana, linux-btrfs, linux-kernel, Avi Weiss

The direct-return refactor in commit b3047a42f55d ("btrfs: send:
directly return from will_overwrite_ref() and simplify it") changed
will_overwrite_ref() to return directly instead of going through the
common out label.

That resulted in a negative return value from is_inode_existent()
to start being converted to 0, making lookup errors unable to be
distinguished from the inode not existing.

process_recorded_refs() expects negative errors from
will_overwrite_ref() and aborts processing when it receives one.

Return the value from is_inode_existent() to restore the previous error
propagation behavior as it was before the refactor.

Fixes: b3047a42f55d ("btrfs: send: directly return from will_overwrite_ref() and simplify it")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
 fs/btrfs/send.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 3ae480c7474b..a888202397ed 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -2066,7 +2066,7 @@ static int will_overwrite_ref(struct send_ctx *sctx, u64 dir, u64 dir_gen,
 
 	ret = is_inode_existent(sctx, dir, dir_gen, NULL, &parent_root_dir_gen);
 	if (ret <= 0)
-		return 0;
+		return ret;
 
 	/*
 	 * If we have a parent root we need to verify that the parent dir was

base-commit: af5534fe2fbc006e83d75d6283dfc5ec75d5d780
-- 
2.43.0


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

* Re: [PATCH] btrfs: send: propagate errors from is_inode_existent()
  2026-08-10  9:47 [PATCH] btrfs: send: propagate errors from is_inode_existent() Avi Weiss
@ 2026-08-11  5:26 ` Qu Wenruo
  2026-08-25 12:38 ` Filipe Manana
  1 sibling, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2026-08-11  5:26 UTC (permalink / raw)
  To: Avi Weiss, David Sterba
  Cc: Chris Mason, Filipe Manana, linux-btrfs, linux-kernel



在 2026/8/10 19:17, Avi Weiss 写道:
> The direct-return refactor in commit b3047a42f55d ("btrfs: send:
> directly return from will_overwrite_ref() and simplify it") changed
> will_overwrite_ref() to return directly instead of going through the
> common out label.
> 
> That resulted in a negative return value from is_inode_existent()
> to start being converted to 0, making lookup errors unable to be
> distinguished from the inode not existing.
> 
> process_recorded_refs() expects negative errors from
> will_overwrite_ref() and aborts processing when it receives one.
> 
> Return the value from is_inode_existent() to restore the previous error
> propagation behavior as it was before the refactor.
> 
> Fixes: b3047a42f55d ("btrfs: send: directly return from will_overwrite_ref() and simplify it")
> Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
> ---
>   fs/btrfs/send.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index 3ae480c7474b..a888202397ed 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -2066,7 +2066,7 @@ static int will_overwrite_ref(struct send_ctx *sctx, u64 dir, u64 dir_gen,
>   
>   	ret = is_inode_existent(sctx, dir, dir_gen, NULL, &parent_root_dir_gen);
>   	if (ret <= 0)
> -		return 0;
> +		return ret;

This behavior seems consistent with the later lookup_dir_item_inode(), 
where if we got ENOENT we just return 0.

Are you sure if we want to return -ENOENT in this case?
>   
>   	/*
>   	 * If we have a parent root we need to verify that the parent dir was
> 
> base-commit: af5534fe2fbc006e83d75d6283dfc5ec75d5d780


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

* Re: [PATCH] btrfs: send: propagate errors from is_inode_existent()
  2026-08-10  9:47 [PATCH] btrfs: send: propagate errors from is_inode_existent() Avi Weiss
  2026-08-11  5:26 ` Qu Wenruo
@ 2026-08-25 12:38 ` Filipe Manana
  2026-08-25 12:43   ` Filipe Manana
  1 sibling, 1 reply; 4+ messages in thread
From: Filipe Manana @ 2026-08-25 12:38 UTC (permalink / raw)
  To: Avi Weiss
  Cc: David Sterba, Chris Mason, Filipe Manana, linux-btrfs, linux-kernel

On Mon, Aug 10, 2026 at 10:52 AM Avi Weiss <thnkslprpt@gmail.com> wrote:
>
> The direct-return refactor in commit b3047a42f55d ("btrfs: send:
> directly return from will_overwrite_ref() and simplify it") changed
> will_overwrite_ref() to return directly instead of going through the
> common out label.
>
> That resulted in a negative return value from is_inode_existent()
> to start being converted to 0, making lookup errors unable to be
> distinguished from the inode not existing.
>
> process_recorded_refs() expects negative errors from
> will_overwrite_ref() and aborts processing when it receives one.
>
> Return the value from is_inode_existent() to restore the previous error
> propagation behavior as it was before the refactor.
>
> Fixes: b3047a42f55d ("btrfs: send: directly return from will_overwrite_ref() and simplify it")
> Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>

Reviewed-by: Filipe Manana <fdmanana@suse.com>

Looks good, thanks.

> ---
>  fs/btrfs/send.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index 3ae480c7474b..a888202397ed 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -2066,7 +2066,7 @@ static int will_overwrite_ref(struct send_ctx *sctx, u64 dir, u64 dir_gen,
>
>         ret = is_inode_existent(sctx, dir, dir_gen, NULL, &parent_root_dir_gen);
>         if (ret <= 0)
> -               return 0;
> +               return ret;
>
>         /*
>          * If we have a parent root we need to verify that the parent dir was
>
> base-commit: af5534fe2fbc006e83d75d6283dfc5ec75d5d780
> --
> 2.43.0
>
>

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

* Re: [PATCH] btrfs: send: propagate errors from is_inode_existent()
  2026-08-25 12:38 ` Filipe Manana
@ 2026-08-25 12:43   ` Filipe Manana
  0 siblings, 0 replies; 4+ messages in thread
From: Filipe Manana @ 2026-08-25 12:43 UTC (permalink / raw)
  To: Avi Weiss
  Cc: David Sterba, Chris Mason, Filipe Manana, linux-btrfs, linux-kernel

On Tue, Aug 25, 2026 at 1:38 PM Filipe Manana <fdmanana@kernel.org> wrote:
>
> On Mon, Aug 10, 2026 at 10:52 AM Avi Weiss <thnkslprpt@gmail.com> wrote:
> >
> > The direct-return refactor in commit b3047a42f55d ("btrfs: send:
> > directly return from will_overwrite_ref() and simplify it") changed
> > will_overwrite_ref() to return directly instead of going through the
> > common out label.
> >
> > That resulted in a negative return value from is_inode_existent()
> > to start being converted to 0, making lookup errors unable to be
> > distinguished from the inode not existing.
> >
> > process_recorded_refs() expects negative errors from
> > will_overwrite_ref() and aborts processing when it receives one.
> >
> > Return the value from is_inode_existent() to restore the previous error
> > propagation behavior as it was before the refactor.
> >
> > Fixes: b3047a42f55d ("btrfs: send: directly return from will_overwrite_ref() and simplify it")
> > Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
>
> Reviewed-by: Filipe Manana <fdmanana@suse.com>
>
> Looks good, thanks.

I changed the subject to be less confusing, as the change is about a
specific caller of is_inode_existent():

btrfs: send: fix lost error return value in will_overwrite_ref()

And I pushed it to the for-next github branch.

>
> > ---
> >  fs/btrfs/send.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> > index 3ae480c7474b..a888202397ed 100644
> > --- a/fs/btrfs/send.c
> > +++ b/fs/btrfs/send.c
> > @@ -2066,7 +2066,7 @@ static int will_overwrite_ref(struct send_ctx *sctx, u64 dir, u64 dir_gen,
> >
> >         ret = is_inode_existent(sctx, dir, dir_gen, NULL, &parent_root_dir_gen);
> >         if (ret <= 0)
> > -               return 0;
> > +               return ret;
> >
> >         /*
> >          * If we have a parent root we need to verify that the parent dir was
> >
> > base-commit: af5534fe2fbc006e83d75d6283dfc5ec75d5d780
> > --
> > 2.43.0
> >
> >

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

end of thread, other threads:[~2026-08-25 12:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-10  9:47 [PATCH] btrfs: send: propagate errors from is_inode_existent() Avi Weiss
2026-08-11  5:26 ` Qu Wenruo
2026-08-25 12:38 ` Filipe Manana
2026-08-25 12:43   ` Filipe Manana

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

all inboxes | Powered by JetHome®