* [PATCH 0/2] xfs: fix CoW fork repair error handling
@ 2026-05-26 12:32 Yingjie Gao
2026-05-26 12:32 ` [PATCH 1/2] xfs: fix error returns in CoW fork repair Yingjie Gao
` (3 more replies)
0 siblings, 4 replies; 17+ messages in thread
From: Yingjie Gao @ 2026-05-26 12:32 UTC (permalink / raw)
To: linux-xfs; +Cc: cem, djwong, linux-kernel, Yingjie Gao
Hi all,
This series fixes two error handling bugs in the CoW fork repair code.
The non-realtime helper can lose real failures in two different ways:
it returns success after the common cleanup labels, and the
force-rebuild path can return directly without freeing the AG repair
context.
The realtime helper has a related cleanup bug in its force-rebuild
path. If marking the full mapping fails, the code jumps past the
rtgroup scrub cleanup and only drops the local rtgroup reference.
Split the fixes into two patches so that the non-RT and RT changes
remain easy to review and bisect independently.
Patches in this series:
1. fix non-RT CoW fork repair error returns and cleanup
2. fix RT CoW fork repair cleanup
Thanks,
Yingjie
Yingjie Gao (2):
xfs: fix error returns in CoW fork repair
xfs: fix rtgroup cleanup in CoW fork repair
fs/xfs/scrub/cow_repair.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 1/2] xfs: fix error returns in CoW fork repair
2026-05-26 12:32 [PATCH 0/2] xfs: fix CoW fork repair error handling Yingjie Gao
@ 2026-05-26 12:32 ` Yingjie Gao
2026-05-26 14:52 ` Carlos Maiolino
2026-05-26 12:32 ` [PATCH 2/2] xfs: fix rtgroup cleanup " Yingjie Gao
` (2 subsequent siblings)
3 siblings, 1 reply; 17+ messages in thread
From: Yingjie Gao @ 2026-05-26 12:32 UTC (permalink / raw)
To: linux-xfs; +Cc: cem, djwong, linux-kernel, Yingjie Gao
The non-realtime CoW fork repair scan returns success after the
common cleanup labels, even if the AG setup, btree queries, or bitmap
updates failed. This can make online repair continue with an
incomplete bad-file-offset bitmap instead of stopping at the original
error.
The force-rebuild path has the opposite cleanup problem: if marking
the entire mapping fails, it returns directly and skips the scrub AG
context and perag reference cleanup.
Send force-rebuild failures through the existing cleanup label and
return the saved error from the function. Successful scans still
return zero.
Fixes: dbbdbd008632 ("xfs: repair problems in CoW forks")
Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
---
fs/xfs/scrub/cow_repair.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
index bffc4666ce60..bc3838bac71a 100644
--- a/fs/xfs/scrub/cow_repair.c
+++ b/fs/xfs/scrub/cow_repair.c
@@ -304,14 +304,14 @@ xrep_cow_find_bad(
error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
xc->irec.br_blockcount);
if (error)
- return error;
+ goto out_sa;
}
out_sa:
xchk_ag_free(sc, &sc->sa);
out_pag:
xfs_perag_put(pag);
- return 0;
+ return error;
}
/*
--
2.20.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 2/2] xfs: fix rtgroup cleanup in CoW fork repair
2026-05-26 12:32 [PATCH 0/2] xfs: fix CoW fork repair error handling Yingjie Gao
2026-05-26 12:32 ` [PATCH 1/2] xfs: fix error returns in CoW fork repair Yingjie Gao
@ 2026-05-26 12:32 ` Yingjie Gao
2026-05-26 14:53 ` Carlos Maiolino
2026-05-26 14:51 ` [PATCH 0/2] xfs: fix CoW fork repair error handling Carlos Maiolino
2026-05-27 3:39 ` [PATCH v2 " Yingjie Gao
3 siblings, 1 reply; 17+ messages in thread
From: Yingjie Gao @ 2026-05-26 12:32 UTC (permalink / raw)
To: linux-xfs; +Cc: cem, djwong, linux-kernel, Yingjie Gao
The realtime CoW fork repair scan initializes scrub rtgroup state
before it checks whether the whole mapping should be rebuilt. That
state includes realtime btree cursors, rtgroup locks, and an extra
sr->rtg reference.
If marking the full mapping fails in the force-rebuild path, the code
jumps directly to out_rtg. That only drops the local rtgroup reference
and skips the scrub rtgroup cleanup, leaving the cursors, lock, and
sr->rtg reference behind.
Jump to out_sr instead so this error path matches the other failures
after xrep_rtgroup_init().
Fixes: fd97fe111208 ("xfs: fix CoW forks for realtime files")
Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
---
fs/xfs/scrub/cow_repair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
index bc3838bac71a..bff25cf74e29 100644
--- a/fs/xfs/scrub/cow_repair.c
+++ b/fs/xfs/scrub/cow_repair.c
@@ -389,7 +389,7 @@ xrep_cow_find_bad_rt(
error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
xc->irec.br_blockcount);
if (error)
- goto out_rtg;
+ goto out_sr;
}
out_sr:
--
2.20.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 0/2] xfs: fix CoW fork repair error handling
2026-05-26 12:32 [PATCH 0/2] xfs: fix CoW fork repair error handling Yingjie Gao
2026-05-26 12:32 ` [PATCH 1/2] xfs: fix error returns in CoW fork repair Yingjie Gao
2026-05-26 12:32 ` [PATCH 2/2] xfs: fix rtgroup cleanup " Yingjie Gao
@ 2026-05-26 14:51 ` Carlos Maiolino
2026-05-27 3:38 ` Yingjie Gao
2026-05-27 3:39 ` [PATCH v2 " Yingjie Gao
3 siblings, 1 reply; 17+ messages in thread
From: Carlos Maiolino @ 2026-05-26 14:51 UTC (permalink / raw)
To: Yingjie Gao; +Cc: linux-xfs, djwong, linux-kernel
On Tue, May 26, 2026 at 08:32:41PM +0800, Yingjie Gao wrote:
> Hi all,
>
> This series fixes two error handling bugs in the CoW fork repair code.
>
> The non-realtime helper can lose real failures in two different ways:
> it returns success after the common cleanup labels, and the
> force-rebuild path can return directly without freeing the AG repair
> context.
>
> The realtime helper has a related cleanup bug in its force-rebuild
> path. If marking the full mapping fails, the code jumps past the
> rtgroup scrub cleanup and only drops the local rtgroup reference.
>
> Split the fixes into two patches so that the non-RT and RT changes
> remain easy to review and bisect independently.
>
> Patches in this series:
> 1. fix non-RT CoW fork repair error returns and cleanup
> 2. fix RT CoW fork repair cleanup
Was this generated by any LLM model?
>
> Thanks,
> Yingjie
>
> Yingjie Gao (2):
> xfs: fix error returns in CoW fork repair
> xfs: fix rtgroup cleanup in CoW fork repair
>
> fs/xfs/scrub/cow_repair.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/2] xfs: fix error returns in CoW fork repair
2026-05-26 12:32 ` [PATCH 1/2] xfs: fix error returns in CoW fork repair Yingjie Gao
@ 2026-05-26 14:52 ` Carlos Maiolino
0 siblings, 0 replies; 17+ messages in thread
From: Carlos Maiolino @ 2026-05-26 14:52 UTC (permalink / raw)
To: Yingjie Gao; +Cc: linux-xfs, djwong, linux-kernel
On Tue, May 26, 2026 at 08:32:42PM +0800, Yingjie Gao wrote:
> The non-realtime CoW fork repair scan returns success after the
> common cleanup labels, even if the AG setup, btree queries, or bitmap
> updates failed. This can make online repair continue with an
> incomplete bad-file-offset bitmap instead of stopping at the original
> error.
>
> The force-rebuild path has the opposite cleanup problem: if marking
> the entire mapping fails, it returns directly and skips the scrub AG
> context and perag reference cleanup.
>
> Send force-rebuild failures through the existing cleanup label and
> return the saved error from the function. Successful scans still
> return zero.
>
> Fixes: dbbdbd008632 ("xfs: repair problems in CoW forks")
> Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
> ---
> fs/xfs/scrub/cow_repair.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
> index bffc4666ce60..bc3838bac71a 100644
> --- a/fs/xfs/scrub/cow_repair.c
> +++ b/fs/xfs/scrub/cow_repair.c
> @@ -304,14 +304,14 @@ xrep_cow_find_bad(
> error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
> xc->irec.br_blockcount);
> if (error)
> - return error;
> + goto out_sa;
> }
The goto here is pointless as it jumps to the very next line, it could
simply let the code fall through.
>
> out_sa:
> xchk_ag_free(sc, &sc->sa);
> out_pag:
> xfs_perag_put(pag);
> - return 0;
> + return error;
> }
>
> /*
> --
> 2.20.1
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 2/2] xfs: fix rtgroup cleanup in CoW fork repair
2026-05-26 12:32 ` [PATCH 2/2] xfs: fix rtgroup cleanup " Yingjie Gao
@ 2026-05-26 14:53 ` Carlos Maiolino
0 siblings, 0 replies; 17+ messages in thread
From: Carlos Maiolino @ 2026-05-26 14:53 UTC (permalink / raw)
To: Yingjie Gao; +Cc: linux-xfs, djwong, linux-kernel
On Tue, May 26, 2026 at 08:32:43PM +0800, Yingjie Gao wrote:
> The realtime CoW fork repair scan initializes scrub rtgroup state
> before it checks whether the whole mapping should be rebuilt. That
> state includes realtime btree cursors, rtgroup locks, and an extra
> sr->rtg reference.
>
> If marking the full mapping fails in the force-rebuild path, the code
> jumps directly to out_rtg. That only drops the local rtgroup reference
> and skips the scrub rtgroup cleanup, leaving the cursors, lock, and
> sr->rtg reference behind.
>
> Jump to out_sr instead so this error path matches the other failures
> after xrep_rtgroup_init().
>
> Fixes: fd97fe111208 ("xfs: fix CoW forks for realtime files")
> Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
> ---
> fs/xfs/scrub/cow_repair.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
> index bc3838bac71a..bff25cf74e29 100644
> --- a/fs/xfs/scrub/cow_repair.c
> +++ b/fs/xfs/scrub/cow_repair.c
> @@ -389,7 +389,7 @@ xrep_cow_find_bad_rt(
> error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
> xc->irec.br_blockcount);
> if (error)
> - goto out_rtg;
> + goto out_sr;
Ditto for this patch.
> }
>
> out_sr:
> --
> 2.20.1
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0/2] xfs: fix CoW fork repair error handling
2026-05-26 14:51 ` [PATCH 0/2] xfs: fix CoW fork repair error handling Carlos Maiolino
@ 2026-05-27 3:38 ` Yingjie Gao
0 siblings, 0 replies; 17+ messages in thread
From: Yingjie Gao @ 2026-05-27 3:38 UTC (permalink / raw)
To: cem; +Cc: djwong, linux-kernel, linux-xfs, Yingjie Gao
Hi Carlos,
Yes, I used LLM assistance for the cover letter wording.
I've prepared a v2 with the cleanup changes you pointed out.
Thanks,
Yingjie
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 0/2] xfs: fix CoW fork repair error handling
2026-05-26 12:32 [PATCH 0/2] xfs: fix CoW fork repair error handling Yingjie Gao
` (2 preceding siblings ...)
2026-05-26 14:51 ` [PATCH 0/2] xfs: fix CoW fork repair error handling Carlos Maiolino
@ 2026-05-27 3:39 ` Yingjie Gao
2026-05-27 3:39 ` [PATCH v2 1/2] xfs: fix error returns in CoW fork repair Yingjie Gao
` (2 more replies)
3 siblings, 3 replies; 17+ messages in thread
From: Yingjie Gao @ 2026-05-27 3:39 UTC (permalink / raw)
To: linux-xfs; +Cc: cem, djwong, linux-kernel, Yingjie Gao
Fix two error handling paths in CoW fork repair.
Patch 1 makes xrep_cow_find_bad() return saved errors after cleanup.
It also lets a force-rebuild bitmap error fall through to the cleanup
labels instead of returning directly.
Patch 2 applies the same fall-through pattern to the realtime helper
so that scrub rtgroup state is released before returning.
Changes since v1:
- Let the force-rebuild error paths fall through instead of adding
gotos, as Carlos pointed out.
v1:
https://lore.kernel.org/linux-xfs/20260526123243.1078867-1-gaoyingjie@uniontech.com/
Yingjie Gao (2):
xfs: fix error returns in CoW fork repair
xfs: fix rtgroup cleanup in CoW fork repair
fs/xfs/scrub/cow_repair.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 1/2] xfs: fix error returns in CoW fork repair
2026-05-27 3:39 ` [PATCH v2 " Yingjie Gao
@ 2026-05-27 3:39 ` Yingjie Gao
2026-05-27 3:39 ` [PATCH v2 2/2] xfs: fix rtgroup cleanup " Yingjie Gao
2026-05-27 4:31 ` [PATCH v3 0/2] xfs: fix CoW fork repair error handling Yingjie Gao
2 siblings, 0 replies; 17+ messages in thread
From: Yingjie Gao @ 2026-05-27 3:39 UTC (permalink / raw)
To: linux-xfs; +Cc: cem, djwong, linux-kernel, Yingjie Gao
xrep_cow_find_bad() returns success after the cleanup labels even if
AG setup, btree queries, or bitmap updates failed. This can make
repair continue with an incomplete bad-file-offset bitmap instead of
stopping at the original error.
The force-rebuild path has a related cleanup problem. If
xrep_cow_mark_file_range() fails, the function returns directly and
skips the scrub AG context and perag cleanup.
Let the force-rebuild path fall through to the existing cleanup code
and return the saved error after cleanup.
Fixes: dbbdbd008632 ("xfs: repair problems in CoW forks")
Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
---
fs/xfs/scrub/cow_repair.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
index bffc4666ce60..d23238830216 100644
--- a/fs/xfs/scrub/cow_repair.c
+++ b/fs/xfs/scrub/cow_repair.c
@@ -303,15 +303,13 @@ xrep_cow_find_bad(
XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
xc->irec.br_blockcount);
- if (error)
- return error;
}
out_sa:
xchk_ag_free(sc, &sc->sa);
out_pag:
xfs_perag_put(pag);
- return 0;
+ return error;
}
/*
--
2.20.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 2/2] xfs: fix rtgroup cleanup in CoW fork repair
2026-05-27 3:39 ` [PATCH v2 " Yingjie Gao
2026-05-27 3:39 ` [PATCH v2 1/2] xfs: fix error returns in CoW fork repair Yingjie Gao
@ 2026-05-27 3:39 ` Yingjie Gao
2026-05-27 4:31 ` [PATCH v3 0/2] xfs: fix CoW fork repair error handling Yingjie Gao
2 siblings, 0 replies; 17+ messages in thread
From: Yingjie Gao @ 2026-05-27 3:39 UTC (permalink / raw)
To: linux-xfs; +Cc: cem, djwong, linux-kernel, Yingjie Gao
xrep_cow_find_bad_rt() initializes scrub rtgroup state before the
force-rebuild path calls xrep_cow_mark_file_range(). If that call
fails, the code jumps directly to out_rtg, which skips the scrub
rtgroup cleanup and only drops the local rtgroup reference.
Remove the unnecessary jump so the function falls through to out_sr,
ensuring the realtime cursors, lock state, and sr->rtg reference are
released before returning.
Fixes: fd97fe111208 ("xfs: fix CoW forks for realtime files")
Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
---
fs/xfs/scrub/cow_repair.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
index d23238830216..e4ca24623135 100644
--- a/fs/xfs/scrub/cow_repair.c
+++ b/fs/xfs/scrub/cow_repair.c
@@ -386,8 +386,6 @@ xrep_cow_find_bad_rt(
XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
xc->irec.br_blockcount);
- if (error)
- goto out_rtg;
}
out_sr:
--
2.20.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 0/2] xfs: fix CoW fork repair error handling
2026-05-27 3:39 ` [PATCH v2 " Yingjie Gao
2026-05-27 3:39 ` [PATCH v2 1/2] xfs: fix error returns in CoW fork repair Yingjie Gao
2026-05-27 3:39 ` [PATCH v2 2/2] xfs: fix rtgroup cleanup " Yingjie Gao
@ 2026-05-27 4:31 ` Yingjie Gao
2026-05-27 4:31 ` [PATCH v3 1/2] xfs: fix error returns in CoW fork repair Yingjie Gao
` (2 more replies)
2 siblings, 3 replies; 17+ messages in thread
From: Yingjie Gao @ 2026-05-27 4:31 UTC (permalink / raw)
To: linux-xfs; +Cc: cem, djwong, linux-kernel, Yingjie Gao
Fix two error handling paths in CoW fork repair.
Patch 1 makes xrep_cow_find_bad() return saved errors after cleanup.
It also lets a force-rebuild bitmap error fall through to the cleanup
labels instead of returning directly.
Patch 2 applies the same fall-through pattern to the realtime helper
so that scrub rtgroup state is released before returning.
Changes since v2:
- Drop the braces around the single-statement force-rebuild if bodies
in both patches.
v2:
https://lore.kernel.org/linux-xfs/20260527033902.1524007-1-gaoyingjie@uniontech.com/
Changes since v1:
- Let the force-rebuild error paths fall through instead of adding
gotos, as Carlos pointed out.
v1:
https://lore.kernel.org/linux-xfs/20260526123243.1078867-1-gaoyingjie@uniontech.com/
Yingjie Gao (2):
xfs: fix error returns in CoW fork repair
xfs: fix rtgroup cleanup in CoW fork repair
fs/xfs/scrub/cow_repair.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 1/2] xfs: fix error returns in CoW fork repair
2026-05-27 4:31 ` [PATCH v3 0/2] xfs: fix CoW fork repair error handling Yingjie Gao
@ 2026-05-27 4:31 ` Yingjie Gao
2026-05-28 4:44 ` Darrick J. Wong
2026-05-27 4:31 ` [PATCH v3 2/2] xfs: fix rtgroup cleanup " Yingjie Gao
2026-05-30 6:40 ` [PATCH v3 0/2] xfs: fix CoW fork repair error handling Carlos Maiolino
2 siblings, 1 reply; 17+ messages in thread
From: Yingjie Gao @ 2026-05-27 4:31 UTC (permalink / raw)
To: linux-xfs; +Cc: cem, djwong, linux-kernel, Yingjie Gao
xrep_cow_find_bad() returns success after the cleanup labels even if
AG setup, btree queries, or bitmap updates failed. This can make
repair continue with an incomplete bad-file-offset bitmap instead of
stopping at the original error.
The force-rebuild path has a related cleanup problem. If
xrep_cow_mark_file_range() fails, the function returns directly and
skips the scrub AG context and perag cleanup.
Let the force-rebuild path fall through to the existing cleanup code
and return the saved error after cleanup.
Fixes: dbbdbd008632 ("xfs: repair problems in CoW forks")
Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
---
fs/xfs/scrub/cow_repair.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
index bffc4666ce60..a6ff09ace43d 100644
--- a/fs/xfs/scrub/cow_repair.c
+++ b/fs/xfs/scrub/cow_repair.c
@@ -300,18 +300,15 @@ xrep_cow_find_bad(
* on the debugging knob, replace everything in the CoW fork.
*/
if ((sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) ||
- XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
+ XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR))
error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
xc->irec.br_blockcount);
- if (error)
- return error;
- }
out_sa:
xchk_ag_free(sc, &sc->sa);
out_pag:
xfs_perag_put(pag);
- return 0;
+ return error;
}
/*
--
2.20.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 2/2] xfs: fix rtgroup cleanup in CoW fork repair
2026-05-27 4:31 ` [PATCH v3 0/2] xfs: fix CoW fork repair error handling Yingjie Gao
2026-05-27 4:31 ` [PATCH v3 1/2] xfs: fix error returns in CoW fork repair Yingjie Gao
@ 2026-05-27 4:31 ` Yingjie Gao
2026-05-28 4:45 ` Darrick J. Wong
2026-05-30 6:40 ` [PATCH v3 0/2] xfs: fix CoW fork repair error handling Carlos Maiolino
2 siblings, 1 reply; 17+ messages in thread
From: Yingjie Gao @ 2026-05-27 4:31 UTC (permalink / raw)
To: linux-xfs; +Cc: cem, djwong, linux-kernel, Yingjie Gao
xrep_cow_find_bad_rt() initializes scrub rtgroup state before the
force-rebuild path calls xrep_cow_mark_file_range(). If that call
fails, the code jumps directly to out_rtg, which skips the scrub
rtgroup cleanup and only drops the local rtgroup reference.
Remove the unnecessary jump so the function falls through to out_sr,
ensuring the realtime cursors, lock state, and sr->rtg reference are
released before returning.
Fixes: fd97fe111208 ("xfs: fix CoW forks for realtime files")
Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
---
fs/xfs/scrub/cow_repair.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
index a6ff09ace43d..c25716fc4fee 100644
--- a/fs/xfs/scrub/cow_repair.c
+++ b/fs/xfs/scrub/cow_repair.c
@@ -382,12 +382,9 @@ xrep_cow_find_bad_rt(
* CoW fork and then scan for staging extents in the refcountbt.
*/
if ((sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) ||
- XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
+ XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR))
error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
xc->irec.br_blockcount);
- if (error)
- goto out_rtg;
- }
out_sr:
xchk_rtgroup_btcur_free(&sc->sr);
--
2.20.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v3 1/2] xfs: fix error returns in CoW fork repair
2026-05-27 4:31 ` [PATCH v3 1/2] xfs: fix error returns in CoW fork repair Yingjie Gao
@ 2026-05-28 4:44 ` Darrick J. Wong
2026-05-28 8:08 ` Carlos Maiolino
0 siblings, 1 reply; 17+ messages in thread
From: Darrick J. Wong @ 2026-05-28 4:44 UTC (permalink / raw)
To: Yingjie Gao; +Cc: linux-xfs, cem, linux-kernel
On Wed, May 27, 2026 at 12:31:33PM +0800, Yingjie Gao wrote:
> xrep_cow_find_bad() returns success after the cleanup labels even if
> AG setup, btree queries, or bitmap updates failed. This can make
> repair continue with an incomplete bad-file-offset bitmap instead of
> stopping at the original error.
>
> The force-rebuild path has a related cleanup problem. If
> xrep_cow_mark_file_range() fails, the function returns directly and
> skips the scrub AG context and perag cleanup.
>
> Let the force-rebuild path fall through to the existing cleanup code
> and return the saved error after cleanup.
>
Cc: <stable@vger.kernel.org> # v6.8
(please make life easier for Theodorics A and B who are half-assing LTS
QA these days)
> Fixes: dbbdbd008632 ("xfs: repair problems in CoW forks")
> Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
> ---
> fs/xfs/scrub/cow_repair.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
> index bffc4666ce60..a6ff09ace43d 100644
> --- a/fs/xfs/scrub/cow_repair.c
> +++ b/fs/xfs/scrub/cow_repair.c
> @@ -300,18 +300,15 @@ xrep_cow_find_bad(
> * on the debugging knob, replace everything in the CoW fork.
> */
> if ((sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) ||
> - XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
> + XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR))
> error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
> xc->irec.br_blockcount);
> - if (error)
> - return error;
I personally would have stuck with the v1 logic of turning that into a
"goto out_sa" but either way is correct.
With the cc tag added,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> - }
>
> out_sa:
> xchk_ag_free(sc, &sc->sa);
> out_pag:
> xfs_perag_put(pag);
> - return 0;
> + return error;
> }
>
> /*
> --
> 2.20.1
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 2/2] xfs: fix rtgroup cleanup in CoW fork repair
2026-05-27 4:31 ` [PATCH v3 2/2] xfs: fix rtgroup cleanup " Yingjie Gao
@ 2026-05-28 4:45 ` Darrick J. Wong
0 siblings, 0 replies; 17+ messages in thread
From: Darrick J. Wong @ 2026-05-28 4:45 UTC (permalink / raw)
To: Yingjie Gao; +Cc: linux-xfs, cem, linux-kernel
On Wed, May 27, 2026 at 12:31:34PM +0800, Yingjie Gao wrote:
> xrep_cow_find_bad_rt() initializes scrub rtgroup state before the
> force-rebuild path calls xrep_cow_mark_file_range(). If that call
> fails, the code jumps directly to out_rtg, which skips the scrub
> rtgroup cleanup and only drops the local rtgroup reference.
>
> Remove the unnecessary jump so the function falls through to out_sr,
> ensuring the realtime cursors, lock state, and sr->rtg reference are
> released before returning.
Cc: <stable@vger.kernel.org> # v6.14
> Fixes: fd97fe111208 ("xfs: fix CoW forks for realtime files")
> Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
With the cc tag, this looks good to me
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/scrub/cow_repair.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
> index a6ff09ace43d..c25716fc4fee 100644
> --- a/fs/xfs/scrub/cow_repair.c
> +++ b/fs/xfs/scrub/cow_repair.c
> @@ -382,12 +382,9 @@ xrep_cow_find_bad_rt(
> * CoW fork and then scan for staging extents in the refcountbt.
> */
> if ((sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) ||
> - XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
> + XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR))
> error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
> xc->irec.br_blockcount);
> - if (error)
> - goto out_rtg;
> - }
>
> out_sr:
> xchk_rtgroup_btcur_free(&sc->sr);
> --
> 2.20.1
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 1/2] xfs: fix error returns in CoW fork repair
2026-05-28 4:44 ` Darrick J. Wong
@ 2026-05-28 8:08 ` Carlos Maiolino
0 siblings, 0 replies; 17+ messages in thread
From: Carlos Maiolino @ 2026-05-28 8:08 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Yingjie Gao, linux-xfs, linux-kernel
On Wed, May 27, 2026 at 09:44:42PM -0700, Darrick J. Wong wrote:
> On Wed, May 27, 2026 at 12:31:33PM +0800, Yingjie Gao wrote:
> > xrep_cow_find_bad() returns success after the cleanup labels even if
> > AG setup, btree queries, or bitmap updates failed. This can make
> > repair continue with an incomplete bad-file-offset bitmap instead of
> > stopping at the original error.
> >
> > The force-rebuild path has a related cleanup problem. If
> > xrep_cow_mark_file_range() fails, the function returns directly and
> > skips the scrub AG context and perag cleanup.
> >
> > Let the force-rebuild path fall through to the existing cleanup code
> > and return the saved error after cleanup.
> >
>
> Cc: <stable@vger.kernel.org> # v6.8
>
> (please make life easier for Theodorics A and B who are half-assing LTS
> QA these days)
I can add this at commit time
>
> > Fixes: dbbdbd008632 ("xfs: repair problems in CoW forks")
> > Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
> > ---
> > fs/xfs/scrub/cow_repair.c | 7 ++-----
> > 1 file changed, 2 insertions(+), 5 deletions(-)
> >
> > diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
> > index bffc4666ce60..a6ff09ace43d 100644
> > --- a/fs/xfs/scrub/cow_repair.c
> > +++ b/fs/xfs/scrub/cow_repair.c
> > @@ -300,18 +300,15 @@ xrep_cow_find_bad(
> > * on the debugging knob, replace everything in the CoW fork.
> > */
> > if ((sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) ||
> > - XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) {
> > + XFS_TEST_ERROR(sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR))
> > error = xrep_cow_mark_file_range(xc, xc->irec.br_startblock,
> > xc->irec.br_blockcount);
> > - if (error)
> > - return error;
>
> I personally would have stuck with the v1 logic of turning that into a
> "goto out_sa" but either way is correct.
>
> With the cc tag added,
> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
>
> --D
>
>
> > - }
> >
> > out_sa:
> > xchk_ag_free(sc, &sc->sa);
> > out_pag:
> > xfs_perag_put(pag);
> > - return 0;
> > + return error;
> > }
> >
> > /*
> > --
> > 2.20.1
> >
> >
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 0/2] xfs: fix CoW fork repair error handling
2026-05-27 4:31 ` [PATCH v3 0/2] xfs: fix CoW fork repair error handling Yingjie Gao
2026-05-27 4:31 ` [PATCH v3 1/2] xfs: fix error returns in CoW fork repair Yingjie Gao
2026-05-27 4:31 ` [PATCH v3 2/2] xfs: fix rtgroup cleanup " Yingjie Gao
@ 2026-05-30 6:40 ` Carlos Maiolino
2 siblings, 0 replies; 17+ messages in thread
From: Carlos Maiolino @ 2026-05-30 6:40 UTC (permalink / raw)
To: linux-xfs, Yingjie Gao; +Cc: djwong, linux-kernel
On Wed, 27 May 2026 12:31:32 +0800, Yingjie Gao wrote:
> Fix two error handling paths in CoW fork repair.
>
> Patch 1 makes xrep_cow_find_bad() return saved errors after cleanup.
> It also lets a force-rebuild bitmap error fall through to the cleanup
> labels instead of returning directly.
>
> Patch 2 applies the same fall-through pattern to the realtime helper
> so that scrub rtgroup state is released before returning.
>
> [...]
Applied to for-next, thanks!
[1/2] xfs: fix error returns in CoW fork repair
commit: fcf4faba9f986b3bb528da11913c9ec5d6e8f689
[2/2] xfs: fix rtgroup cleanup in CoW fork repair
commit: c3e073894379532c00cca7ba5762e18fafe29da8
Best regards,
--
Carlos Maiolino <cem@kernel.org>
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2026-05-30 6:40 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26 12:32 [PATCH 0/2] xfs: fix CoW fork repair error handling Yingjie Gao
2026-05-26 12:32 ` [PATCH 1/2] xfs: fix error returns in CoW fork repair Yingjie Gao
2026-05-26 14:52 ` Carlos Maiolino
2026-05-26 12:32 ` [PATCH 2/2] xfs: fix rtgroup cleanup " Yingjie Gao
2026-05-26 14:53 ` Carlos Maiolino
2026-05-26 14:51 ` [PATCH 0/2] xfs: fix CoW fork repair error handling Carlos Maiolino
2026-05-27 3:38 ` Yingjie Gao
2026-05-27 3:39 ` [PATCH v2 " Yingjie Gao
2026-05-27 3:39 ` [PATCH v2 1/2] xfs: fix error returns in CoW fork repair Yingjie Gao
2026-05-27 3:39 ` [PATCH v2 2/2] xfs: fix rtgroup cleanup " Yingjie Gao
2026-05-27 4:31 ` [PATCH v3 0/2] xfs: fix CoW fork repair error handling Yingjie Gao
2026-05-27 4:31 ` [PATCH v3 1/2] xfs: fix error returns in CoW fork repair Yingjie Gao
2026-05-28 4:44 ` Darrick J. Wong
2026-05-28 8:08 ` Carlos Maiolino
2026-05-27 4:31 ` [PATCH v3 2/2] xfs: fix rtgroup cleanup " Yingjie Gao
2026-05-28 4:45 ` Darrick J. Wong
2026-05-30 6:40 ` [PATCH v3 0/2] xfs: fix CoW fork repair error handling Carlos Maiolino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox