Skip to content

Commit b2f57a8

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: compress: delay temp page allocation
Currently, we allocate temp pages which is used to pad hole in cluster during read IO submission, it may take long time before releasing them in f2fs_decompress_pages(), since they are only used as temp output buffer in decompression context, so let's just do the allocation in that context to reduce time of memory pool resource occupation. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 944dd22 commit b2f57a8

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

fs/f2fs/compress.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ void f2fs_decompress_pages(struct bio *bio, struct page *page, bool verity)
670670
const struct f2fs_compress_ops *cops =
671671
f2fs_cops[fi->i_compress_algorithm];
672672
int ret;
673+
int i;
673674

674675
dec_page_count(sbi, F2FS_RD_DATA);
675676

@@ -688,6 +689,26 @@ void f2fs_decompress_pages(struct bio *bio, struct page *page, bool verity)
688689
goto out_free_dic;
689690
}
690691

692+
dic->tpages = f2fs_kzalloc(sbi, sizeof(struct page *) *
693+
dic->cluster_size, GFP_NOFS);
694+
if (!dic->tpages) {
695+
ret = -ENOMEM;
696+
goto out_free_dic;
697+
}
698+
699+
for (i = 0; i < dic->cluster_size; i++) {
700+
if (dic->rpages[i]) {
701+
dic->tpages[i] = dic->rpages[i];
702+
continue;
703+
}
704+
705+
dic->tpages[i] = f2fs_compress_alloc_page();
706+
if (!dic->tpages[i]) {
707+
ret = -ENOMEM;
708+
goto out_free_dic;
709+
}
710+
}
711+
691712
if (cops->init_decompress_ctx) {
692713
ret = cops->init_decompress_ctx(dic);
693714
if (ret)
@@ -1449,22 +1470,6 @@ struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc)
14491470
dic->cpages[i] = page;
14501471
}
14511472

1452-
dic->tpages = f2fs_kzalloc(sbi, sizeof(struct page *) *
1453-
dic->cluster_size, GFP_NOFS);
1454-
if (!dic->tpages)
1455-
goto out_free;
1456-
1457-
for (i = 0; i < dic->cluster_size; i++) {
1458-
if (cc->rpages[i]) {
1459-
dic->tpages[i] = cc->rpages[i];
1460-
continue;
1461-
}
1462-
1463-
dic->tpages[i] = f2fs_compress_alloc_page();
1464-
if (!dic->tpages[i])
1465-
goto out_free;
1466-
}
1467-
14681473
return dic;
14691474

14701475
out_free:

0 commit comments

Comments
 (0)