Skip to content

Commit 01fc4b9

Browse files
poluoJaegeuk Kim
authored andcommitted
f2fs: use onstack pages instead of pvec
Since pvec have 15 pages, it not a multiple of 4, when write compressed pages, write in 64K as a unit, it will call pagevec_lookup_range_tag agagin, sometimes this will take a lot of time. Use onstack pages instead of pvec to mitigate this problem. Signed-off-by: Fengnan Chang <fengnanchang@gmail.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 4f8219f commit 01fc4b9

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

fs/f2fs/compress.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,10 @@ bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index)
841841
return is_page_in_cluster(cc, index);
842842
}
843843

844-
bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct pagevec *pvec,
844+
bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages,
845845
int index, int nr_pages, bool uptodate)
846846
{
847-
unsigned long pgidx = pvec->pages[index]->index;
847+
unsigned long pgidx = pages[index]->index;
848848
int i = uptodate ? 0 : 1;
849849

850850
/*
@@ -858,9 +858,9 @@ bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct pagevec *pvec,
858858
return false;
859859

860860
for (; i < cc->cluster_size; i++) {
861-
if (pvec->pages[index + i]->index != pgidx + i)
861+
if (pages[index + i]->index != pgidx + i)
862862
return false;
863-
if (uptodate && !PageUptodate(pvec->pages[index + i]))
863+
if (uptodate && !PageUptodate(pages[index + i]))
864864
return false;
865865
}
866866

fs/f2fs/data.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,7 +2916,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
29162916
{
29172917
int ret = 0;
29182918
int done = 0, retry = 0;
2919-
struct pagevec pvec;
2919+
struct page *pages[F2FS_ONSTACK_PAGES];
29202920
struct f2fs_sb_info *sbi = F2FS_M_SB(mapping);
29212921
struct bio *bio = NULL;
29222922
sector_t last_block;
@@ -2947,8 +2947,6 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
29472947
int submitted = 0;
29482948
int i;
29492949

2950-
pagevec_init(&pvec);
2951-
29522950
if (get_dirty_pages(mapping->host) <=
29532951
SM_I(F2FS_M_SB(mapping))->min_hot_blocks)
29542952
set_inode_flag(mapping->host, FI_HOT_DATA);
@@ -2974,13 +2972,13 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
29742972
tag_pages_for_writeback(mapping, index, end);
29752973
done_index = index;
29762974
while (!done && !retry && (index <= end)) {
2977-
nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end,
2978-
tag);
2975+
nr_pages = find_get_pages_range_tag(mapping, &index, end,
2976+
tag, F2FS_ONSTACK_PAGES, pages);
29792977
if (nr_pages == 0)
29802978
break;
29812979

29822980
for (i = 0; i < nr_pages; i++) {
2983-
struct page *page = pvec.pages[i];
2981+
struct page *page = pages[i];
29842982
bool need_readd;
29852983
readd:
29862984
need_readd = false;
@@ -3012,7 +3010,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
30123010
goto lock_page;
30133011

30143012
if (f2fs_all_cluster_page_ready(&cc,
3015-
&pvec, i, nr_pages, true))
3013+
pages, i, nr_pages, true))
30163014
goto lock_page;
30173015

30183016
ret2 = f2fs_prepare_compress_overwrite(
@@ -3026,7 +3024,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
30263024
(!f2fs_compress_write_end(inode,
30273025
fsdata, page->index, 1) ||
30283026
!f2fs_all_cluster_page_ready(&cc,
3029-
&pvec, i, nr_pages, false))) {
3027+
pages, i, nr_pages, false))) {
30303028
retry = 1;
30313029
break;
30323030
}
@@ -3116,7 +3114,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
31163114
if (need_readd)
31173115
goto readd;
31183116
}
3119-
pagevec_release(&pvec);
3117+
release_pages(pages, nr_pages);
31203118
cond_resched();
31213119
}
31223120
#ifdef CONFIG_F2FS_FS_COMPRESSION

fs/f2fs/f2fs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,8 @@ enum {
598598
#define RECOVERY_MAX_RA_BLOCKS BIO_MAX_VECS
599599
#define RECOVERY_MIN_RA_BLOCKS 1
600600

601+
#define F2FS_ONSTACK_PAGES 16 /* nr of onstack pages */
602+
601603
struct rb_entry {
602604
struct rb_node rb_node; /* rb node located in rb-tree */
603605
union {
@@ -4198,7 +4200,7 @@ void f2fs_end_read_compressed_page(struct page *page, bool failed,
41984200
block_t blkaddr, bool in_task);
41994201
bool f2fs_cluster_is_empty(struct compress_ctx *cc);
42004202
bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index);
4201-
bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct pagevec *pvec,
4203+
bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages,
42024204
int index, int nr_pages, bool uptodate);
42034205
bool f2fs_sanity_check_cluster(struct dnode_of_data *dn);
42044206
void f2fs_compress_ctx_add_page(struct compress_ctx *cc, struct page *page);

0 commit comments

Comments
 (0)