btrfs: send: propagate errors from is_inode_existent()
PATCH 1/1 btrfs: send: propagate errors from is_inode_existent()
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.
--- fs/btrfs/send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/send.c +1 -1
@@ -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
Signature · 1 line
2.43.0
Quoted 26 lines · Avi Weiss
The direct-return refactor in commit
b3047a42f55d("btrfs: send:
directly return fromwill_overwrite_ref()and simplify it") changedwill_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 fromwill_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 <[email protected]>--- fs/btrfs/send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/send.c +0
-0
fs/btrfs/send.c static int will_overwrite_ref(struct send_ctx *sctx, u64 dir, u64 dir_gen, · line 2069
Quoted 5 lines
fs/btrfs/send.c +1
-1@@ -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?
Quoted 5 lines
fs/btrfs/send.c +0
-0/* * If we have a parent root we need to verify that the parent dir was base-commit:
af5534fe2fbc006e83d75d6283dfc5ec75d5d780
Quoted 10 lines · Avi Weiss
The direct-return refactor in commit
b3047a42f55d("btrfs: send:
directly return fromwill_overwrite_ref()and simplify it") changedwill_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.
Quoted 8 lines
process_recorded_refs()expects negative errors fromwill_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 <[email protected]>
Looks good, thanks.
Quoted 23 lines
--- fs/btrfs/send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/send.c +1
-1@@ -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
Quoted 18 lines · Filipe Manana
Quoted 16 lines · Avi Weiss
The direct-return refactor in commit
b3047a42f55d("btrfs: send:
directly return fromwill_overwrite_ref()and simplify it") changedwill_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 fromwill_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.
Quoted 6 lines
Quoted 2 lines
Fixes b3047a42f55d ("btrfs: send: directly return from will_overwrite_ref() and simplify it")Signed-off-by Avi Weiss <[email protected]>Reviewed-by Filipe Manana <[email protected]>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.
Quoted 24 lines
Quoted 24 lines
--- fs/btrfs/send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/send.c +1
-1@@ -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