Skip to content

Commit 185f203

Browse files
mofishzzJaegeuk Kim
authored andcommitted
f2fs: avoid splitting bio when reading multiple pages
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. To handle this case, align max_nr_pages to cluster_size, which should be enough for all compressed pages. Signed-off-by: Jianan Huang <[email protected]> Signed-off-by: Sheng Yong <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent e23ab80 commit 185f203

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

fs/f2fs/data.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2303,7 +2303,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
23032303
}
23042304

23052305
if (!bio) {
2306-
bio = f2fs_grab_read_bio(inode, blkaddr, nr_pages,
2306+
bio = f2fs_grab_read_bio(inode, blkaddr, nr_pages - i,
23072307
f2fs_ra_op_flags(rac),
23082308
folio->index, for_write);
23092309
if (IS_ERR(bio)) {
@@ -2376,6 +2376,14 @@ static int f2fs_mpage_readpages(struct inode *inode,
23762376
unsigned max_nr_pages = nr_pages;
23772377
int ret = 0;
23782378

2379+
#ifdef CONFIG_F2FS_FS_COMPRESSION
2380+
if (f2fs_compressed_file(inode)) {
2381+
index = rac ? readahead_index(rac) : folio->index;
2382+
max_nr_pages = round_up(index + nr_pages, cc.cluster_size) -
2383+
round_down(index, cc.cluster_size);
2384+
}
2385+
#endif
2386+
23792387
map.m_pblk = 0;
23802388
map.m_lblk = 0;
23812389
map.m_len = 0;

0 commit comments

Comments
 (0)