linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: avoid splitting bio when reading multiple pages
@ 2025-06-17  5:55 Jianan Huang via Linux-f2fs-devel
  2025-06-17 11:37 ` Chao Yu via Linux-f2fs-devel
  2025-06-18  8:17 ` [f2fs-dev] [PATCH v2] " Jianan Huang via Linux-f2fs-devel
  0 siblings, 2 replies; 8+ messages in thread
From: Jianan Huang via Linux-f2fs-devel @ 2025-06-17  5:55 UTC (permalink / raw)
  To: linux-f2fs-devel, chao, jaegeuk; +Cc: Sheng Yong, wanghui33

When fewer pages are read, nr_pages may be smaller than nr_cpages. Due
to the nr_vecs limit, the compressed pages will be split into multiple
bios and then merged at the block level. In this case, nr_cpages should
be used to pre-allocate bvecs.

Signed-off-by: Jianan Huang <huangjianan@xiaomi.com>
Signed-off-by: Sheng Yong <shengyong1@xiaomi.com>
---
 fs/f2fs/data.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 31e892842625..c7773b09d83f 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2303,7 +2303,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
 		}
 
 		if (!bio) {
-			bio = f2fs_grab_read_bio(inode, blkaddr, nr_pages,
+			bio = f2fs_grab_read_bio(inode, blkaddr,
+					max(nr_pages, cc->nr_cpages) - i,
 					f2fs_ra_op_flags(rac),
 					folio->index, for_write);
 			if (IS_ERR(bio)) {
@@ -2373,7 +2374,6 @@ static int f2fs_mpage_readpages(struct inode *inode,
 	pgoff_t index;
 #endif
 	unsigned nr_pages = rac ? readahead_count(rac) : 1;
-	unsigned max_nr_pages = nr_pages;
 	int ret = 0;
 
 	map.m_pblk = 0;
@@ -2400,7 +2400,7 @@ static int f2fs_mpage_readpages(struct inode *inode,
 		/* 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,
+						nr_pages,
 						&last_block_in_bio,
 						rac, false);
 			f2fs_destroy_compress_ctx(&cc, false);
@@ -2432,7 +2432,7 @@ static int f2fs_mpage_readpages(struct inode *inode,
 read_single_page:
 #endif
 
-		ret = f2fs_read_single_page(inode, folio, max_nr_pages, &map,
+		ret = f2fs_read_single_page(inode, folio, nr_pages, &map,
 					&bio, &last_block_in_bio, rac);
 		if (ret) {
 #ifdef CONFIG_F2FS_FS_COMPRESSION
@@ -2450,7 +2450,7 @@ static int f2fs_mpage_readpages(struct inode *inode,
 			/* last page */
 			if (nr_pages == 1 && !f2fs_cluster_is_empty(&cc)) {
 				ret = f2fs_read_multi_pages(&cc, &bio,
-							max_nr_pages,
+							nr_pages,
 							&last_block_in_bio,
 							rac, false);
 				f2fs_destroy_compress_ctx(&cc, false);
-- 
2.43.0



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-06-25  3:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17  5:55 [f2fs-dev] [PATCH] f2fs: avoid splitting bio when reading multiple pages Jianan Huang via Linux-f2fs-devel
2025-06-17 11:37 ` Chao Yu via Linux-f2fs-devel
2025-06-17 13:13   ` Sheng Yong
2025-06-17 13:43     ` [f2fs-dev] [External Mail]Re: " Huang Jianan via Linux-f2fs-devel
2025-06-24 13:56     ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-06-18  8:17 ` [f2fs-dev] [PATCH v2] " Jianan Huang via Linux-f2fs-devel
2025-06-25  3:05   ` Huang Jianan via Linux-f2fs-devel
2025-06-25  3:26   ` Chao Yu via Linux-f2fs-devel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).