From patchwork Tue Aug 13 14:13:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13762104 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 CD8FBC52D7C for ; Tue, 13 Aug 2024 14:14:08 +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 1sdsHo-0001LC-Dk; Tue, 13 Aug 2024 14:14:08 +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 1sdsHk-0001Kg-Hg for linux-f2fs-devel@lists.sourceforge.net; Tue, 13 Aug 2024 14:14:04 +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=aKA/ZZ3O8Z+6nCg36uZ9SadppOXjFaBHpqnT40tFc/k=; b=UYYCoZKCRDncVWIyb/+I4sh6Ru +sgbe2j8LKuSqP8VOr6aFyqW0IRuIsRPdrL1H0584C6oZkbTCnB9DA5nB+AqR78FazJs0wNXHKgI6 CMLl3ECXs4ZCAASQnBfVzrgPxqwGFTX2tmO1BZKEmUZ11WXza3MZhXUzpZrhyr28SKws=; 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=aKA/ZZ3O8Z+6nCg36uZ9SadppOXjFaBHpqnT40tFc/k=; b=De+LFRUMQcbdarGW2BGxcEMBwh JMZS64w2qeC7hKmIotoKbh8ZaNSgemf4y+B5d47noqvOV/EtsHdQqcfZIKc73qcvGkZLGwRIa6GLO 436XNPA0QXf1GFF7feiHXWO1R4RdKYWhtr5Aqd3bEcmnpJ0HvlLE3Af2z4WQ2wRh0L+w=; 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 1sdsHj-0001D5-R3 for linux-f2fs-devel@lists.sourceforge.net; Tue, 13 Aug 2024 14:14:04 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7D2E361726; Tue, 13 Aug 2024 14:13:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D559CC4AF0B; Tue, 13 Aug 2024 14:13:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723558438; bh=5T499NbgrjKr5NOj5StQGgnVfYV5k+BMGIi5VEOc7AU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EpS+8sNg/0fjtUqjjEU21HwpPd1cVu3aEWiOVNVS6pXd87OhjQlLc2OjCXW4Z/qOC CMui+djcxR8+17IaMN3S1g/nnlIEu/2OMbeEDLIFqsb38mCsaKE0BT1tsGvbm1g5dI I2hG+3ecJsm+Q6Oc9JkJeBXKGednlRW6hsQqbzF95oF1k3QcYQ/OxyJYpjTvMDapWq 6arnDIddQiw4lng0uDwIlQIH16LMkeYPqEXCK2sSB+2OqHjoatR9rhnDcOXo6rB+bW 3oYsk2yOWwXYyPa49ge+ahGv4R45qYQ8ky4bGSTgYeqd7dF6+cTZcPrAsEQ/jdWX2L gICkksTrwlR/w== From: Chao Yu To: jaegeuk@kernel.org Date: Tue, 13 Aug 2024 22:13:30 +0800 Message-Id: <20240813141331.417067-8-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240813141331.417067-1-chao@kernel.org> References: <20240813141331.417067-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1sdsHj-0001D5-R3 Subject: [f2fs-dev] [PATCH 8/9] f2fs: convert f2fs_read_multi_pages() 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, Matthew Wilcox , linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Convert to use folio, so that we can get rid of 'page->index' to prepare for removal of 'index' field in structure page [1]. [1] https://lore.kernel.org/all/Zp8fgUSIBGQ1TN0D@casper.infradead.org/ Cc: Matthew Wilcox Signed-off-by: Chao Yu --- fs/f2fs/data.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 0779e222f709..9e21cfe11cc7 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2207,19 +2207,22 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, /* get rid of pages beyond EOF */ for (i = 0; i < cc->cluster_size; i++) { struct page *page = cc->rpages[i]; + struct folio *folio; if (!page) continue; - if ((sector_t)page->index >= last_block_in_file) { - zero_user_segment(page, 0, PAGE_SIZE); - if (!PageUptodate(page)) - SetPageUptodate(page); - } else if (!PageUptodate(page)) { + + folio = page_folio(page); + if ((sector_t)folio->index >= last_block_in_file) { + folio_zero_segment(folio, 0, folio_size(folio)); + if (!folio_test_uptodate(folio)) + folio_mark_uptodate(folio); + } else if (!folio_test_uptodate(folio)) { continue; } - unlock_page(page); + folio_unlock(folio); if (for_write) - put_page(page); + folio_put(folio); cc->rpages[i] = NULL; cc->nr_rpages--; } @@ -2279,7 +2282,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, } for (i = 0; i < cc->nr_cpages; i++) { - struct page *page = dic->cpages[i]; + struct folio *folio = page_folio(dic->cpages[i]); block_t blkaddr; struct bio_post_read_ctx *ctx; @@ -2289,7 +2292,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, f2fs_wait_on_block_writeback(inode, blkaddr); - if (f2fs_load_compressed_page(sbi, page, blkaddr)) { + if (f2fs_load_compressed_page(sbi, folio_page(folio, 0), + blkaddr)) { if (atomic_dec_and_test(&dic->remaining_pages)) { f2fs_decompress_cluster(dic, true); break; @@ -2299,7 +2303,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, if (bio && (!page_is_mergeable(sbi, bio, *last_block_in_bio, blkaddr) || - !f2fs_crypt_mergeable_bio(bio, inode, page->index, NULL))) { + !f2fs_crypt_mergeable_bio(bio, inode, folio->index, NULL))) { submit_and_realloc: f2fs_submit_read_bio(sbi, bio, DATA); bio = NULL; @@ -2308,7 +2312,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, if (!bio) { bio = f2fs_grab_read_bio(inode, blkaddr, nr_pages, f2fs_ra_op_flags(rac), - page->index, for_write); + folio->index, for_write); if (IS_ERR(bio)) { ret = PTR_ERR(bio); f2fs_decompress_end_io(dic, ret, true); @@ -2318,7 +2322,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, } } - if (bio_add_page(bio, page, blocksize, 0) < blocksize) + if (bio_add_folio(bio, folio, blocksize, 0) < blocksize) goto submit_and_realloc; ctx = get_post_read_ctx(bio);