btrfs-progs: raid56: fix the wrong recovery condition for data and P case

There is a bug in raid56_recov() which doesn't properly repair data and
P case corruption:

	/* Data and P*/
	if (dest2 == nr_devs - 1)
		return raid6_recov_datap(nr_devs, stripe_len, dest1, data);

Note that, dest1/2 is to indicate which slot has corruption.

For RAID6 cases:

[0, nr_devs - 2) is for data stripes,
@data_devs - 2 is for P,
@data_devs - 1 is for Q.

For above code, the comment is correct, but the check condition is
wrong, and leads to the only project, btrfs-fuse, to report raid6
recovery error for 2 devices missing case.

Fix it by using correct condition.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2021-11-16 21:10:51 +08:00 committed by David Sterba
parent 1b194bb620
commit 2755204480

View File

@ -343,7 +343,7 @@ int raid56_recov(int nr_devs, size_t stripe_len, u64 profile, int dest1,
return raid6_recov_data2(nr_devs, stripe_len, dest1, dest2,
data);
/* Data and P*/
if (dest2 == nr_devs - 1)
if (dest2 == nr_devs - 2)
return raid6_recov_datap(nr_devs, stripe_len, dest1, data);
/*