Commit 01fc4b9a authored by Fengnan Chang's avatar Fengnan Chang Committed by Jaegeuk Kim

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: default avatarFengnan Chang <fengnanchang@gmail.com>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 4f8219f8
...@@ -841,10 +841,10 @@ bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index) ...@@ -841,10 +841,10 @@ bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index)
return is_page_in_cluster(cc, index); return is_page_in_cluster(cc, index);
} }
bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct pagevec *pvec, bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages,
int index, int nr_pages, bool uptodate) int index, int nr_pages, bool uptodate)
{ {
unsigned long pgidx = pvec->pages[index]->index; unsigned long pgidx = pages[index]->index;
int i = uptodate ? 0 : 1; int i = uptodate ? 0 : 1;
/* /*
...@@ -858,9 +858,9 @@ bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct pagevec *pvec, ...@@ -858,9 +858,9 @@ bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct pagevec *pvec,
return false; return false;
for (; i < cc->cluster_size; i++) { for (; i < cc->cluster_size; i++) {
if (pvec->pages[index + i]->index != pgidx + i) if (pages[index + i]->index != pgidx + i)
return false; return false;
if (uptodate && !PageUptodate(pvec->pages[index + i])) if (uptodate && !PageUptodate(pages[index + i]))
return false; return false;
} }
......
...@@ -2916,7 +2916,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, ...@@ -2916,7 +2916,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
{ {
int ret = 0; int ret = 0;
int done = 0, retry = 0; int done = 0, retry = 0;
struct pagevec pvec; struct page *pages[F2FS_ONSTACK_PAGES];
struct f2fs_sb_info *sbi = F2FS_M_SB(mapping); struct f2fs_sb_info *sbi = F2FS_M_SB(mapping);
struct bio *bio = NULL; struct bio *bio = NULL;
sector_t last_block; sector_t last_block;
...@@ -2947,8 +2947,6 @@ static int f2fs_write_cache_pages(struct address_space *mapping, ...@@ -2947,8 +2947,6 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
int submitted = 0; int submitted = 0;
int i; int i;
pagevec_init(&pvec);
if (get_dirty_pages(mapping->host) <= if (get_dirty_pages(mapping->host) <=
SM_I(F2FS_M_SB(mapping))->min_hot_blocks) SM_I(F2FS_M_SB(mapping))->min_hot_blocks)
set_inode_flag(mapping->host, FI_HOT_DATA); set_inode_flag(mapping->host, FI_HOT_DATA);
...@@ -2974,13 +2972,13 @@ static int f2fs_write_cache_pages(struct address_space *mapping, ...@@ -2974,13 +2972,13 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
tag_pages_for_writeback(mapping, index, end); tag_pages_for_writeback(mapping, index, end);
done_index = index; done_index = index;
while (!done && !retry && (index <= end)) { while (!done && !retry && (index <= end)) {
nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end, nr_pages = find_get_pages_range_tag(mapping, &index, end,
tag); tag, F2FS_ONSTACK_PAGES, pages);
if (nr_pages == 0) if (nr_pages == 0)
break; break;
for (i = 0; i < nr_pages; i++) { for (i = 0; i < nr_pages; i++) {
struct page *page = pvec.pages[i]; struct page *page = pages[i];
bool need_readd; bool need_readd;
readd: readd:
need_readd = false; need_readd = false;
...@@ -3012,7 +3010,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, ...@@ -3012,7 +3010,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
goto lock_page; goto lock_page;
if (f2fs_all_cluster_page_ready(&cc, if (f2fs_all_cluster_page_ready(&cc,
&pvec, i, nr_pages, true)) pages, i, nr_pages, true))
goto lock_page; goto lock_page;
ret2 = f2fs_prepare_compress_overwrite( ret2 = f2fs_prepare_compress_overwrite(
...@@ -3026,7 +3024,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, ...@@ -3026,7 +3024,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
(!f2fs_compress_write_end(inode, (!f2fs_compress_write_end(inode,
fsdata, page->index, 1) || fsdata, page->index, 1) ||
!f2fs_all_cluster_page_ready(&cc, !f2fs_all_cluster_page_ready(&cc,
&pvec, i, nr_pages, false))) { pages, i, nr_pages, false))) {
retry = 1; retry = 1;
break; break;
} }
...@@ -3116,7 +3114,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, ...@@ -3116,7 +3114,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
if (need_readd) if (need_readd)
goto readd; goto readd;
} }
pagevec_release(&pvec); release_pages(pages, nr_pages);
cond_resched(); cond_resched();
} }
#ifdef CONFIG_F2FS_FS_COMPRESSION #ifdef CONFIG_F2FS_FS_COMPRESSION
......
...@@ -598,6 +598,8 @@ enum { ...@@ -598,6 +598,8 @@ enum {
#define RECOVERY_MAX_RA_BLOCKS BIO_MAX_VECS #define RECOVERY_MAX_RA_BLOCKS BIO_MAX_VECS
#define RECOVERY_MIN_RA_BLOCKS 1 #define RECOVERY_MIN_RA_BLOCKS 1
#define F2FS_ONSTACK_PAGES 16 /* nr of onstack pages */
struct rb_entry { struct rb_entry {
struct rb_node rb_node; /* rb node located in rb-tree */ struct rb_node rb_node; /* rb node located in rb-tree */
union { union {
...@@ -4198,7 +4200,7 @@ void f2fs_end_read_compressed_page(struct page *page, bool failed, ...@@ -4198,7 +4200,7 @@ void f2fs_end_read_compressed_page(struct page *page, bool failed,
block_t blkaddr, bool in_task); block_t blkaddr, bool in_task);
bool f2fs_cluster_is_empty(struct compress_ctx *cc); bool f2fs_cluster_is_empty(struct compress_ctx *cc);
bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index); bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index);
bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct pagevec *pvec, bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages,
int index, int nr_pages, bool uptodate); int index, int nr_pages, bool uptodate);
bool f2fs_sanity_check_cluster(struct dnode_of_data *dn); bool f2fs_sanity_check_cluster(struct dnode_of_data *dn);
void f2fs_compress_ctx_add_page(struct compress_ctx *cc, struct page *page); void f2fs_compress_ctx_add_page(struct compress_ctx *cc, struct page *page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment