summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/data.c
diff options
context:
space:
mode:
authorFengnan Chang <changfengnan@vivo.com>2021-08-12 19:36:41 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2021-08-12 13:46:05 -0700
commita2649315bcb88a136ce978a06af8aa23ea8b4154 (patch)
tree6a2863d0ce6c34ade071eb42aaa4b7a840961cee /fs/f2fs/data.c
parent65ddf6564843890a58ee3b18bb46ce67d96333fb (diff)
downloadlinux-stable-a2649315bcb88a136ce978a06af8aa23ea8b4154.tar.gz
linux-stable-a2649315bcb88a136ce978a06af8aa23ea8b4154.tar.bz2
linux-stable-a2649315bcb88a136ce978a06af8aa23ea8b4154.zip
f2fs: compress: avoid duplicate counting of valid blocks when read compressed file
Since cluster is basic unit of compression, one cluster is compressed or not, so we can calculate valid blocks only for first page in cluster, the other pages just skip. Signed-off-by: Fengnan Chang <changfengnan@vivo.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/data.c')
-rw-r--r--fs/f2fs/data.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index df5e8d8c654e..cec084806725 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2299,6 +2299,7 @@ static int f2fs_mpage_readpages(struct inode *inode,
.nr_rpages = 0,
.nr_cpages = 0,
};
+ pgoff_t nc_cluster_idx = NULL_CLUSTER;
#endif
unsigned nr_pages = rac ? readahead_count(rac) : 1;
unsigned max_nr_pages = nr_pages;
@@ -2331,12 +2332,23 @@ static int f2fs_mpage_readpages(struct inode *inode,
if (ret)
goto set_error_page;
}
- ret = f2fs_is_compressed_cluster(inode, page->index);
- if (ret < 0)
- goto set_error_page;
- else if (!ret)
- goto read_single_page;
+ if (cc.cluster_idx == NULL_CLUSTER) {
+ if (nc_cluster_idx ==
+ page->index >> cc.log_cluster_size) {
+ goto read_single_page;
+ }
+
+ ret = f2fs_is_compressed_cluster(inode, page->index);
+ if (ret < 0)
+ goto set_error_page;
+ else if (!ret) {
+ nc_cluster_idx =
+ page->index >> cc.log_cluster_size;
+ goto read_single_page;
+ }
+ nc_cluster_idx = NULL_CLUSTER;
+ }
ret = f2fs_init_compress_ctx(&cc);
if (ret)
goto set_error_page;