summaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2022-10-10 18:36:06 +0800
committerDavid Sterba <dsterba@suse.com>2022-10-24 15:26:54 +0200
commitf15fb2cd979a07fbfc666e2f04b8b30ec9233b2a (patch)
treed4473662322688279a1966c0ec0f3685d0c58b4b /fs/btrfs
parent4efb365a3f04d0bee7833f168b0b00a15edefeac (diff)
downloadlinux-stable-f15fb2cd979a07fbfc666e2f04b8b30ec9233b2a.tar.gz
linux-stable-f15fb2cd979a07fbfc666e2f04b8b30ec9233b2a.tar.bz2
linux-stable-f15fb2cd979a07fbfc666e2f04b8b30ec9233b2a.zip
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 <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/raid56.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index f6395e8288d6..892005f756cf 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -2742,8 +2742,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;
}