From patchwork Mon Apr 22 06:24:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13637667 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 AD2B6C04FF6 for ; Mon, 22 Apr 2024 06:24:36 +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 1ryn6O-0002nf-Hd; Mon, 22 Apr 2024 06:24:33 +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 1ryn6M-0002nP-R4 for linux-f2fs-devel@lists.sourceforge.net; Mon, 22 Apr 2024 06:24:31 +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=3RPbzZaKpNpx+hJXEGA+mqxUlf54lEOjgi/6V2cCFPM=; b=DGSzThlUZv15Cy0hFjD4PG4e4w y45v9WBUkaJsqx2KYwtPMdGdEtu40CSGavWiCPL6LKFiTnEqPla7Z6FQnucIp7JZKyPu9gtoaGi0U gcm9ABJMzBQTJ6DVWmmmRqa7/13HB/m6JWPQtrH4sb4ffXvVqgyMqbEu42+irvOODIzc=; 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=3RPbzZaKpNpx+hJXEGA+mqxUlf54lEOjgi/6V2cCFPM=; b=c 3QmPZ0AGwUp5F4zNAnxsk8EYzC4ZNbquf4N2WT/knYnswez5YGKOcylt+ALJ1eBqrVTrC8W9pjZwE F7W+IYDn3Mtcq9uYcizzpfJlf4DS0UDAQUtAoKy8QEPQ6bg48ti/Dl4Xn4Wp/2x7jp3u1HludXNHJ xEr72LNcWlmcu9t8=; 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 1ryn6M-0003db-81 for linux-f2fs-devel@lists.sourceforge.net; Mon, 22 Apr 2024 06:24:31 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 274EF60C2C for ; Mon, 22 Apr 2024 06:24:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B9FBC116B1; Mon, 22 Apr 2024 06:24:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713767064; bh=2QoZ6xX4IimgOgvIRYJS2/KFiClJl3fHIS1noYBxHZI=; h=From:To:Cc:Subject:Date:From; b=L+el3r3nSlCtYRJogplF8kaG7cSfgKJKTO2aTkJFvJy+GTo+A20CNyJLvoFKydy9p 693A20syONNQ1vqBX4aQASUamtPQT+aV05b8q8+idnZFAmc9tTlqx7cjLID/fU1c/H CJLuukhW45QnMz1MrnCPDm8P2Sb9CRkyh5AZC/d9Czz9wrE958LwUj2krxfyOvIq45 kr2feC11lYEgDADb2mB91TpiBCY/KmsFHFZ5lT53LkyypFzP2mnbFO0XHVYuepSr4B hozQT0fPOLE8Fz7mOdf+JOHjt2OILnzFE85/SlVhLCiQRqX4xByk6N/tbzQLCrsyZb 3CFeUGBcV2MWA== From: Chao Yu To: jaegeuk@kernel.org Date: Mon, 22 Apr 2024 14:24:14 +0800 Message-Id: <20240422062417.2421616-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Headers-End: 1ryn6M-0003db-81 Subject: [f2fs-dev] [PATCH v2 1/4] f2fs: convert f2fs_mpage_readpages() to use folio 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 Convert f2fs_mpage_readpages() to use folio and related functionality. Signed-off-by: Chao Yu --- v2: - fix compile warning w/o CONFIG_F2FS_FS_COMPRESSION reported by lkp fs/f2fs/data.c | 81 +++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index ed7d08785fcf..6419cf020327 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2345,7 +2345,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, * Major change was from block_size == page_size in f2fs by default. */ static int f2fs_mpage_readpages(struct inode *inode, - struct readahead_control *rac, struct page *page) + struct readahead_control *rac, struct folio *folio) { struct bio *bio = NULL; sector_t last_block_in_bio = 0; @@ -2362,6 +2362,7 @@ static int f2fs_mpage_readpages(struct inode *inode, .nr_cpages = 0, }; pgoff_t nc_cluster_idx = NULL_CLUSTER; + pgoff_t index; #endif unsigned nr_pages = rac ? readahead_count(rac) : 1; unsigned max_nr_pages = nr_pages; @@ -2378,64 +2379,62 @@ static int f2fs_mpage_readpages(struct inode *inode, for (; nr_pages; nr_pages--) { if (rac) { - page = readahead_page(rac); - prefetchw(&page->flags); + folio = readahead_folio(rac); + prefetchw(&folio->flags); } #ifdef CONFIG_F2FS_FS_COMPRESSION - if (f2fs_compressed_file(inode)) { - /* there are remained compressed pages, submit them */ - if (!f2fs_cluster_can_merge_page(&cc, page->index)) { - ret = f2fs_read_multi_pages(&cc, &bio, - max_nr_pages, - &last_block_in_bio, - rac != NULL, false); - f2fs_destroy_compress_ctx(&cc, false); - if (ret) - goto set_error_page; - } - if (cc.cluster_idx == NULL_CLUSTER) { - if (nc_cluster_idx == - page->index >> cc.log_cluster_size) { - goto read_single_page; - } - - ret = f2fs_is_compressed_cluster(inode, page->index); - if (ret < 0) - goto set_error_page; - else if (!ret) { - nc_cluster_idx = - page->index >> cc.log_cluster_size; - goto read_single_page; - } - - nc_cluster_idx = NULL_CLUSTER; - } - ret = f2fs_init_compress_ctx(&cc); + index = folio_index(folio); + + if (!f2fs_compressed_file(inode)) + goto read_single_page; + + /* there are remained compressed pages, submit them */ + if (!f2fs_cluster_can_merge_page(&cc, index)) { + ret = f2fs_read_multi_pages(&cc, &bio, + max_nr_pages, + &last_block_in_bio, + rac != NULL, false); + f2fs_destroy_compress_ctx(&cc, false); if (ret) goto set_error_page; + } + if (cc.cluster_idx == NULL_CLUSTER) { + if (nc_cluster_idx == index >> cc.log_cluster_size) + goto read_single_page; - f2fs_compress_ctx_add_page(&cc, page); + ret = f2fs_is_compressed_cluster(inode, index); + if (ret < 0) + goto set_error_page; + else if (!ret) { + nc_cluster_idx = + index >> cc.log_cluster_size; + goto read_single_page; + } - goto next_page; + nc_cluster_idx = NULL_CLUSTER; } + ret = f2fs_init_compress_ctx(&cc); + if (ret) + goto set_error_page; + + f2fs_compress_ctx_add_page(&cc, &folio->page); + + goto next_page; read_single_page: #endif - - ret = f2fs_read_single_page(inode, page, max_nr_pages, &map, + ret = f2fs_read_single_page(inode, &folio->page, max_nr_pages, &map, &bio, &last_block_in_bio, rac); if (ret) { #ifdef CONFIG_F2FS_FS_COMPRESSION set_error_page: #endif - zero_user_segment(page, 0, PAGE_SIZE); - unlock_page(page); + folio_zero_segment(folio, 0, folio_size(folio)); + folio_unlock(folio); } #ifdef CONFIG_F2FS_FS_COMPRESSION next_page: #endif - if (rac) - put_page(page); #ifdef CONFIG_F2FS_FS_COMPRESSION if (f2fs_compressed_file(inode)) { @@ -2472,7 +2471,7 @@ static int f2fs_read_data_folio(struct file *file, struct folio *folio) if (f2fs_has_inline_data(inode)) ret = f2fs_read_inline_data(inode, page); if (ret == -EAGAIN) - ret = f2fs_mpage_readpages(inode, NULL, page); + ret = f2fs_mpage_readpages(inode, NULL, folio); return ret; } From patchwork Mon Apr 22 06:24:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13637668 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 B0AF8C05023 for ; Mon, 22 Apr 2024 06:24:36 +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 1ryn6Q-00063t-1k; Mon, 22 Apr 2024 06:24:34 +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 1ryn6P-00063l-0u for linux-f2fs-devel@lists.sourceforge.net; Mon, 22 Apr 2024 06:24:33 +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=k/FRz+hMLSVMIRaJ6shy9/XVHMVYO5eOzEO0+HjW35s=; b=BXT0KH2yOv+fdlr8pg9yDkZypw Ud8WMk0ekoL1P7oyDSnsOByI8uy0PMxdJk0r2DMNE8ktWBMfoD/d9agSnA9/7rl7MsV2wUG8fhuVo 0p8w7r49lZDO1wgxleyscYznz1KO7HdfAmkDe+pAtRrvxoos4Ve8bIbHhUtVX6+ORPZ0=; 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=k/FRz+hMLSVMIRaJ6shy9/XVHMVYO5eOzEO0+HjW35s=; b=Cql1aPppsPKwSA7ZEnQxHQKuFN kADT8lmpThF4uLuJ6Nh26nrZ1BCSvxqC+9/2hehTL7oC5yjdgw28aHGHuDK4qFR3jasRAAbmHOfxy eIr7rVP9MVpuqSlAuCCif0lrhug83YSmafHtiiRN52/Jj6Nyr0f/Sj0xEtX0UIjsgH44=; 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 1ryn6O-0003dd-2H for linux-f2fs-devel@lists.sourceforge.net; Mon, 22 Apr 2024 06:24:33 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4A86760C47 for ; Mon, 22 Apr 2024 06:24:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 544F8C113CC; Mon, 22 Apr 2024 06:24:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713767066; bh=lq61WtOlYIOBoAAF9mgYkGC8E+tMVi57Ql/mXCqncQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LcaS7AqbEfyPuC8TTV8PfYy3fb2RB0Ta6U/sZx/YeksnX1Csf90pLAIQj1WICfcMG T7O83eJHF/K/jsbGu8B88bEhvF0MbHVNegVHPd42fgSSAIAUPR4yVIIf7kFynhmIdX 5E4CXH3Ow6J0vDL0ZcqZPsiqQwAiR4tIHmBpWrj6I0syQUfYZT2BIfQd/+cK4VCea4 Ork8W1606pr5MHSW5Jcm5apIpInaPqW0V5XhovqmTJmT7DgyDpkw+ZzGWls6jpjSdO JwcVBWV5HT6oXhBDzIOYdX1AAuSzYe5yJiSnMg6Hi73aAMc2rnlTsh2iI18q2kww2X WbDzcwwqKc4kQ== From: Chao Yu To: jaegeuk@kernel.org Date: Mon, 22 Apr 2024 14:24:15 +0800 Message-Id: <20240422062417.2421616-2-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240422062417.2421616-1-chao@kernel.org> References: <20240422062417.2421616-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1ryn6O-0003dd-2H Subject: [f2fs-dev] [PATCH v2 2/4] f2fs: convert f2fs_read_single_page() to use folio 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 Convert f2fs_read_single_page() to use folio and related functionality. Signed-off-by: Chao Yu --- v2: - no change. fs/f2fs/data.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 6419cf020327..bb6c0e955d7e 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2063,7 +2063,7 @@ static inline loff_t f2fs_readpage_limit(struct inode *inode) return i_size_read(inode); } -static int f2fs_read_single_page(struct inode *inode, struct page *page, +static int f2fs_read_single_page(struct inode *inode, struct folio *folio, unsigned nr_pages, struct f2fs_map_blocks *map, struct bio **bio_ret, @@ -2076,9 +2076,10 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, sector_t last_block; sector_t last_block_in_file; sector_t block_nr; + pgoff_t index = folio_index(folio); int ret = 0; - block_in_file = (sector_t)page_index(page); + block_in_file = (sector_t)index; last_block = block_in_file + nr_pages; last_block_in_file = bytes_to_blks(inode, f2fs_readpage_limit(inode) + blocksize - 1); @@ -2109,7 +2110,7 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, got_it: if ((map->m_flags & F2FS_MAP_MAPPED)) { block_nr = map->m_pblk + block_in_file - map->m_lblk; - SetPageMappedToDisk(page); + folio_set_mappedtodisk(folio); if (!f2fs_is_valid_blkaddr(F2FS_I_SB(inode), block_nr, DATA_GENERIC_ENHANCE_READ)) { @@ -2118,15 +2119,15 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, } } else { zero_out: - zero_user_segment(page, 0, PAGE_SIZE); - if (f2fs_need_verity(inode, page->index) && - !fsverity_verify_page(page)) { + folio_zero_segment(folio, 0, folio_size(folio)); + if (f2fs_need_verity(inode, index) && + !fsverity_verify_folio(folio)) { ret = -EIO; goto out; } - if (!PageUptodate(page)) - SetPageUptodate(page); - unlock_page(page); + if (!folio_test_uptodate(folio)) + folio_mark_uptodate(folio); + folio_unlock(folio); goto out; } @@ -2136,14 +2137,14 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, */ if (bio && (!page_is_mergeable(F2FS_I_SB(inode), bio, *last_block_in_bio, block_nr) || - !f2fs_crypt_mergeable_bio(bio, inode, page->index, NULL))) { + !f2fs_crypt_mergeable_bio(bio, inode, index, NULL))) { submit_and_realloc: f2fs_submit_read_bio(F2FS_I_SB(inode), bio, DATA); bio = NULL; } if (bio == NULL) { bio = f2fs_grab_read_bio(inode, block_nr, nr_pages, - is_readahead ? REQ_RAHEAD : 0, page->index, + is_readahead ? REQ_RAHEAD : 0, index, false); if (IS_ERR(bio)) { ret = PTR_ERR(bio); @@ -2158,7 +2159,7 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, */ f2fs_wait_on_block_writeback(inode, block_nr); - if (bio_add_page(bio, page, blocksize, 0) < blocksize) + if (!bio_add_folio(bio, folio, blocksize, 0)) goto submit_and_realloc; inc_page_count(F2FS_I_SB(inode), F2FS_RD_DATA); @@ -2423,7 +2424,7 @@ static int f2fs_mpage_readpages(struct inode *inode, goto next_page; read_single_page: #endif - ret = f2fs_read_single_page(inode, &folio->page, max_nr_pages, &map, + ret = f2fs_read_single_page(inode, folio, max_nr_pages, &map, &bio, &last_block_in_bio, rac); if (ret) { #ifdef CONFIG_F2FS_FS_COMPRESSION From patchwork Mon Apr 22 06:24:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13637670 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 8D39DC05023 for ; Mon, 22 Apr 2024 06:24:44 +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 1ryn6Z-0002pE-3U; Mon, 22 Apr 2024 06:24:43 +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 1ryn6X-0002or-CW for linux-f2fs-devel@lists.sourceforge.net; Mon, 22 Apr 2024 06:24:42 +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=GqKHo9vj3kW+OejD6Vb7XSRx5gWKjv2wnKG3AT8wi3A=; b=QnW+iXdFv/7lQm83VvQLXwAaor SahYj1H9sTPLwav16fI1j9UdT1hSdOQEQxCLTiGpKmlPnDRWY7dlJFB3MM4bvHYm69yNxG8QPdhHH m5aCC0yUTUHr/BLD8Y+KEl3pv+dv2z9/Xp+mUDJirtM4z9Gi4e4CixthP+Fm1JpoDKBA=; 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=GqKHo9vj3kW+OejD6Vb7XSRx5gWKjv2wnKG3AT8wi3A=; b=L45zGpRfUn+qaYowPV1H5UvqI4 QkqX2Js3ik6oxOb226CCX8sgaNbKH7AndbrggTQyU09458SSqEI3oaETz5yiGzCs4cAodGvDTtwVA NOSmkhVF7Q7ttr0woPSGE62lHPZ0CZtMKkaXpmNT9ltlomP7WhUkt8XBrJin+OQjBoFQ=; 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 1ryn6W-0003dy-DB for linux-f2fs-devel@lists.sourceforge.net; Mon, 22 Apr 2024 06:24:42 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id D0108CE09CF for ; Mon, 22 Apr 2024 06:24:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20368C116B1; Mon, 22 Apr 2024 06:24:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713767068; bh=UXeIomZemy3zpwCifF52rGb5bBATrGJrCt/HKWLMLTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lj9OYEaMDXoPMSLnwW+EthLhggh6OLYI0H7Wx+wX8nEYzdBr9KeJ//zH5vH7aZ3Sv r8xKSNcBAFu6aPb7sPOKhbCAzVcr67SF56r/uslbrgMcofbPdMKKa1kH1Hfbx1kBeo zlXX/CiRQ1W7NeLIVV2GnxjLTjKLDM2U3/e3fatrilSSzQ1l8g3MlYwAGfQ+H7HUi2 +juMOG1PgE+l/u5l7RlOSk95rvEQiTGYV/YxMG8guEmOAMAjbQknADRIAGBpwESKZ4 +Gs34/HLkyxgifPR5Le4I8w33lOvFTva/+taiDhZw1mEpWElkTszx1mcwYL13rVGhD dh1dk/+uaTT6Q== From: Chao Yu To: jaegeuk@kernel.org Date: Mon, 22 Apr 2024 14:24:16 +0800 Message-Id: <20240422062417.2421616-3-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240422062417.2421616-1-chao@kernel.org> References: <20240422062417.2421616-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1ryn6W-0003dy-DB Subject: [f2fs-dev] [PATCH v2 3/4] f2fs: convert f2fs_read_inline_data() to use folio 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 Convert f2fs_read_inline_data() to use folio and related functionality, and also convert its caller to use folio. Signed-off-by: Chao Yu --- v2: - no change. fs/f2fs/data.c | 11 +++++------ fs/f2fs/f2fs.h | 4 ++-- fs/f2fs/inline.c | 34 +++++++++++++++++----------------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index bb6c0e955d7e..24f9a39ffd56 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2457,20 +2457,19 @@ static int f2fs_mpage_readpages(struct inode *inode, static int f2fs_read_data_folio(struct file *file, struct folio *folio) { - struct page *page = &folio->page; - struct inode *inode = page_file_mapping(page)->host; + struct inode *inode = folio_file_mapping(folio)->host; int ret = -EAGAIN; - trace_f2fs_readpage(page, DATA); + trace_f2fs_readpage(&folio->page, DATA); if (!f2fs_is_compress_backend_ready(inode)) { - unlock_page(page); + folio_unlock(folio); return -EOPNOTSUPP; } /* If the file has inline data, try to read it directly */ if (f2fs_has_inline_data(inode)) - ret = f2fs_read_inline_data(inode, page); + ret = f2fs_read_inline_data(inode, folio); if (ret == -EAGAIN) ret = f2fs_mpage_readpages(inode, NULL, folio); return ret; @@ -3399,7 +3398,7 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi, if (f2fs_has_inline_data(inode)) { if (pos + len <= MAX_INLINE_DATA(inode)) { - f2fs_do_read_inline_data(page, ipage); + f2fs_do_read_inline_data(page_folio(page), ipage); set_inode_flag(inode, FI_DATA_EXIST); if (inode->i_nlink) set_page_private_inline(ipage); diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 3f7196122574..a0ae99bcca39 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4154,10 +4154,10 @@ extern struct kmem_cache *f2fs_inode_entry_slab; bool f2fs_may_inline_data(struct inode *inode); bool f2fs_sanity_check_inline_data(struct inode *inode); bool f2fs_may_inline_dentry(struct inode *inode); -void f2fs_do_read_inline_data(struct page *page, struct page *ipage); +void f2fs_do_read_inline_data(struct folio *folio, struct page *ipage); void f2fs_truncate_inline_inode(struct inode *inode, struct page *ipage, u64 from); -int f2fs_read_inline_data(struct inode *inode, struct page *page); +int f2fs_read_inline_data(struct inode *inode, struct folio *folio); int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page); int f2fs_convert_inline_inode(struct inode *inode); int f2fs_try_convert_inline_dir(struct inode *dir, struct dentry *dentry); diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c index 3d3218a4b29d..7638d0d7b7ee 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c @@ -61,22 +61,22 @@ bool f2fs_may_inline_dentry(struct inode *inode) return true; } -void f2fs_do_read_inline_data(struct page *page, struct page *ipage) +void f2fs_do_read_inline_data(struct folio *folio, struct page *ipage) { - struct inode *inode = page->mapping->host; + struct inode *inode = folio_file_mapping(folio)->host; - if (PageUptodate(page)) + if (folio_test_uptodate(folio)) return; - f2fs_bug_on(F2FS_P_SB(page), page->index); + f2fs_bug_on(F2FS_I_SB(inode), folio_index(folio)); - zero_user_segment(page, MAX_INLINE_DATA(inode), PAGE_SIZE); + folio_zero_segment(folio, MAX_INLINE_DATA(inode), folio_size(folio)); /* Copy the whole inline data block */ - memcpy_to_page(page, 0, inline_data_addr(inode, ipage), + memcpy_to_folio(folio, 0, inline_data_addr(inode, ipage), MAX_INLINE_DATA(inode)); - if (!PageUptodate(page)) - SetPageUptodate(page); + if (!folio_test_uptodate(folio)) + folio_mark_uptodate(folio); } void f2fs_truncate_inline_inode(struct inode *inode, @@ -97,13 +97,13 @@ void f2fs_truncate_inline_inode(struct inode *inode, clear_inode_flag(inode, FI_DATA_EXIST); } -int f2fs_read_inline_data(struct inode *inode, struct page *page) +int f2fs_read_inline_data(struct inode *inode, struct folio *folio) { struct page *ipage; ipage = f2fs_get_node_page(F2FS_I_SB(inode), inode->i_ino); if (IS_ERR(ipage)) { - unlock_page(page); + folio_unlock(folio); return PTR_ERR(ipage); } @@ -112,15 +112,15 @@ int f2fs_read_inline_data(struct inode *inode, struct page *page) return -EAGAIN; } - if (page->index) - zero_user_segment(page, 0, PAGE_SIZE); + if (folio_index(folio)) + folio_zero_segment(folio, 0, folio_size(folio)); else - f2fs_do_read_inline_data(page, ipage); + f2fs_do_read_inline_data(folio, ipage); - if (!PageUptodate(page)) - SetPageUptodate(page); + if (!folio_test_uptodate(folio)) + folio_mark_uptodate(folio); f2fs_put_page(ipage, 1); - unlock_page(page); + folio_unlock(folio); return 0; } @@ -166,7 +166,7 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page) f2fs_bug_on(F2FS_P_SB(page), folio_test_writeback(page_folio(page))); - f2fs_do_read_inline_data(page, dn->inode_page); + f2fs_do_read_inline_data(page_folio(page), dn->inode_page); set_page_dirty(page); /* clear dirty state */ From patchwork Mon Apr 22 06:24:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13637669 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 0530CC4345F for ; Mon, 22 Apr 2024 06:24:44 +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 1ryn6Y-0007iF-Rj; Mon, 22 Apr 2024 06:24:43 +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 1ryn6U-0007i4-71 for linux-f2fs-devel@lists.sourceforge.net; Mon, 22 Apr 2024 06:24:38 +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=BpKLwF+Fb+l/RtCr9J2Nldy2Ln7wvLwcX88TaHDTTds=; b=ifMZmAMIO3fT04pYfh/nxruH6o ogfHcDjh4TsiefAGkkUw3XDZ+pAuJexgqXThzlOn+8JIHKy/gpflUcc4gvKEHR2FkE4KeXHD953Ty TSIWaOJtTiDvMQAzNt5jadojMLBfSS1ehdI/Y1Ss+iCZOClHmlwAwHD9MrgJPl42Xjok=; 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=BpKLwF+Fb+l/RtCr9J2Nldy2Ln7wvLwcX88TaHDTTds=; b=CMEjhGFSOSJl65G7WIMrnP3PHh Wgj/ajfLYZCGa+uLLEKRTWPQLsQkDhkhHEeP98EuXvEbiYS2+yPRLeF+RpCRyOiUQoiLpKbqzzx1u wJVGc4MNonV5QgQNNOR4ZKjFAhXLw9odaBKP0dBZNz5XAVTcAgJuthIG0RRUEFk6SSbA=; 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 1ryn6S-0003dj-Ov for linux-f2fs-devel@lists.sourceforge.net; Mon, 22 Apr 2024 06:24:38 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 953C5CE0A48 for ; Mon, 22 Apr 2024 06:24:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E93ABC2BD11; Mon, 22 Apr 2024 06:24:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713767070; bh=HuVjVZ6RRiLFQGFS0GihV94ntmz3batSIusPOiVW4t4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fOhzCanV+6czMu++OWThyb2BTreGgvNYbvY3iaw6oRWSINrjZVmr8apXaVRhiwbSh sfmhC/k6l+QrBWkvLyTNku2s0FT6xzXAG8lMmn3vijbSAWEqfPui1Fhlh1xHqhn3Vl 1qy+eM5resmmwPp8JZlrA60nc05zqdlWPbcJ5vsVWBKFzA2h7TNKFJJAUudbLFxwhE 5Or+x22l8mEOUrqP4cCTVGKDEqO8lccNZOvRvH3tKhrhpiJqP8LH0BVZtiyUu8urWE cJtmfu+MslzOK/bxusEogKhrtyKeE3rpFlhYozZYY0LJ5xjLYn4rTlihgOpW5z10iK 2OC0RkyPnLIIw== From: Chao Yu To: jaegeuk@kernel.org Date: Mon, 22 Apr 2024 14:24:17 +0800 Message-Id: <20240422062417.2421616-4-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240422062417.2421616-1-chao@kernel.org> References: <20240422062417.2421616-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1ryn6S-0003dj-Ov Subject: [f2fs-dev] [PATCH v2 4/4] f2fs: convert f2fs__page tracepoint class to use folio 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 Convert f2fs__page tracepoint class() and its instances to use folio and related functionality, and rename it to f2fs__folio(). Signed-off-by: Chao Yu --- v2: - no change. fs/f2fs/checkpoint.c | 4 ++-- fs/f2fs/data.c | 10 ++++----- fs/f2fs/node.c | 4 ++-- include/trace/events/f2fs.h | 42 ++++++++++++++++++------------------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index eac698b8dd38..5d05a413f451 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -345,7 +345,7 @@ static int __f2fs_write_meta_page(struct page *page, { struct f2fs_sb_info *sbi = F2FS_P_SB(page); - trace_f2fs_writepage(page, META); + trace_f2fs_writepage(page_folio(page), META); if (unlikely(f2fs_cp_error(sbi))) { if (is_sbi_flag_set(sbi, SBI_IS_CLOSE)) { @@ -492,7 +492,7 @@ long f2fs_sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type, static bool f2fs_dirty_meta_folio(struct address_space *mapping, struct folio *folio) { - trace_f2fs_set_page_dirty(&folio->page, META); + trace_f2fs_set_page_dirty(folio, META); if (!folio_test_uptodate(folio)) folio_mark_uptodate(folio); diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 24f9a39ffd56..21d4c1c9b25b 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2460,7 +2460,7 @@ static int f2fs_read_data_folio(struct file *file, struct folio *folio) struct inode *inode = folio_file_mapping(folio)->host; int ret = -EAGAIN; - trace_f2fs_readpage(&folio->page, DATA); + trace_f2fs_readpage(folio, DATA); if (!f2fs_is_compress_backend_ready(inode)) { folio_unlock(folio); @@ -2709,7 +2709,7 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio) } else { set_inode_flag(inode, FI_UPDATE_WRITE); } - trace_f2fs_do_write_data_page(fio->page, IPU); + trace_f2fs_do_write_data_page(page_folio(page), IPU); return err; } @@ -2738,7 +2738,7 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio) /* LFS mode write path */ f2fs_outplace_write_data(&dn, fio); - trace_f2fs_do_write_data_page(page, OPU); + trace_f2fs_do_write_data_page(page_folio(page), OPU); set_inode_flag(inode, FI_APPEND_WRITE); out_writepage: f2fs_put_dnode(&dn); @@ -2785,7 +2785,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, .last_block = last_block, }; - trace_f2fs_writepage(page, DATA); + trace_f2fs_writepage(page_folio(page), DATA); /* we should bypass data pages to proceed the kworker jobs */ if (unlikely(f2fs_cp_error(sbi))) { @@ -3759,7 +3759,7 @@ static bool f2fs_dirty_data_folio(struct address_space *mapping, { struct inode *inode = mapping->host; - trace_f2fs_set_page_dirty(&folio->page, DATA); + trace_f2fs_set_page_dirty(folio, DATA); if (!folio_test_uptodate(folio)) folio_mark_uptodate(folio); diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 3b9eb5693683..95cecf08cb37 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1624,7 +1624,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, }; unsigned int seq; - trace_f2fs_writepage(page, NODE); + trace_f2fs_writepage(page_folio(page), NODE); if (unlikely(f2fs_cp_error(sbi))) { /* keep node pages in remount-ro mode */ @@ -2171,7 +2171,7 @@ static int f2fs_write_node_pages(struct address_space *mapping, static bool f2fs_dirty_node_folio(struct address_space *mapping, struct folio *folio) { - trace_f2fs_set_page_dirty(&folio->page, NODE); + trace_f2fs_set_page_dirty(folio, NODE); if (!folio_test_uptodate(folio)) folio_mark_uptodate(folio); diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h index 7ed0fc430dc6..371ba28415f5 100644 --- a/include/trace/events/f2fs.h +++ b/include/trace/events/f2fs.h @@ -1304,11 +1304,11 @@ TRACE_EVENT(f2fs_write_end, __entry->copied) ); -DECLARE_EVENT_CLASS(f2fs__page, +DECLARE_EVENT_CLASS(f2fs__folio, - TP_PROTO(struct page *page, int type), + TP_PROTO(struct folio *folio, int type), - TP_ARGS(page, type), + TP_ARGS(folio, type), TP_STRUCT__entry( __field(dev_t, dev) @@ -1321,14 +1321,14 @@ DECLARE_EVENT_CLASS(f2fs__page, ), TP_fast_assign( - __entry->dev = page_file_mapping(page)->host->i_sb->s_dev; - __entry->ino = page_file_mapping(page)->host->i_ino; + __entry->dev = folio_file_mapping(folio)->host->i_sb->s_dev; + __entry->ino = folio_file_mapping(folio)->host->i_ino; __entry->type = type; __entry->dir = - S_ISDIR(page_file_mapping(page)->host->i_mode); - __entry->index = page->index; - __entry->dirty = PageDirty(page); - __entry->uptodate = PageUptodate(page); + S_ISDIR(folio_file_mapping(folio)->host->i_mode); + __entry->index = folio_index(folio); + __entry->dirty = folio_test_dirty(folio); + __entry->uptodate = folio_test_uptodate(folio); ), TP_printk("dev = (%d,%d), ino = %lu, %s, %s, index = %lu, " @@ -1341,32 +1341,32 @@ DECLARE_EVENT_CLASS(f2fs__page, __entry->uptodate) ); -DEFINE_EVENT(f2fs__page, f2fs_writepage, +DEFINE_EVENT(f2fs__folio, f2fs_writepage, - TP_PROTO(struct page *page, int type), + TP_PROTO(struct folio *folio, int type), - TP_ARGS(page, type) + TP_ARGS(folio, type) ); -DEFINE_EVENT(f2fs__page, f2fs_do_write_data_page, +DEFINE_EVENT(f2fs__folio, f2fs_do_write_data_page, - TP_PROTO(struct page *page, int type), + TP_PROTO(struct folio *folio, int type), - TP_ARGS(page, type) + TP_ARGS(folio, type) ); -DEFINE_EVENT(f2fs__page, f2fs_readpage, +DEFINE_EVENT(f2fs__folio, f2fs_readpage, - TP_PROTO(struct page *page, int type), + TP_PROTO(struct folio *folio, int type), - TP_ARGS(page, type) + TP_ARGS(folio, type) ); -DEFINE_EVENT(f2fs__page, f2fs_set_page_dirty, +DEFINE_EVENT(f2fs__folio, f2fs_set_page_dirty, - TP_PROTO(struct page *page, int type), + TP_PROTO(struct folio *folio, int type), - TP_ARGS(page, type) + TP_ARGS(folio, type) ); TRACE_EVENT(f2fs_replace_atomic_write_block,