Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2063553lqt; Sun, 21 Apr 2024 23:24:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWc8kmA8YEH9DGiwu7DuyTo0gUjmJY0smuRfIa3qeLNrrLO93i9v6g6G2WitmJcbVrMfYezu7cVzlYMWSTdKSV53qRHf4X30Y0ClTiwRQ== X-Google-Smtp-Source: AGHT+IG/XcZedVlmMQGeUssYiFibhPPzgXZt4KvfAyz9vxQhriveB0rOj8ivn38o/JKVkiJYfmk6 X-Received: by 2002:a50:c30d:0:b0:56e:6d9:7bd6 with SMTP id a13-20020a50c30d000000b0056e06d97bd6mr5898273edb.34.1713767091585; Sun, 21 Apr 2024 23:24:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713767091; cv=pass; d=google.com; s=arc-20160816; b=eR+JoYEOf1C6opI70whQm/+lztHIpM5YV37EXnFDSjwVTRyfU+Q5HCN7fqtdAtsWLH Gj9wGldf64kM0reQ8y1OljRnwdW86fqG5Uvuo1CvPl480cjbAx1nmZ4ti2JYuRhZV1gZ nHrrK6pVyyXLHQWToaLHSNn546KN8W8UCYjWiD4LuHyvpWxNt0nnikM8fRLBIo/3ENdS mrxZl70fqnj1eJ57RJVSbz7Q3Un2MS4GV3fNu+HyjJnhGbyRTZGyrYiyghQS5xdjJgpo OZqYhwbHhS7kXxLkRfxY+jil53iYeLYcQiME0QAdBLO/agRqqoNJMKrfISl8xDDdz05+ oGeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=k/FRz+hMLSVMIRaJ6shy9/XVHMVYO5eOzEO0+HjW35s=; fh=X1/oBJvTGJUQ0YtRp03u+3tPfRw/dXXALWynfOSlfQQ=; b=TbsvoAH1Ftg0BjoumBK3tnO41YQNF1PJncAgCUYGvxbtVNw97rmZ60PlHpIGKtQwNS oOvkmgk9oBuDX5KIDDiRBRQSsuBXVR07ZP35zl/E/d+Ez96oxTgnlmb0YcmPg8atFYoD QBRskl9XQqxYGQbH67ud0J3+Gu09HxzEQZ1RST27Bk6kLQ9gUy3ZPlyfC7KO5H/2ul7p JX8s5aNZMC/IDtO/FcPLgwROU/Sy7nTKGObz408aOnNnYcIsHIhkxFMUfvzHbH8NlQ2y aMk3IDCl2HJOLgTBMIDLuZdRXlkjvZmBjYX4bQyRMAAUBQyzZwU2LXRsM2w/UCj0RCPX IQqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LcaS7Aqb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-152781-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152781-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e25-20020a50d4d9000000b00571d1ed05cbsi4360294edj.314.2024.04.21.23.24.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Apr 2024 23:24:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152781-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LcaS7Aqb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-152781-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152781-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 524A71F22192 for ; Mon, 22 Apr 2024 06:24:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A82AB446DC; Mon, 22 Apr 2024 06:24:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LcaS7Aqb" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C275443ACE for ; Mon, 22 Apr 2024 06:24:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713767066; cv=none; b=g7ADro3Ike8aXhs962wviOC+Kx3N+CDoUG70rhHF1d2jNkOClkBwU+kdUAnUnqBGGR9qYzqC85pD2B6QdsLhKFdKNRDJLhlLXUDQIgcxtpYlagSH7farJifeOvbwIbGZRpuPp1Y9oO2HjCm7fcAsOD12S31esCGsjOmH1K2ZOk4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713767066; c=relaxed/simple; bh=lq61WtOlYIOBoAAF9mgYkGC8E+tMVi57Ql/mXCqncQg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IlsMB8nnOnDgvevKA4b+20WRCuDnUiksqnZpjJrxeCrMllKvtFdVcy3CEY894x71bVzIEN9mQKn4vdg8JB5p7Sv+HsTTClIaALpKosGN+RrtVSPucJmJAF2Rd7ZqIDBoUU+bxfDREtSXhKc5QsYlxrJicMr7MJB3cFIqROnMSOQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LcaS7Aqb; arc=none smtp.client-ip=10.30.226.201 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 Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH v2 2/4] f2fs: convert f2fs_read_single_page() to use folio 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 -- 2.40.1