f2fs: compress: avoid duplicate counting of valid blocks when read compressed file
RFC PATCH 1/1 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.
--- fs/f2fs/data.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
fs/f2fs/data.c +7 -6
@@ -2304,12 +2304,13 @@ 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 ) { + ret =f2fs_is_compressed_cluster (inode, page->index); +if (ret <0 ) + goto set_error_page; +else if (!ret) + goto read_single_page; + } ret =f2fs_init_compress_ctx (&cc);if (ret) goto set_error_page;
Signature · 8 lines
2.29.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu
maintainerQuoted 14 lines · Fengnan Chang
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 <[email protected]>--- fs/f2fs/data.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)fs/f2fs/data.c +0
-0
fs/f2fs/data.c static int f2fs_mpage_readpages(struct inode *inode, · line 2311
Quoted 8 lines
fs/f2fs/data.c +0
-5@@ -2304,12 +2304,13 @@ 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;
How about truncation races with read?
Thanks,
fs/f2fs/data.c static int f2fs_mpage_readpages(struct inode *inode, · line 2316
Quoted 12 lines
fs/f2fs/data.c +7
-1- +if (cc.cluster_idx ==NULL_CLUSTER ) { + ret =f2fs_is_compressed_cluster (inode, page->index); +if (ret <0 ) + goto set_error_page; +else if (!ret) + goto read_single_page; + } ret =f2fs_init_compress_ctx (&cc);if (ret) goto set_error_page;
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
f2fs_read_multi_pages will handle,all truncate page will be zero out, Whether partial or all page in cluster.
Quoted 27 lines · Chao Yu
Quoted 14 lines · Fengnan Chang
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 <[email protected]>---
fs/f2fs/data.c| 13 +++++++------1 file changed, 7 insertions(+), 6 deletions(-)fs/f2fs/data.c +0
-0fs/f2fs/data.c static int f2fs_mpage_readpages(struct inode · line 2312
Quoted 9 lines
fs/f2fs/data.c +0
-5@@ -2304,12 +2304,13 @@ 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;How about truncation races with read?
Quoted 15 lines
Thanks,
Quoted 12 lines
fs/f2fs/data.c +7
-1- + if (cc.cluster_idx == NULL_CLUSTER) { + ret = f2fs_is_compressed_cluster(inode, page->index); + if (ret < 0) + goto set_error_page; + else if (!ret) + goto read_single_page; + } ret = f2fs_init_compress_ctx(&cc); if (ret)goto
set_error_page;
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu
maintainerQuoted 4 lines · Fengnan Chang
f2fs_read_multi_pageswill handle,all truncate page will be zero out, Whether partial or all page in cluster.
Quoted 27 lines
Quoted 26 lines · Chao Yu
Quoted 14 lines · Fengnan Chang
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 <[email protected]>--- fs/f2fs/data.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)fs/f2fs/data.c +0
-0fs/f2fs/data.c static int f2fs_mpage_readpages(struct inode · line 2312
Quoted 9 lines
fs/f2fs/data.c +0
-5@@ -2304,12 +2304,13 @@ 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;How about truncation races with read?
Look into this again, it looks fine, truncation tries to grab all pages lock of cluster, but readahead has already held some/all of them, so there is no such race condition.
So compressed cluster case looks fine to me, but we still need to call f2fs_is_compressed_cluster() every time for non-compressed cluster, could you please check that as well?
Thanks,
Quoted 16 lines
Quoted 16 lines
Thanks,
Quoted 12 lines
fs/f2fs/data.c +7
-1- + if (cc.cluster_idx == NULL_CLUSTER) { + ret = f2fs_is_compressed_cluster(inode, page->index); + if (ret < 0) + goto set_error_page; + else if (!ret) + goto read_single_page; + } ret = f2fs_init_compress_ctx(&cc); if (ret)goto
set_error_page;
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
I'll check this later.
Thanks.
Quoted 37 lines · Chao Yu
Quoted 4 lines · Fengnan Chang
f2fs_read_multi_pageswill handle,all truncate page will be zero out, Whether partial or all page in cluster.Quoted 27 lines
Quoted 26 lines · Chao Yu
Quoted 14 lines · Fengnan Chang
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 <[email protected]>---
fs/f2fs/data.c| 13 +++++++------1 file changed, 7 insertions(+), 6 deletions(-)fs/f2fs/data.c +0
-0fs/f2fs/data.c static int f2fs_mpage_readpages(struct inode · line 2312
Quoted 9 lines
fs/f2fs/data.c +0
-5@@ -2304,12 +2304,13 @@ 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;How about truncation races with read?
Look into this again, it looks fine, truncation tries to grab all pages lock of cluster, but readahead has already held some/all of them, so there is no such race condition.
Quoted 23 lines
So compressed cluster case looks fine to me, but we still need to call
f2fs_is_compressed_cluster()every time for non-compressed cluster, could you please check that as well?Thanks,
Quoted 16 lines
Quoted 16 lines
Thanks,
Quoted 12 lines
fs/f2fs/data.c +7
-1- + if (cc.cluster_idx == NULL_CLUSTER) { + ret = f2fs_is_compressed_cluster(inode, page->index); + if (ret < 0) + goto set_error_page; + else if (!ret) + goto read_single_page; + } ret = f2fs_init_compress_ctx(&cc); if (ret)goto
set_error_page;
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Hi chao:
Since cc.cluster_idx only will be set in f2fs_compress_ctx_add_page,
so for non-compressed cluster, cc.cluster_idx should always be NULL. it means that the handling process of non-compressed cluster is same as older.
Quoted 37 lines · Chao Yu
Quoted 4 lines · Fengnan Chang
f2fs_read_multi_pageswill handle,all truncate page will be zero out, Whether partial or all page in cluster.Quoted 27 lines
Quoted 26 lines · Chao Yu
Quoted 14 lines · Fengnan Chang
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 <[email protected]>---
fs/f2fs/data.c| 13 +++++++------1 file changed, 7 insertions(+), 6 deletions(-)fs/f2fs/data.c +0
-0fs/f2fs/data.c static int f2fs_mpage_readpages(struct inode · line 2312
Quoted 9 lines
fs/f2fs/data.c +0
-5@@ -2304,12 +2304,13 @@ 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;How about truncation races with read?
Look into this again, it looks fine, truncation tries to grab all pages lock of cluster, but readahead has already held some/all of them, so there is no such race condition.
Quoted 23 lines
So compressed cluster case looks fine to me, but we still need to call
f2fs_is_compressed_cluster()every time for non-compressed cluster, could you please check that as well?Thanks,
Quoted 16 lines
Quoted 16 lines
Thanks,
Quoted 12 lines
fs/f2fs/data.c +7
-1- + if (cc.cluster_idx == NULL_CLUSTER) { + ret = f2fs_is_compressed_cluster(inode, page->index); + if (ret < 0) + goto set_error_page; + else if (!ret) + goto read_single_page; + } ret = f2fs_init_compress_ctx(&cc); if (ret)goto
set_error_page;
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu
maintainerQuoted 4 lines · Fengnan Chang
Hi chao:
Since cc.cluster_idx only will be set inf2fs_compress_ctx_add_page,
so for non-compressed cluster, cc.cluster_idx should always be NULL. it means that the handling process of non-compressed cluster is same as older.
Yup, so what I mean is why not skipping f2fs_is_compressed_cluster() check for non-compressed cluster as we did for compressed cluster.
Thanks,
Quoted 51 lines · Chao Yu
Quoted 49 lines · Fengnan Chang
Quoted 4 lines
f2fs_read_multi_pageswill handle,all truncate page will be zero out, Whether partial or all page in cluster.Quoted 29 lines
Quoted 28 lines · Chao Yu
Quoted 16 lines · Fengnan Chang
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 <[email protected]>--- fs/f2fs/data.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)fs/f2fs/data.c +0
-0fs/f2fs/data.c static int f2fs_mpage_readpages(struct inode · line 2312
Quoted 9 lines
fs/f2fs/data.c +0
-5@@ -2304,12 +2304,13 @@ 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;How about truncation races with read?
Look into this again, it looks fine, truncation tries to grab all pages lock
of cluster, but readahead has already held some/all of them, so there is no such race condition.So compressed cluster case looks fine to me, but we still need to call
f2fs_is_compressed_cluster()every time for non-compressed cluster, could you please check that as well?Thanks,
Quoted 3 lines
Quoted 3 lines
Thanks,
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
fs/f2fs/data.c +4
-1- + if (cc.cluster_idx == NULL_CLUSTER) { + ret = f2fs_is_compressed_cluster(inode, page->index); + if (ret < 0) + goto set_error_page;Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
fs/f2fs/data.c +3
-0+ else if (!ret) + goto read_single_page; + } ret = f2fs_init_compress_ctx(&cc); if (ret)goto
set_error_page;
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Um, in previous thought, consider of random read for non-compressed
cluster, I didn't handle non-compressed cluster, after your remind, I think we can skip f2fs_is_compressed_cluster() check for sequential read for non-compressed cluster.
Quoted 6 lines · Chao Yu
Quoted 4 lines · Fengnan Chang
Hi chao:
Since cc.cluster_idx only will be set inf2fs_compress_ctx_add_page, so for non-compressed cluster, cc.cluster_idx should always be NULL. it means that the handling process of non-compressed cluster is same as older.
Quoted 72 lines
Yup, so what I mean is why not skipping
f2fs_is_compressed_cluster()check for non-compressed cluster as we did for compressed cluster.Thanks,
Quoted 66 lines · Chao Yu
Quoted 64 lines · Fengnan Chang
Quoted 4 lines
f2fs_read_multi_pageswill handle,all truncate page will be zero out, Whether partial or all page in cluster.Quoted 29 lines
Quoted 28 lines · Chao Yu
Quoted 16 lines · Fengnan Chang
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 <[email protected]>---
fs/f2fs/data.c| 13 +++++++------1 file changed, 7 insertions(+), 6 deletions(-)fs/f2fs/data.c +0
-0fs/f2fs/data.c static int f2fs_mpage_readpages(struct inode · line 2312
Quoted 9 lines
fs/f2fs/data.c +0
-5@@ -2304,12 +2304,13 @@ 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;How about truncation races with read?
Look into this again, it looks fine, truncation tries to grab all pages lock
of cluster, but readahead has already held some/all of them, so there is no such race condition.So compressed cluster case looks fine to me, but we still need to call
f2fs_is_compressed_cluster()every time for non-compressed cluster, could you please check that as well?Thanks,
Quoted 17 lines
Quoted 17 lines
Thanks,
Quoted 13 lines
fs/f2fs/data.c +7
-1- + if (cc.cluster_idx == NULL_CLUSTER) { + ret = f2fs_is_compressed_cluster(inode, page->index); + if (ret < 0) + goto set_error_page; + else if (!ret) + goto read_single_page; + } ret = f2fs_init_compress_ctx(&cc);if (ret)
gotoset_error_page;
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel