From: Fengnan Chang <fengnanchang@gmail.com>
To: jaegeuk@kernel.org, chao@kernel.org
Cc: Fengnan Chang <changfengnan@vivo.com>,
linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH v3 2/3] f2fs: use onstack pages instead of pvec
Date: Sun, 17 Jul 2022 13:32:06 +0800 [thread overview]
Message-ID: <20220717053207.192372-3-fengnanchang@gmail.com> (raw)
In-Reply-To: <20220717053207.192372-1-fengnanchang@gmail.com>
From: Fengnan Chang <changfengnan@vivo.com>
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 <changfengnan@vivo.com>
---
fs/f2fs/compress.c | 8 ++++----
fs/f2fs/data.c | 16 +++++++---------
fs/f2fs/f2fs.h | 4 +++-
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 28619d45b5c9..6dd7782546e9 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -871,7 +871,7 @@ 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;
@@ -887,12 +887,12 @@ bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct pagevec *pvec,
if (nr_pages - index < cc->cluster_size)
return false;
- pgidx = pvec->pages[index]->index;
+ pgidx = pages[index]->index;
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 022d0a8715c5..d2d2cfd54210 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2901,7 +2901,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;
@@ -2932,8 +2932,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);
@@ -2959,13 +2957,13 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
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;
@@ -2997,7 +2995,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
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(
@@ -3011,7 +3009,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
(!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;
}
@@ -3101,7 +3099,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
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 df07c15a5202..06d0370fd760 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -598,6 +598,8 @@ enum {
#define RECOVERY_MAX_RA_BLOCKS BIO_MAX_VECS
#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 {
@@ -4163,7 +4165,7 @@ void f2fs_end_read_compressed_page(struct page *page, bool failed,
block_t blkaddr);
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);
--
2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2022-07-17 5:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-17 5:32 [f2fs-dev] [PATCH v3 0/3] support compressed file write/read amplifiction Fengnan Chang
2022-07-17 5:32 ` [f2fs-dev] [PATCH v3 1/3] f2fs: intorduce f2fs_all_cluster_page_ready Fengnan Chang
2022-07-24 9:33 ` Chao Yu
2022-07-17 5:32 ` Fengnan Chang [this message]
2022-07-17 5:32 ` [f2fs-dev] [PATCH v3 3/3] f2fs: support compressed file write/read amplifiction Fengnan Chang
2022-07-24 9:58 ` Chao Yu
2022-07-25 13:00 ` fengnan chang
2022-07-24 9:36 ` [f2fs-dev] [PATCH v3 0/3] " Chao Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220717053207.192372-3-fengnanchang@gmail.com \
--to=fengnanchang@gmail.com \
--cc=changfengnan@vivo.com \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.