Message ID | 846cb6c0ad0ba87026f2d0b1ac3dfc4e1ddde21c.1686725373.git.wqu@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: scrub: fix a return value overwrite in scrub_stripe() | expand |
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
On Wed, Jun 14, 2023 at 02:49:35PM +0800, Qu Wenruo wrote: > [RETURN VALUE OVERWRITE] > Inside scrub_stripe(), we would submit all the remaining stripes after > iterating all extents. > > But since flush_scrub_stripes() can return error, we need to avoid > overwriting the existing @ret if there is any error. > > However the existing check is doing the wrong check: > > ret2 = flush_scrub_stripes(); > if (!ret2) > ret = ret2; > > This would overwrite the existing @ret to 0 as long as the final flush > detects no critical errors. > > [FIX] > We should check @ret other than @ret2 in that case. > > Fixes: 8eb3dd17eadd ("btrfs: dev-replace: error out if we have unrepaired metadata error during") > Signed-off-by: Qu Wenruo <wqu@suse.com> Added to misc-next, thanks.
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index be6efe9f3b55..521a5b7895c1 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -2252,7 +2252,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx, } out: ret2 = flush_scrub_stripes(sctx); - if (!ret2) + if (!ret) ret = ret2; if (sctx->raid56_data_stripes) { for (int i = 0; i < nr_data_stripes(map); i++)
[RETURN VALUE OVERWRITE] Inside scrub_stripe(), we would submit all the remaining stripes after iterating all extents. But since flush_scrub_stripes() can return error, we need to avoid overwriting the existing @ret if there is any error. However the existing check is doing the wrong check: ret2 = flush_scrub_stripes(); if (!ret2) ret = ret2; This would overwrite the existing @ret to 0 as long as the final flush detects no critical errors. [FIX] We should check @ret other than @ret2 in that case. Fixes: 8eb3dd17eadd ("btrfs: dev-replace: error out if we have unrepaired metadata error during") Signed-off-by: Qu Wenruo <wqu@suse.com> --- fs/btrfs/scrub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)