Skip to content

Commit f15fb2c

Browse files
adam900710kdave
authored andcommitted
btrfs: raid56: properly handle the error when unable to find the missing stripe
In raid56_alloc_missing_rbio(), if we can not determine where the missing device is inside the full stripe, we just BUG_ON(). This is not necessary especially the only caller inside scrub.c is already properly checking the return value, and will treat it as a memory allocation failure. Fix the error handling by: - Add an extra warning for the reason Although personally speaking it may be better to be an ASSERT(). - Properly free the allocated rbio Signed-off-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 4efb365 commit f15fb2c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/btrfs/raid56.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -2742,8 +2742,10 @@ raid56_alloc_missing_rbio(struct bio *bio, struct btrfs_io_context *bioc)
27422742

27432743
rbio->faila = find_logical_bio_stripe(rbio, bio);
27442744
if (rbio->faila == -1) {
2745-
BUG();
2746-
kfree(rbio);
2745+
btrfs_warn_rl(fs_info,
2746+
"can not determine the failed stripe number for full stripe %llu",
2747+
bioc->raid_map[0]);
2748+
__free_raid_bio(rbio);
27472749
return NULL;
27482750
}
27492751

0 commit comments

Comments
 (0)