From patchwork Tue Feb 18 05:51:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13979086 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 85F57C02198 for ; Tue, 18 Feb 2025 05:52:18 +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 1tkGWn-0000Iu-0o; Tue, 18 Feb 2025 05:52:17 +0000 Received: from [172.30.29.66] (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 1tkGWl-0000IK-0H for linux-f2fs-devel@lists.sourceforge.net; Tue, 18 Feb 2025 05:52:15 +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=e/scrlPF9Nuommu0AaLdjJYTM9nSFLlyoatgBo1kEyk=; b=LTkwRO1x3teOmmGW7BQPDsI6zX iHu28jT4b4ws9VmctpRuqpSrEh45qxTZZSau0n9a9WM7DSr4SO3E//s7EQfskiGwXwLUQvzSPQCvl pOzf/TUuyZ9WPma5TLUX+hl2NdFov/mrpmdE3dlRn8Aog58hZlQnTaTZDg7sQGtl1vs0=; 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=e/scrlPF9Nuommu0AaLdjJYTM9nSFLlyoatgBo1kEyk=; b=b0IuwEp2EYHiOUftsoOix0BnUG OIxWMWfmoejGUDL59LGMfWaYQ+Sl8ojpt8+jroBKBXizCQnf90y22r/usKJynt36RzDbQd4ZPawi2 Xux9H5j6RYtFpPMH+SWuti6HzQwJZcpkc5Fm3DgIWIEKlsMSNbExxaxcz7FJbyfR4iMk=; Received: from casper.infradead.org ([90.155.50.34]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1tkGWk-0007bb-8L for linux-f2fs-devel@lists.sourceforge.net; Tue, 18 Feb 2025 05:52:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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; bh=e/scrlPF9Nuommu0AaLdjJYTM9nSFLlyoatgBo1kEyk=; b=TYZC6ZtvhUAGk4adZthzzV3cqA 908B3Js9iNm9pVV3EqQdbKM1uo7cd2AOCDl9zAK4M36zd75QB1PVmZi02zP3l95tsZaGpaOvC9esb 7kyD7f+VH5SX060P7gr5zwZ/oDSGCMQNm2h4FLI5Oprk0l9fptdCXwqms2oybocHRN6o7WH6p5RGL D07vUeiiygerUtG9VRYIa4CR+hO3u1+8vF+ss1QeEQ3jgass6pMsSF3QM8VZ40cuwUHD4pEfJ/tdY z9BEx/xMt8O1BySP5zxOYKCcfrR2xyvlwimmC014QSXvlZPVJXNBADHILwOXFx+NUDr+lyKTbc5PH JPwbmdQQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tkGWd-00000002Tsu-3s4X; Tue, 18 Feb 2025 05:52:07 +0000 From: "Matthew Wilcox (Oracle)" To: Jaegeuk Kim , Chao Yu Date: Tue, 18 Feb 2025 05:51:52 +0000 Message-ID: <20250218055203.591403-19-willy@infradead.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250218055203.591403-1-willy@infradead.org> References: <20250218055203.591403-1-willy@infradead.org> MIME-Version: 1.0 X-Headers-End: 1tkGWk-0007bb-8L Subject: [f2fs-dev] [PATCH 18/27] f2fs: Use a folio throughout f2fs_truncate_inode_blocks() 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-fsdevel@vger.kernel.org, "Matthew Wilcox \(Oracle\)" , linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Use f2fs_get_node_folio() to get a folio and use it throughout. Remove a few calls to compound_head() and a reference to page->mapping. Signed-off-by: Matthew Wilcox (Oracle) --- fs/f2fs/node.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 2d161ddda9c3..e1ed7ccfb690 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1130,7 +1130,7 @@ int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from) unsigned int nofs = 0; struct f2fs_inode *ri; struct dnode_of_data dn; - struct page *page; + struct folio *folio; trace_f2fs_truncate_inode_blocks_enter(inode, from); @@ -1140,16 +1140,16 @@ int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from) return level; } - page = f2fs_get_node_page(sbi, inode->i_ino); - if (IS_ERR(page)) { - trace_f2fs_truncate_inode_blocks_exit(inode, PTR_ERR(page)); - return PTR_ERR(page); + folio = f2fs_get_node_folio(sbi, inode->i_ino); + if (IS_ERR(folio)) { + trace_f2fs_truncate_inode_blocks_exit(inode, PTR_ERR(folio)); + return PTR_ERR(folio); } - set_new_dnode(&dn, inode, page, NULL, 0); - unlock_page(page); + set_new_dnode(&dn, inode, &folio->page, NULL, 0); + folio_unlock(folio); - ri = F2FS_INODE(page); + ri = F2FS_INODE(&folio->page); switch (level) { case 0: case 1: @@ -1178,7 +1178,7 @@ int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from) skip_partial: while (cont) { - dn.nid = get_nid(page, offset[0], true); + dn.nid = get_nid(&folio->page, offset[0], true); switch (offset[0]) { case NODE_DIR1_BLOCK: case NODE_DIR2_BLOCK: @@ -1199,7 +1199,7 @@ int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from) BUG(); } if (err == -ENOENT) { - set_sbi_flag(F2FS_P_SB(page), SBI_NEED_FSCK); + set_sbi_flag(F2FS_F_SB(folio), SBI_NEED_FSCK); f2fs_handle_error(sbi, ERROR_INVALID_BLKADDR); f2fs_err_ratelimited(sbi, "truncate node fail, ino:%lu, nid:%u, " @@ -1210,18 +1210,18 @@ int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from) } if (err < 0) goto fail; - if (offset[1] == 0 && get_nid(page, offset[0], true)) { - lock_page(page); - BUG_ON(page->mapping != NODE_MAPPING(sbi)); - set_nid(page, offset[0], 0, true); - unlock_page(page); + if (offset[1] == 0 && get_nid(&folio->page, offset[0], true)) { + folio_lock(folio); + BUG_ON(folio->mapping != NODE_MAPPING(sbi)); + set_nid(&folio->page, offset[0], 0, true); + folio_unlock(folio); } offset[1] = 0; offset[0]++; nofs += err; } fail: - f2fs_put_page(page, 0); + f2fs_folio_put(folio, false); trace_f2fs_truncate_inode_blocks_exit(inode, err); return err > 0 ? 0 : err; }