]> git.baikalelectronics.ru Git - kernel.git/commitdiff
f2fs: intorduce f2fs_all_cluster_page_ready
authorFengnan Chang <changfengnan@vivo.com>
Sun, 31 Jul 2022 03:33:45 +0000 (11:33 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 5 Aug 2022 11:20:28 +0000 (04:20 -0700)
When write total cluster, all pages is uptodate, there is not need to call
f2fs_prepare_compress_overwrite, intorduce f2fs_all_cluster_page_ready
to avoid this.

Signed-off-by: Fengnan Chang <changfengnan@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/compress.c
fs/f2fs/data.c
fs/f2fs/f2fs.h

index 086e6f74ce32b41aa2e04dc25ad853dc20dd41cd..75886b493ec3bfc157ad3ed59717eafcc0537fff 100644 (file)
@@ -841,20 +841,27 @@ 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_loaded(struct compress_ctx *cc, struct pagevec *pvec,
-                               int index, int nr_pages)
+bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct pagevec *pvec,
+                               int index, int nr_pages, bool uptodate)
 {
-       unsigned long pgidx;
-       int i;
+       unsigned long pgidx = pvec->pages[index]->index;
+       int i = uptodate ? 0 : 1;
 
-       if (nr_pages - index < cc->cluster_size)
+       /*
+        * when uptodate set to true, try to check all pages in cluster is
+        * uptodate or not.
+        */
+       if (uptodate && (pgidx % cc->cluster_size))
                return false;
 
-       pgidx = pvec->pages[index]->index;
+       if (nr_pages - index < cc->cluster_size)
+               return false;
 
-       for (i = 1; i < cc->cluster_size; i++) {
+       for (; i < cc->cluster_size; i++) {
                if (pvec->pages[index + i]->index != pgidx + i)
                        return false;
+               if (uptodate && !PageUptodate(pvec->pages[index + i]))
+                       return false;
        }
 
        return true;
index f48eec8f93e2462778f994b4219bbd3702f4b3b8..34a7a9affea0f45a3169b28dac6ada923efc67d5 100644 (file)
@@ -3011,6 +3011,10 @@ readd:
                                if (!f2fs_cluster_is_empty(&cc))
                                        goto lock_page;
 
+                               if (f2fs_all_cluster_page_ready(&cc,
+                                       &pvec, i, nr_pages, true))
+                                       goto lock_page;
+
                                ret2 = f2fs_prepare_compress_overwrite(
                                                        inode, &pagep,
                                                        page->index, &fsdata);
@@ -3021,8 +3025,8 @@ readd:
                                } else if (ret2 &&
                                        (!f2fs_compress_write_end(inode,
                                                fsdata, page->index, 1) ||
-                                        !f2fs_all_cluster_page_loaded(&cc,
-                                               &pvec, i, nr_pages))) {
+                                        !f2fs_all_cluster_page_ready(&cc,
+                                               &pvec, i, nr_pages, false))) {
                                        retry = 1;
                                        break;
                                }
index 2f3c4eef89c270eeabcb9ddb7c882f3c8711c7aa..35383f5353a43bacb487d1f54708f0d9c818c149 100644 (file)
@@ -4198,8 +4198,8 @@ 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_loaded(struct compress_ctx *cc, struct pagevec *pvec,
-                               int index, int nr_pages);
+bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct pagevec *pvec,
+                               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);
 int f2fs_write_multi_pages(struct compress_ctx *cc,