aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFengnan Chang <fengnanchang@gmail.com>2022-07-31 11:33:46 +0800
committerJaegeuk Kim <jaegeuk@google.com>2022-08-05 04:27:13 -0700
commitf2e7caa837fcf91b1e1234468a931f15d6ab2a0a (patch)
treea574274982b48c50a37cf8d2bbca1d08138b614e
parent3ed4e7d2ab9e74781dc68c815f2243737af94dd4 (diff)
downloadf2fs-stable-linux-5.10.y-mainline.tar.gz
f2fs: use onstack pages instead of pvec6.0-rc1-5.10linux-5.10.y-mainline
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>
-rw-r--r--fs/f2fs/compress.c8
-rw-r--r--fs/f2fs/data.c16
-rw-r--r--fs/f2fs/f2fs.h4
3 files changed, 14 insertions, 14 deletions
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index a908f2a6ed809e..24f3a88071950c 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -840,10 +840,10 @@ bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t 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)
{
- unsigned long pgidx = pvec->pages[index]->index;
+ unsigned long pgidx = pages[index]->index;
int i = uptodate ? 0 : 1;
/*
@@ -857,9 +857,9 @@ bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct pagevec *pvec,
return false;
for (; i < cc->cluster_size; i++) {
- if (pvec->pages[index + i]->index != pgidx + i)
+ if (pages[index + i]->index != pgidx + i)
return false;
- if (uptodate && !PageUptodate(pvec->pages[index + i]))
+ if (uptodate && !PageUptodate(pages[index + i]))
return false;
}
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index c912315afa6202..e2c04241f7d73b 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2939,7 +2939,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
{
int ret = 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 bio *bio = NULL;
sector_t last_block;
@@ -2970,8 +2970,6 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
int submitted = 0;
int i;
- pagevec_init(&pvec);
-
if (get_dirty_pages(mapping->host) <=
SM_I(F2FS_M_SB(mapping))->min_hot_blocks)
set_inode_flag(mapping->host, FI_HOT_DATA);
@@ -2997,13 +2995,13 @@ retry:
tag_pages_for_writeback(mapping, index, end);
done_index = index;
while (!done && !retry && (index <= end)) {
- nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end,
- tag);
+ nr_pages = find_get_pages_range_tag(mapping, &index, end,
+ tag, F2FS_ONSTACK_PAGES, pages);
if (nr_pages == 0)
break;
for (i = 0; i < nr_pages; i++) {
- struct page *page = pvec.pages[i];
+ struct page *page = pages[i];
bool need_readd;
readd:
need_readd = false;
@@ -3035,7 +3033,7 @@ readd:
goto lock_page;
if (f2fs_all_cluster_page_ready(&cc,
- &pvec, i, nr_pages, true))
+ pages, i, nr_pages, true))
goto lock_page;
ret2 = f2fs_prepare_compress_overwrite(
@@ -3049,7 +3047,7 @@ readd:
(!f2fs_compress_write_end(inode,
fsdata, page->index, 1) ||
!f2fs_all_cluster_page_ready(&cc,
- &pvec, i, nr_pages, false))) {
+ pages, i, nr_pages, false))) {
retry = 1;
break;
}
@@ -3139,7 +3137,7 @@ next:
if (need_readd)
goto readd;
}
- pagevec_release(&pvec);
+ release_pages(pages, nr_pages);
cond_resched();
}
#ifdef CONFIG_F2FS_FS_COMPRESSION
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 1157beebcdcfd8..4a606faf99095f 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -595,6 +595,8 @@ enum {
#define RECOVERY_MAX_RA_BLOCKS BIO_MAX_PAGES
#define RECOVERY_MIN_RA_BLOCKS 1
+#define F2FS_ONSTACK_PAGES 16 /* nr of onstack pages */
+
struct rb_entry {
struct rb_node rb_node; /* rb node located in rb-tree */
union {
@@ -4197,7 +4199,7 @@ void f2fs_end_read_compressed_page(struct page *page, bool failed,
block_t blkaddr, bool in_task);
bool f2fs_cluster_is_empty(struct compress_ctx *cc);
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);
bool f2fs_sanity_check_cluster(struct dnode_of_data *dn);
void f2fs_compress_ctx_add_page(struct compress_ctx *cc, struct page *page);