btrfs-progs: Preserve first error in loop of check_extent_refs()
PATCH 1/1 btrfs-progs: Preserve first error in loop of check_extent_refs()
Previously, the err variable inside the loop was updated with cur_err on every iteration, regardless of whether cur_err indicated an error. This caused a bug where an earlier error could be overwritten by a later successful iteration, losing the original failure.
This fix ensures that err retains the first encountered error and is not reset by subsequent successful iterations.
--- check/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
check/main.c +2 -1
@@ -8322,7 +8322,8 @@ static int check_extent_refs(struct btrfs_root *root, cur_err =1 ; } next: - err = cur_err; +if (cur_err) + err = cur_err;remove_cache_extent (extent_cache, cache);free_all_extent_backrefs (rec);if (!init_extent_tree && opt_check_repair && (!cur_err || fix))
Signature · 1 line
2.34.1
Quoted 7 lines · tchou
Previously, the
errvariable inside the loop was updated withcur_erron every iteration, regardless of whethercur_errindicated an error. This caused a bug where an earlier error could be overwritten by a later successful iteration, losing the original failure.This fix ensures that
errretains the first encountered error and is not reset by subsequent successful iterations.
SoB line please, otherwise looks good to me.
And if it's a case you hit in real world, mind to extract or craft a minimal image as a test case?
Thanks,
Qu
Quoted 18 lines
--- check/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)check/main.c +2
-1@@ -8322,7 +8322,8 @@ static int check_extent_refs(struct btrfs_root *root, cur_err =1 ; } next: - err = cur_err; +if (cur_err) + err = cur_err;remove_cache_extent (extent_cache, cache);free_all_extent_backrefs (rec);if (!init_extent_tree && opt_check_repair && (!cur_err || fix))
Quoted 10 lines · Qu Wenruo
Quoted 7 lines · tchou
Previously, the
errvariable inside the loop was updated withcur_erron every iteration, regardless of whethercur_errindicated an error. This caused a bug where an earlier error could be overwritten by a later successful iteration, losing the original failure.This fix ensures that
errretains the first encountered error and is not reset by subsequent successful iterations.SoB line please, otherwise looks good to me.
For btrfs-progs teh SoB line is optional, I think it's mentioned in the README. It makes sense for kernel to insist on the attribution and some trace to real people but btrfs-progs are much smaller and I think it's better to lower the contribution barriers.
Quoted 1 line
Reviewed-by Qu Wenruo <[email protected]>
Thanks, feel free to add the commit to devel.
Quoted 2 lines
And if it's a case you hit in real world, mind to extract or craft a minimal image as a test case?
From my experience, casual contributors will rarely write tests and I do not do that when I'm sending a fix or reporting a problem to other projects. In order to keep the track of that it may be best to open an issue, unless you or me will write the test case.
David Sterba 於 2025/2/13 07:29 寫道:
Quoted 10 lines · Qu Wenruo
Quoted 9 lines · tchou
Quoted 7 lines
Previously, the
errvariable inside the loop was updated withcur_erron every iteration, regardless of whethercur_errindicated an error. This caused a bug where an earlier error could be overwritten by a later successful iteration, losing the original failure.This fix ensures that
errretains the first encountered error and is not reset by subsequent successful iterations.
Quoted 6 lines
Quoted 1 line
SoB line please, otherwise looks good to me.
For btrfs-progs teh SoB line is optional, I think it's mentioned in the README. It makes sense for kernel to insist on the attribution and some trace to real people but btrfs-progs are much smaller and I think it's better to lower the contribution barriers.
Thanks, I will add it next time send patch.
Quoted 5 lines
Quoted 2 lines
Reviewed-by Qu Wenruo <[email protected]>Thanks, feel free to add the commit to devel.
Do I need to send PR in github of btrfs-progs, or maintainer will add the commit directly?
Quoted 7 lines
Quoted 2 lines
And if it's a case you hit in real world, mind to extract or craft a minimal image as a test case?
From my experience, casual contributors will rarely write tests and I do
not do that when I'm sending a fix or reporting a problem to other projects. In order to keep the track of that it may be best to open an issue, unless you or me will write the test case.
Not the real case, but fake case by modifying the bytenr of extent to wrong number when test the correctness of function we develop with backref check. I think every backpointer mismatch case can test it.
Thanks, TCHou
Quoted 21 lines · tchou
David Sterba 於 2025/2/13 07:29 寫道:
Quoted 10 lines · Qu Wenruo
Quoted 9 lines · tchou
Quoted 7 lines
Previously, the
errvariable inside the loop was updated withcur_erron every iteration, regardless of whethercur_errindicated an error. This caused a bug where an earlier error could be overwritten by a later successful iteration, losing the original failure.This fix ensures that
errretains the first encountered error and is not reset by subsequent successful iterations.Quoted 6 lines
Quoted 1 line
SoB line please, otherwise looks good to me.
For btrfs-progs teh SoB line is optional, I think it's mentioned in the README. It makes sense for kernel to insist on the attribution and some trace to real people but btrfs-progs are much smaller and I think it's better to lower the contribution barriers.
Thanks, I will add it next time send patch.
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Reviewed-by Qu Wenruo <[email protected]>Thanks, feel free to add the commit to devel.
Do I need to send PR in github of btrfs-progs, or maintainer will add the commit directly?
No worry, feel free to use either/both mail or github pull request.
We can handle both at merge time.
(In fact, I send mail for personal accounting, and github PR for real merge)
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
And if it's a case you hit in real world, mind to extract or craft a minimal image as a test case?
Quoted 8 lines
Quoted 4 lines
From my experience, casual contributors will rarely write tests and I do not do that when I'm sending a fix or reporting a problem to other projects. In order to keep the track of that it may be best to open an issue, unless you or me will write the test case.
Not the real case, but fake case by modifying the bytenr of extent to wrong number when test the correctness of function we develop with backref check. I think every backpointer mismatch case can test it.
Thanks, let me try to craft a minimal image with this method.
Thanks,
Qu
Quoted 3 lines
Thanks, TCHou