From patchwork Sun Dec 10 09:20:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13486373 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 00B69C4167B for ; Sun, 10 Dec 2023 09:21:18 +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 1rCFzx-0007VZ-Th; Sun, 10 Dec 2023 09:21:18 +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 1rCFzu-0007Uf-5X for linux-f2fs-devel@lists.sourceforge.net; Sun, 10 Dec 2023 09:21:14 +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=nzuKnedrEWC6imVBrtc3Ahv7ofZ1i17PF18F+M1hMpI=; b=A0LHmmpTmb/7tgrybK46fpuRbO suF5yZxMIIZ6GJDonqqrXh0Rmq4+Joc7rHQmpa8gXAP/YeUK60K8pzMuEjA1CB/lMBFqtj+Q5jVAk xsVEcpFEuainbqDt+9VNWPkWnhlQChyPbRcn40zrdMuH9yGoakV7alkWBLmjilkrLM5A=; 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=nzuKnedrEWC6imVBrtc3Ahv7ofZ1i17PF18F+M1hMpI=; b=D4oDkCh0BG0lInN/nBfhjW1YIc feuX30ZUZxW5DICsRxGTpDen8j1f8zYxUQWN085VjvMEDlhGjYrWWYdFJEoj3DTIR9I727usQ6Mdm GkWrPwvze1BDnllCZnVok+7WaeHBqQ157w0b1YdD+IphuTNuZYKgGxfSb2n9jY0/yoTc=; 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 1rCFzq-0002n7-98 for linux-f2fs-devel@lists.sourceforge.net; Sun, 10 Dec 2023 09:21:14 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B0E06CE0AC4 for ; Sun, 10 Dec 2023 09:20:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B40CFC433C7; Sun, 10 Dec 2023 09:20:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702200055; bh=eUCNfxU2ZBnjWJhSbW0ed8WQRjl0G3WQDgSCqx5F8l4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CsAAwj/MMr5jSOHLX75QKHpCQxJtZVXufXnZ6XxIMswho/8WFi8muJOhFEAk0mBNc 82vlvK36Hj45Wn+lAU52WNuPlO7MFhdvSjTgjBBwFUAh22Mjr1BnZ71MHQA/NSZiVO NQp+nEztmeLMTbKh9DaYeM6ztfhmTRbAgmQq6nbZoH6+BWj2/L5LX6hM/FyV+gUVeM 3B5BxJ4kJ/+MsnVvRR+sNYzJfzdJv6pgxe0kxvwqbU1LvLMXxE/kxscHdcKZOtMWVg CMT6YQWKIS+EPzY5xwXZyEY97SJucA/U9M40cxsnrmCIqk53e5WtASetoCsJ+B5xd4 pLncCxPkj9n2Q== From: Chao Yu To: jaegeuk@kernel.org Date: Sun, 10 Dec 2023 17:20:39 +0800 Message-Id: <20231210092040.3374741-5-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231210092040.3374741-1-chao@kernel.org> References: <20231210092040.3374741-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1rCFzq-0002n7-98 Subject: [f2fs-dev] [PATCH 5/6] f2fs: introduce f2fs_invalidate_internal_cache() for cleanup 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: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Just cleanup, no logic changes. Signed-off-by: Chao Yu --- fs/f2fs/data.c | 8 +++----- fs/f2fs/f2fs.h | 7 +++++++ fs/f2fs/gc.c | 5 ++--- fs/f2fs/segment.c | 14 ++++---------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index d86419b01310..27015b7875ae 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1484,11 +1484,9 @@ static int __allocate_data_block(struct dnode_of_data *dn, int seg_type) old_blkaddr = dn->data_blkaddr; f2fs_allocate_data_block(sbi, NULL, old_blkaddr, &dn->data_blkaddr, &sum, seg_type, NULL); - if (GET_SEGNO(sbi, old_blkaddr) != NULL_SEGNO) { - invalidate_mapping_pages(META_MAPPING(sbi), - old_blkaddr, old_blkaddr); - f2fs_invalidate_compress_page(sbi, old_blkaddr); - } + if (GET_SEGNO(sbi, old_blkaddr) != NULL_SEGNO) + f2fs_invalidate_internal_cache(sbi, old_blkaddr); + f2fs_update_data_blkaddr(dn, dn->data_blkaddr); return 0; } diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 50e666ebd987..65294e3b0bef 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4613,6 +4613,13 @@ static inline bool f2fs_is_readonly(struct f2fs_sb_info *sbi) return f2fs_sb_has_readonly(sbi) || f2fs_readonly(sbi->sb); } +static inline void f2fs_invalidate_internal_cache(struct f2fs_sb_info *sbi, + block_t blkaddr) +{ + invalidate_mapping_pages(META_MAPPING(sbi), blkaddr, blkaddr); + f2fs_invalidate_compress_page(sbi, blkaddr); +} + #define EFSBADCRC EBADMSG /* Bad CRC detected */ #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */ diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 2fbe16ad726f..405a6077bd83 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1380,9 +1380,8 @@ static int move_data_block(struct inode *inode, block_t bidx, memcpy(page_address(fio.encrypted_page), page_address(mpage), PAGE_SIZE); f2fs_put_page(mpage, 1); - invalidate_mapping_pages(META_MAPPING(fio.sbi), - fio.old_blkaddr, fio.old_blkaddr); - f2fs_invalidate_compress_page(fio.sbi, fio.old_blkaddr); + + f2fs_invalidate_internal_cache(fio.sbi, fio.old_blkaddr); set_page_dirty(fio.encrypted_page); if (clear_page_dirty_for_io(fio.encrypted_page)) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 007ebb107236..61da26eb61cc 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2500,8 +2500,7 @@ void f2fs_invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr) if (addr == NEW_ADDR || addr == COMPRESS_ADDR) return; - invalidate_mapping_pages(META_MAPPING(sbi), addr, addr); - f2fs_invalidate_compress_page(sbi, addr); + f2fs_invalidate_internal_cache(sbi, addr); /* add it into sit main buffer */ down_write(&sit_i->sentry_lock); @@ -3562,11 +3561,8 @@ static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio) reallocate: f2fs_allocate_data_block(fio->sbi, fio->page, fio->old_blkaddr, &fio->new_blkaddr, sum, type, fio); - if (GET_SEGNO(fio->sbi, fio->old_blkaddr) != NULL_SEGNO) { - invalidate_mapping_pages(META_MAPPING(fio->sbi), - fio->old_blkaddr, fio->old_blkaddr); - f2fs_invalidate_compress_page(fio->sbi, fio->old_blkaddr); - } + if (GET_SEGNO(fio->sbi, fio->old_blkaddr) != NULL_SEGNO) + f2fs_invalidate_internal_cache(fio->sbi, fio->old_blkaddr); /* writeout dirty page into bdev */ f2fs_submit_page_write(fio); @@ -3762,9 +3758,7 @@ void f2fs_do_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, update_sit_entry(sbi, new_blkaddr, 1); } if (GET_SEGNO(sbi, old_blkaddr) != NULL_SEGNO) { - invalidate_mapping_pages(META_MAPPING(sbi), - old_blkaddr, old_blkaddr); - f2fs_invalidate_compress_page(sbi, old_blkaddr); + f2fs_invalidate_internal_cache(sbi, old_blkaddr); if (!from_gc) update_segment_mtime(sbi, old_blkaddr, 0); update_sit_entry(sbi, old_blkaddr, -1);