]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
btrfs: raid56: properly handle the error when unable to find the missing stripe
authorQu Wenruo <wqu@suse.com>
Mon, 10 Oct 2022 10:36:06 +0000 (18:36 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Nov 2022 08:27:18 +0000 (09:27 +0100)
[ Upstream commit f15fb2cd979a07fbfc666e2f04b8b30ec9233b2a ]

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 <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/raid56.c

index 2feb5c20641aecc0107fbe5a3c9ae35cdfc35bcc..a21b9e085d1b55572065e9c60b0a6bcf47e32a59 100644 (file)
@@ -2767,8 +2767,10 @@ raid56_alloc_missing_rbio(struct bio *bio, struct btrfs_io_context *bioc)
 
        rbio->faila = find_logical_bio_stripe(rbio, bio);
        if (rbio->faila == -1) {
-               BUG();
-               kfree(rbio);
+               btrfs_warn_rl(fs_info,
+       "can not determine the failed stripe number for full stripe %llu",
+                             bioc->raid_map[0]);
+               __free_raid_bio(rbio);
                return NULL;
        }