From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 216A7C43219 for ; Fri, 11 Nov 2022 02:37:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232925AbiKKChL (ORCPT ); Thu, 10 Nov 2022 21:37:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232434AbiKKCgl (ORCPT ); Thu, 10 Nov 2022 21:36:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 018CFCE23; Thu, 10 Nov 2022 18:35:18 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B7D1AB823E2; Fri, 11 Nov 2022 02:35:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A44EFC433D6; Fri, 11 Nov 2022 02:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668134115; bh=QxUeB5WV+GSnRxYS4vTC0gkrV3wabEgLbnL4EVSYrEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gl2zGEQL95LolZIexQ9U83wl5NJ39JrviZJSG77y5ePvrcqFuaSUS1REvUz//1fF5 vYQcByZxfvhUxT3ncpqYQvwG0gwMlEBNm5m6pHvQWXCp1iqb8EzTPd/hbth7E1arUZ WdqwyDCBrREvizjtX5hEJrL9vdTMoy4jyVn3oqtrZ8BqbLru2ykZT6NF0oLXHFnv9p VtsNFLSI+6NurKyZkYgh6yDDHCd9VZSggvaTspf3YTxhUVhMsTXwK5P5keW0D2hs+N NFvFKUarXbaf8b+c4RCx/RmSlxsoAyoaF9ROMGQyIc1kQZlqyptnEDIMfSV4zneefZ 4jT2SABcplV7Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Qu Wenruo , David Sterba , Sasha Levin , clm@fb.com, josef@toxicpanda.com, linux-btrfs@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 02/11] btrfs: raid56: properly handle the error when unable to find the missing stripe Date: Thu, 10 Nov 2022 21:35:02 -0500 Message-Id: <20221111023511.227800-2-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221111023511.227800-1-sashal@kernel.org> References: <20221111023511.227800-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Qu Wenruo [ 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 Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/raid56.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 3157a26ddf7e..5b27c289139a 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -2728,8 +2728,10 @@ raid56_alloc_missing_rbio(struct btrfs_fs_info *fs_info, struct bio *bio, 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; } -- 2.35.1