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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C7745C47DD9 for ; Mon, 22 Jan 2024 15:10:03 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rRvw2-0008NU-N2; Mon, 22 Jan 2024 15:10:03 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rRvw1-0008NB-Eh for linux-f2fs-devel@lists.sourceforge.net; Mon, 22 Jan 2024 15:10:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=OfOlg0GQ5UrgwH9NyOQaBKIKytzmrybUTDt7vm8zp5U=; b=W4aN5yRvsDWBfmpdQKA/g6wfOw 8vnholc7aQubkiBGm/I5xh3EEjIRIbMzfcA3nI8vg2Aq3r4QV1wNopDOhkMeIg54d/MMTAiCOa0G4 tgsrGIgChTa0gH4PKs6F3oBPpdu4cuwn5g4cHB1MLGRmljCXmWLz3eRaBi4iV/GSS8HM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=OfOlg0GQ5UrgwH9NyOQaBKIKytzmrybUTDt7vm8zp5U=; b=S IWP/7mBO1hgxmxMOh0juRu5wFj7UT5SaaPjLsKX0x7upAVTVPwrUWbgyUiuQwW7d0i3nOGQl2yQA+ KeIT8Hd0wOObhKMl3ZkMXzZh43gYlbEuqxZNxYio5PlToaupnZAHIVQjwu8Dh1T7R0RVlscy9W0O3 4h5iN3326g3c3kKg=; Received: from sin.source.kernel.org ([145.40.73.55]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rRvw0-0003fi-Ex for linux-f2fs-devel@lists.sourceforge.net; Mon, 22 Jan 2024 15:10:01 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id BE3E6CE2B2C for ; Mon, 22 Jan 2024 15:09:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8D92C433C7; Mon, 22 Jan 2024 15:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705936192; bh=gVYl3puETxMBF8kQKDFOuGLxTaMGQg6pVudIGcoKl2g=; h=From:To:Cc:Subject:Date:From; b=BudYVM5MDW8nK3m4VP96h42pdjiCNYFA3/4RiIn0Ex+N9X9/gfzcmY8fqCZ+Wj2jg ecD8qCWI6NVQvrSOSQSsFvenWTgQ6MTFstJjZaV7RR3s9B2ny8QDczMqu7WYuXRNQD clXmZSq497bUzb/slziDnkzKsZKZ+n7O1UvRxe51u+Z+uT1peKVspH8rV7/81nTK+4 hZrBz4n9S1w/YfO8ECbajyK+GfdkA1J/EvwcNhSF2/p/6262D4a6kv7SFbmDH77imU 1PeMeqNEQ6jizmOPQAYFAA8QVURxdXGuRrKvv1IVcpvpY5B96yMczCZlU2AM+kikSw r0kgxkcEqtsEg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Date: Mon, 22 Jan 2024 10:08:02 -0500 Message-ID: <20240122150949.994249-1-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.74 X-Headers-End: 1rRvw0-0003fi-Ex Subject: [f2fs-dev] [PATCH AUTOSEL 6.1 01/53] f2fs: fix to check return value of f2fs_reserve_new_block() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Chao Yu [ Upstream commit 956fa1ddc132e028f3b7d4cf17e6bfc8cb36c7fd ] Let's check return value of f2fs_reserve_new_block() in do_recover_data() rather than letting it fails silently. Also refactoring check condition on return value of f2fs_reserve_new_block() as below: - trigger f2fs_bug_on() only for ENOSPC case; - use do-while statement to avoid redundant codes; Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/recovery.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c index dea95b48b647..4f4db465220f 100644 --- a/fs/f2fs/recovery.c +++ b/fs/f2fs/recovery.c @@ -683,7 +683,16 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode, */ if (dest == NEW_ADDR) { f2fs_truncate_data_blocks_range(&dn, 1); - f2fs_reserve_new_block(&dn); + do { + err = f2fs_reserve_new_block(&dn); + if (err == -ENOSPC) { + f2fs_bug_on(sbi, 1); + break; + } + } while (err && + IS_ENABLED(CONFIG_F2FS_FAULT_INJECTION)); + if (err) + goto err; continue; } @@ -691,12 +700,14 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode, if (f2fs_is_valid_blkaddr(sbi, dest, META_POR)) { if (src == NULL_ADDR) { - err = f2fs_reserve_new_block(&dn); - while (err && - IS_ENABLED(CONFIG_F2FS_FAULT_INJECTION)) + do { err = f2fs_reserve_new_block(&dn); - /* We should not get -ENOSPC */ - f2fs_bug_on(sbi, err); + if (err == -ENOSPC) { + f2fs_bug_on(sbi, 1); + break; + } + } while (err && + IS_ENABLED(CONFIG_F2FS_FAULT_INJECTION)); if (err) goto err; } -- 2.43.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A1EF4C3AD; Mon, 22 Jan 2024 15:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705936193; cv=none; b=N+QcEIngly8eLC8Zmo7xyuzNOBjancFUQzwv4mrXVC2U+mrXqE2+RMTWAblcCevxM2pVuJFTx40Z7E6aOe0C7WvUr2WbCith9KM/+pvSdabRLkXlzMQf3noLPKQc8PqqsP2VuUR5DRw6xca8PyLFx1RchC9gwMkHX1Wdqny2DBo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705936193; c=relaxed/simple; bh=gVYl3puETxMBF8kQKDFOuGLxTaMGQg6pVudIGcoKl2g=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RVFab2wGtCHGDJ5q6lx+4ccPHnwMVNWLloF0F53bHLGbvZDkmoBf7bP6b2gP9pNs3Vaw1gYRR5/hv0kXexbvlLdiVoXRY/DkrgqJkyhTMd4IYvON6c1m8ZrgIS6GimYDWXfh3VEN21Dm+9FvvoPC8pAtCtQ5CcfVEEAtx89MXW0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BudYVM5M; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BudYVM5M" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8D92C433C7; Mon, 22 Jan 2024 15:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705936192; bh=gVYl3puETxMBF8kQKDFOuGLxTaMGQg6pVudIGcoKl2g=; h=From:To:Cc:Subject:Date:From; b=BudYVM5MDW8nK3m4VP96h42pdjiCNYFA3/4RiIn0Ex+N9X9/gfzcmY8fqCZ+Wj2jg ecD8qCWI6NVQvrSOSQSsFvenWTgQ6MTFstJjZaV7RR3s9B2ny8QDczMqu7WYuXRNQD clXmZSq497bUzb/slziDnkzKsZKZ+n7O1UvRxe51u+Z+uT1peKVspH8rV7/81nTK+4 hZrBz4n9S1w/YfO8ECbajyK+GfdkA1J/EvwcNhSF2/p/6262D4a6kv7SFbmDH77imU 1PeMeqNEQ6jizmOPQAYFAA8QVURxdXGuRrKvv1IVcpvpY5B96yMczCZlU2AM+kikSw r0kgxkcEqtsEg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Chao Yu , Jaegeuk Kim , Sasha Levin , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH AUTOSEL 6.1 01/53] f2fs: fix to check return value of f2fs_reserve_new_block() Date: Mon, 22 Jan 2024 10:08:02 -0500 Message-ID: <20240122150949.994249-1-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.74 Content-Transfer-Encoding: 8bit From: Chao Yu [ Upstream commit 956fa1ddc132e028f3b7d4cf17e6bfc8cb36c7fd ] Let's check return value of f2fs_reserve_new_block() in do_recover_data() rather than letting it fails silently. Also refactoring check condition on return value of f2fs_reserve_new_block() as below: - trigger f2fs_bug_on() only for ENOSPC case; - use do-while statement to avoid redundant codes; Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/recovery.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c index dea95b48b647..4f4db465220f 100644 --- a/fs/f2fs/recovery.c +++ b/fs/f2fs/recovery.c @@ -683,7 +683,16 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode, */ if (dest == NEW_ADDR) { f2fs_truncate_data_blocks_range(&dn, 1); - f2fs_reserve_new_block(&dn); + do { + err = f2fs_reserve_new_block(&dn); + if (err == -ENOSPC) { + f2fs_bug_on(sbi, 1); + break; + } + } while (err && + IS_ENABLED(CONFIG_F2FS_FAULT_INJECTION)); + if (err) + goto err; continue; } @@ -691,12 +700,14 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode, if (f2fs_is_valid_blkaddr(sbi, dest, META_POR)) { if (src == NULL_ADDR) { - err = f2fs_reserve_new_block(&dn); - while (err && - IS_ENABLED(CONFIG_F2FS_FAULT_INJECTION)) + do { err = f2fs_reserve_new_block(&dn); - /* We should not get -ENOSPC */ - f2fs_bug_on(sbi, err); + if (err == -ENOSPC) { + f2fs_bug_on(sbi, 1); + break; + } + } while (err && + IS_ENABLED(CONFIG_F2FS_FAULT_INJECTION)); if (err) goto err; } -- 2.43.0