From patchwork Tue Apr 9 20:34:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13623232 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 65E6BCD129A for ; Tue, 9 Apr 2024 20:34:31 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1ruIAo-00073L-90; Tue, 09 Apr 2024 20:34:30 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ruIAn-00073B-A2 for linux-f2fs-devel@lists.sourceforge.net; Tue, 09 Apr 2024 20:34:29 +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=NhtsXoRKUqq4hsMx2pA6WaoBbzOvRD+NiaEMAGMouh4=; b=mnwDDWNUmoWwNkKFACiH9ixZjT WFjIz9HB11XanZk003iu1rJxzoRV0H3lYVeCSJsQNKn0e2911O3w/x+j5zjeeRtvnLMoWV6XHGHiA 9vx2WhLpCGF8GGWMm7CIVEXw3YjXup0CyRV99yEOyQsI8r2OIfEPh6sqPd36C5o0TAHY=; 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=NhtsXoRKUqq4hsMx2pA6WaoBbzOvRD+NiaEMAGMouh4=; b=R OWqEEUqyWHxG++swCNvuwzyAWJiWH8Xekl79MFMRb1w9SVQvk8ID15Pom5SnSetfhEnoZJ1ksYxEG z0w/c8qQsrlLM/7j5Lw15De4JSZWJk3H4MbyoXg+8+uNzGhegI/mJWsMJhKtnsnquyZWyu5VcrmyV FkqrTzXSqKGKL5wY=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1ruIAf-0001Q9-BM for linux-f2fs-devel@lists.sourceforge.net; Tue, 09 Apr 2024 20:34:25 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 08B0861A0A for ; Tue, 9 Apr 2024 20:34:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9061AC433F1; Tue, 9 Apr 2024 20:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712694855; bh=b3ttuqhR2lE3/ooK+He6Bxq4Y4ocjGQu2qVnnFvzt3E=; h=From:To:Cc:Subject:Date:From; b=jgV+KyxMSmKVsIW5Datu32WxKTPm4RUP3BcRod7zvS2MN6JReG6EoIjj5fgi4XGtE 7vTK+miVqsVB2MhHxmbrXMtlQbzEM2ILUxcXHPgc9pxviFXQfwQkh5M/SefZPKuAvk gGRrC2VtowxWxDd4zptc5FoF0eicC1tyBFZ2PoXO5a1eWYs0YxBA0HMaJOpox7belm GrwsYUxaUhNMt+f8/veKgcWDptT3e52FZ+gbXdZHiP2mo8wnr6AbNiYAPy9ZLS9a7a +XuWk4M+4vBRTstUu4xCKXOjLpFONnQHmuPAUmjBRl/gyhl5aPoRX/RqgveM1yF5nz Drx+6Fi2bmXtw== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Tue, 9 Apr 2024 20:34:09 +0000 Message-ID: <20240409203411.1885121-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog MIME-Version: 1.0 X-Headers-End: 1ruIAf-0001Q9-BM Subject: [f2fs-dev] [PATCH 1/3] f2fs: use folio_test_writeback 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: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Let's convert PageWriteback to folio_test_writeback. Signed-off-by: Jaegeuk Kim Reviewed-by: Chao Yu --- fs/f2fs/compress.c | 2 +- fs/f2fs/data.c | 3 +-- fs/f2fs/f2fs.h | 2 +- fs/f2fs/gc.c | 2 +- fs/f2fs/inline.c | 2 +- fs/f2fs/inode.c | 3 ++- fs/f2fs/node.c | 2 +- fs/f2fs/segment.c | 10 +++++----- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index 8892c8262141..d67c471ab5df 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -1484,7 +1484,7 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc, if (!PageDirty(cc->rpages[i])) goto continue_unlock; - if (PageWriteback(cc->rpages[i])) { + if (folio_test_writeback(page_folio(cc->rpages[i]))) { if (wbc->sync_mode == WB_SYNC_NONE) goto continue_unlock; f2fs_wait_on_page_writeback(cc->rpages[i], DATA, true, true); diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 60056b9a51be..19f1e573297d 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2707,8 +2707,7 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio) if (err) { if (fscrypt_inode_uses_fs_layer_crypto(inode)) fscrypt_finalize_bounce_page(&fio->encrypted_page); - if (PageWriteback(page)) - end_page_writeback(page); + end_page_writeback(page); } else { set_inode_flag(inode, FI_UPDATE_WRITE); } diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index e9ef971f4dba..dd530dc70005 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4660,7 +4660,7 @@ static inline void f2fs_truncate_meta_inode_pages(struct f2fs_sb_info *sbi, page = find_get_page(META_MAPPING(sbi), blkaddr + i); if (page) { - if (PageWriteback(page)) + if (folio_test_writeback(page_folio(page))) need_submit = true; f2fs_put_page(page, 0); } diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 8852814dab7f..ac4cbbe50c2f 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1434,7 +1434,7 @@ static int move_data_page(struct inode *inode, block_t bidx, int gc_type, goto out; if (gc_type == BG_GC) { - if (PageWriteback(page)) { + if (folio_test_writeback(page_folio(page))) { err = -EAGAIN; goto out; } diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c index ac00423f117b..3d3218a4b29d 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c @@ -164,7 +164,7 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page) return -EFSCORRUPTED; } - f2fs_bug_on(F2FS_P_SB(page), PageWriteback(page)); + f2fs_bug_on(F2FS_P_SB(page), folio_test_writeback(page_folio(page))); f2fs_do_read_inline_data(page, dn->inode_page); set_page_dirty(page); diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index 12b1fef31f43..d7a5a88a1a5e 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -161,7 +161,8 @@ bool f2fs_inode_chksum_verify(struct f2fs_sb_info *sbi, struct page *page) if (!f2fs_enable_inode_chksum(sbi, page)) #else if (!f2fs_enable_inode_chksum(sbi, page) || - PageDirty(page) || PageWriteback(page)) + PageDirty(page) || + folio_test_writeback(page_folio(page))) #endif return true; diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index bb57bbaff7b4..3b9eb5693683 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1743,7 +1743,7 @@ int f2fs_move_node_page(struct page *node_page, int gc_type) goto release_page; } else { /* set page dirty and write it */ - if (!PageWriteback(node_page)) + if (!folio_test_writeback(page_folio(node_page))) set_page_dirty(node_page); } out_page: diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 4fd76e867e0a..065fd5919b48 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3612,13 +3612,13 @@ int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, mutex_unlock(&curseg->curseg_mutex); f2fs_up_read(&SM_I(sbi)->curseg_lock); return 0; + out_err: *new_blkaddr = NULL_ADDR; up_write(&sit_i->sentry_lock); mutex_unlock(&curseg->curseg_mutex); f2fs_up_read(&SM_I(sbi)->curseg_lock); return ret; - } void f2fs_update_device_state(struct f2fs_sb_info *sbi, nid_t ino, @@ -3660,8 +3660,7 @@ static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio) &fio->new_blkaddr, sum, type, fio)) { if (fscrypt_inode_uses_fs_layer_crypto(fio->page->mapping->host)) fscrypt_finalize_bounce_page(&fio->encrypted_page); - if (PageWriteback(fio->page)) - end_page_writeback(fio->page); + end_page_writeback(fio->page); if (f2fs_in_warm_node_list(fio->sbi, fio->page)) f2fs_del_fsync_node_entry(fio->sbi, fio->page); goto out; @@ -3904,7 +3903,7 @@ void f2fs_replace_block(struct f2fs_sb_info *sbi, struct dnode_of_data *dn, void f2fs_wait_on_page_writeback(struct page *page, enum page_type type, bool ordered, bool locked) { - if (PageWriteback(page)) { + if (folio_test_writeback(page_folio(page))) { struct f2fs_sb_info *sbi = F2FS_P_SB(page); /* submit cached LFS IO */ @@ -3913,7 +3912,8 @@ void f2fs_wait_on_page_writeback(struct page *page, f2fs_submit_merged_ipu_write(sbi, NULL, page); if (ordered) { wait_on_page_writeback(page); - f2fs_bug_on(sbi, locked && PageWriteback(page)); + f2fs_bug_on(sbi, locked && + folio_test_writeback(page_folio(page))); } else { wait_for_stable_page(page); } From patchwork Tue Apr 9 20:34:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13623231 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 281C9C67861 for ; Tue, 9 Apr 2024 20:34:30 +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 1ruIAl-0004a9-Q8; Tue, 09 Apr 2024 20:34:28 +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 1ruIAi-0004Zg-20 for linux-f2fs-devel@lists.sourceforge.net; Tue, 09 Apr 2024 20:34:24 +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:References: In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=DViuD9q47sgWqUNVbmW7SyxVjvs0LravwJ40SFdxKG4=; b=bpnvv/JrSMwaihzdR8hfrPz2P3 8MxyY/xQFuYoOUcxUi+o13NdGjRikxAnntsYNxpURlBPlmKYunNYHCcIRYYLutp4lyXrcvRqZgFny 4TZmXFvXtVZBHjs/gKMWUInuO8FEbHzQ8Hahrww60czBioXYSbphdy6mka+KbLm17uPM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=DViuD9q47sgWqUNVbmW7SyxVjvs0LravwJ40SFdxKG4=; b=GKM923FmxyAyGUI8QscbkfIwaq dI81Y2yc9zxL7uXDA1ZyqBiLSiFzDOTeNj/Z+AWdrRyBVCUVPMRNtgZS76wktuHP++NMKLsEcw6dA 7zazscK5/MGmm7ON12lcxYGIOR4/FuQ2VSI8rsfiN+2HBZ8rutE/iPecf9Huw3bBF/CI=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1ruIAg-0001QE-AJ for linux-f2fs-devel@lists.sourceforge.net; Tue, 09 Apr 2024 20:34:22 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0227261A17 for ; Tue, 9 Apr 2024 20:34:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A76CC433F1; Tue, 9 Apr 2024 20:34:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712694856; bh=yuHHraFJs2uSx9hQ7hdbnjpoe1/DllEgPkr59YJ8+BU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qYS5yUbp2j2MUkMS/chiuO59dZHMJNSE+6fhRmIqgrmpMsWsXPq11EPlEQFcnkp99 HnWtx8P31Ejg/zj46124biFba+Pz96KQDjmJKVU+nC6XcSZQgQBrrOUWr6bTKqcOpt 4DY6avaWW08lHV6cty4FKMK6+zo/lsMlbAqXZ2QUptl3W5G26MOWu3+z2vGtX2oXDs 4Id09by82cRuUMnEwQIiKdAKmEs7Wbybyr9PlYxfKOX5+66+MMC2k6H+jG2kqlTWlM f9eIVPMnKbWIBXfIGJ1Eg7iK8YGSTc0vbg1Dk3wDgGQL3U2XskeK37fh4nEmZ5AnTu exkNMIRLiJeUg== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Tue, 9 Apr 2024 20:34:10 +0000 Message-ID: <20240409203411.1885121-2-jaegeuk@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240409203411.1885121-1-jaegeuk@kernel.org> References: <20240409203411.1885121-1-jaegeuk@kernel.org> MIME-Version: 1.0 X-Headers-End: 1ruIAg-0001QE-AJ Subject: [f2fs-dev] [PATCH 2/3] f2fs: clear writeback when compression failed 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: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Let's stop issuing compressed writes and clear their writeback flags. Signed-off-by: Jaegeuk Kim Signed-off-by: Jaegeuk Kim Reviewed-by: Daeho Jeong Reviewed-by: Chao Yu --- fs/f2fs/compress.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index d67c471ab5df..3a8ecc6aee84 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -1031,6 +1031,25 @@ static void set_cluster_writeback(struct compress_ctx *cc) } } +static void cancel_cluster_writeback(struct compress_ctx *cc, int submitted) +{ + int i; + + for (i = 0; i < cc->cluster_size; i++) { + if (!cc->rpages[i]) + continue; + if (i < submitted) { + if (i) + f2fs_wait_on_page_writeback(cc->rpages[i], + DATA, true, true); + inode_inc_dirty_pages(cc->inode); + lock_page(cc->rpages[i]); + } + clear_page_private_gcing(cc->rpages[i]); + end_page_writeback(cc->rpages[i]); + } +} + static void set_cluster_dirty(struct compress_ctx *cc) { int i; @@ -1232,7 +1251,6 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc, .page = NULL, .encrypted_page = NULL, .compressed_page = NULL, - .submitted = 0, .io_type = io_type, .io_wbc = wbc, .encrypted = fscrypt_inode_uses_fs_layer_crypto(cc->inode) ? @@ -1358,7 +1376,15 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc, fio.compressed_page = cc->cpages[i - 1]; cc->cpages[i - 1] = NULL; + fio.submitted = 0; f2fs_outplace_write_data(&dn, &fio); + if (unlikely(!fio.submitted)) { + cancel_cluster_writeback(cc, i); + + /* To call fscrypt_finalize_bounce_page */ + i = cc->valid_nr_cpages; + goto out_destroy_crypt; + } (*submitted)++; unlock_continue: inode_dec_dirty_pages(cc->inode); @@ -1392,8 +1418,11 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc, out_destroy_crypt: page_array_free(cc->inode, cic->rpages, cc->cluster_size); - for (--i; i >= 0; i--) + for (--i; i >= 0; i--) { + if (!cc->cpages[i]) + continue; fscrypt_finalize_bounce_page(&cc->cpages[i]); + } out_put_cic: kmem_cache_free(cic_entry_slab, cic); out_put_dnode: From patchwork Tue Apr 9 20:34:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13623233 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 5D85CCD128A for ; Tue, 9 Apr 2024 20:34:31 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1ruIAo-0007Q1-Lx; Tue, 09 Apr 2024 20:34:31 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ruIAn-0007Pk-CR for linux-f2fs-devel@lists.sourceforge.net; Tue, 09 Apr 2024 20:34:29 +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:References: In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=chP/1/6goYaphGUjfEv2QXzQENrepAGweOTmsWv0VR8=; b=VOFBqlpoouHQIR4r3Ut8KDE9jD Mp9aURkbRFYMnFCri6WIM7F4J3Z7mCubbIzwLrqHOHXb0GYKa5dmuUFf65BhIPeAca1nEha7SSnBB QoIy6KTrbtdQNDzR6COa9vI6zN8KvVGlXbeXz2gxCsw44REgzIhoKkMJpZKXTyUJZFGQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=chP/1/6goYaphGUjfEv2QXzQENrepAGweOTmsWv0VR8=; b=ahBwR+7+0EQlBviRMfnrjaQ7qN u2J5pKCx4/k1nYT5ktrEx20NDQ0Na0i2Pj84nOPfL07bvO/724CY/u4DRk6Yh+cEGjBySc5IPTn+f fH9TUAysnMnSdJW3j/J76tehorGyxsL/1ejwhmokxGQohxf4LX4yWzh0JViSaB6IfWS4=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1ruIAm-0001Qg-A3 for linux-f2fs-devel@lists.sourceforge.net; Tue, 09 Apr 2024 20:34:28 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 016E561A22 for ; Tue, 9 Apr 2024 20:34:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B26AC433C7; Tue, 9 Apr 2024 20:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712694857; bh=+4w6Yn40335a0GsU306fLSUnzxXEUP2Ol6OJgXDYeI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FOjfp/7g2+iX4WP7BmUILh7tqFC85L1DLkTG24ckMIrxOZGocygA/5bs19BDuOc3M BDtYlBc+gY0lkLP8sezyoUt/3Qx8AV0wO1ptAMIQJNjHKglQcweQmZXRaW6aMeyWdZ jz3fF0yGMNUcvDFc4GqmvwlU3eXu+JGxnYClbmc5OJc9MamBMmApbAvftFWvUCaDCi ZLLFjUw1H5Fdf9Wv0Pjd3Sbx5dlmGQlRqc3cyQEH5jJwZi2NU1cnXJsJJX8bEOlhEB bKt1XiCNEK2kCv6R0y1q5n9pAS7EogAtl1Ed1ndGkIbZl30272kQWaGuYQGUoDfNfy zjtcH1ozj0BCw== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Tue, 9 Apr 2024 20:34:11 +0000 Message-ID: <20240409203411.1885121-3-jaegeuk@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240409203411.1885121-1-jaegeuk@kernel.org> References: <20240409203411.1885121-1-jaegeuk@kernel.org> MIME-Version: 1.0 X-Headers-End: 1ruIAm-0001Qg-A3 Subject: [f2fs-dev] [PATCH 3/3] f2fs: fix false alarm on invalid block address 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: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net f2fs_ra_meta_pages can try to read ahead on invalid block address which is not the corruption case. Fixes: 31f85ccc84b8 ("f2fs: unify the error handling of f2fs_is_valid_blkaddr") Signed-off-by: Jaegeuk Kim --- fs/f2fs/checkpoint.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index eac698b8dd38..b01320502624 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -179,22 +179,22 @@ static bool __f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi, break; case META_SIT: if (unlikely(blkaddr >= SIT_BLK_CNT(sbi))) - goto err; + goto check_only; break; case META_SSA: if (unlikely(blkaddr >= MAIN_BLKADDR(sbi) || blkaddr < SM_I(sbi)->ssa_blkaddr)) - goto err; + goto check_only; break; case META_CP: if (unlikely(blkaddr >= SIT_I(sbi)->sit_base_addr || blkaddr < __start_cp_addr(sbi))) - goto err; + goto check_only; break; case META_POR: if (unlikely(blkaddr >= MAX_BLKADDR(sbi) || blkaddr < MAIN_BLKADDR(sbi))) - goto err; + goto check_only; break; case DATA_GENERIC: case DATA_GENERIC_ENHANCE: @@ -228,6 +228,7 @@ static bool __f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi, return true; err: f2fs_handle_error(sbi, ERROR_INVALID_BLKADDR); +check_only: return false; }