On 2022/4/29 14:54, Fengnan Chang wrote:
Intorduce f2fs_all_cluster_page_uptodate, try to reduce call
f2fs_prepare_compress_overwrite.
Hmm... it's better to describe in which case newly introduced
function can improve performance...
Signed-off-by: Fengnan Chang <[email protected]>
---
fs/f2fs/compress.c | 23 ++++++++++++++++++++++-
fs/f2fs/data.c | 5 +++++
fs/f2fs/f2fs.h | 2 ++
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 12a56f9e1572..11499fd3dd6b 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -871,6 +871,28 @@ 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_uptodate(struct compress_ctx *cc, struct pagevec *pvec,
+ int index, int nr_pages)
Is it possible to merge f2fs_all_cluster_page_uptodate and
f2fs_all_cluster_page_loaded() into a common function, something like:
f2fs_all_cluster_page_ready(bool update)?
Thanks,
+{
+ unsigned long pgidx;
+ int i;
+
+ pgidx = pvec->pages[index]->index;
+ if (pgidx % cc->cluster_size)
+ return false;
+
+ if (nr_pages - index < cc->cluster_size)
+ return false;
+
+ for (i = 0; i < cc->cluster_size; i++) {
+ if (pvec->pages[index + i]->index != pgidx + i)
+ return false;
+ if (!PageUptodate(pvec->pages[index + i]))
+ return false;
+ }
+
+ return true;
+}
bool f2fs_all_cluster_page_loaded(struct compress_ctx *cc, struct pagevec
*pvec,
int index, int nr_pages)
{
@@ -881,7 +903,6 @@ bool f2fs_all_cluster_page_loaded(struct compress_ctx *cc,
struct pagevec *pvec,
return false;
pgidx = pvec->pages[index]->index;
-
for (i = 1; i < cc->cluster_size; i++) {
if (pvec->pages[index + i]->index != pgidx + i)
return false;
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 9a1a526f2092..b8204d91fed4 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2967,6 +2967,11 @@ static int f2fs_write_cache_pages(struct address_space
*mapping,
if (!f2fs_cluster_is_empty(&cc))
goto lock_page;
+ if (f2fs_all_cluster_page_uptodate(&cc,
+ &pvec, i, nr_pages)) {
+ goto lock_page;
+ }
+
ret2 = f2fs_prepare_compress_overwrite(
inode, &pagep,
page->index, &fsdata);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 38cbed0f544e..b4bed1e983bb 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -4180,6 +4180,8 @@ bool f2fs_cluster_can_merge_page(struct compress_ctx *cc,
pgoff_t index);
bool f2fs_all_cluster_page_loaded(struct compress_ctx *cc, struct pagevec
*pvec,
int index, int nr_pages);
bool f2fs_sanity_check_cluster(struct dnode_of_data *dn);
+bool f2fs_all_cluster_page_uptodate(struct compress_ctx *cc, struct pagevec
*pvec,
+ int index, int nr_pages);
void f2fs_compress_ctx_add_page(struct compress_ctx *cc, struct page *page);
int f2fs_write_multi_pages(struct compress_ctx *cc,
int *submitted,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel