Skip to contentSkip to conversation

f2fs: compress: remove unneed check condition

PATCH Superseded Chao Yu 2 participants 7 messages Apr 21, 2021 – Apr 27, 2021 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 f2fs: compress: remove unneed check condition

In only call path of __cluster_may_compress(), __f2fs_write_data_pages() has checked SBI_POR_DOING condition, and also cluster_may_compress() has checked CP_ERROR_FLAG condition, so remove redundant check condition in __cluster_may_compress() for cleanup.

---
 fs/f2fs/compress.c | 5 -----
 1 file changed, 5 deletions(-)
fs/f2fs/compress.c +0 -5
index 3c9d797dbdd6..532c311e3a89 100644
@@ -906,11 +906,6 @@ static bool __cluster_may_compress(struct compress_ctx *cc)
 
 		f2fs_bug_on(sbi, !page);
 
-		if (unlikely(f2fs_cp_error(sbi)))
-			return false;
-		if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
-			return false;
-
 		/* beyond EOF */
 		if (page->index >= nr_pages)
 			return false;
Signature · 1 line
2.29.2
maintainer
#1 lore raw
Quoted 4 lines · Chao Yu

In only call path of __cluster_may_compress(), __f2fs_write_data_pages() has checked SBI_POR_DOING condition, and also cluster_may_compress() has checked CP_ERROR_FLAG condition, so remove redundant check condition in __cluster_may_compress() for cleanup.

I think cp_error can get any time without synchronization. Is it safe to say it's redundant?

Quoted 24 lines
---
 fs/f2fs/compress.c | 5 -----
 1 file changed, 5 deletions(-)
fs/f2fs/compress.c +0 -5
index 3c9d797dbdd6..532c311e3a89 100644
@@ -906,11 +906,6 @@ static bool __cluster_may_compress(struct compress_ctx *cc)
 
 		f2fs_bug_on(sbi, !page);
 
-		if (unlikely(f2fs_cp_error(sbi)))
-			return false;
-		if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
-			return false;
-
 		/* beyond EOF */
 		if (page->index >= nr_pages)
 			return false;
Signature · 1 line
2.29.2
author
#2 lore raw
Quoted 8 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu

In only call path of __cluster_may_compress(), __f2fs_write_data_pages() has checked SBI_POR_DOING condition, and also cluster_may_compress() has checked CP_ERROR_FLAG condition, so remove redundant check condition in __cluster_may_compress() for cleanup.

I think cp_error can get any time without synchronization. Is it safe to say it's redundant?

Yes,

But no matter how late we check cp_error, cp_error can happen after our check points, it won't cause regression if we remove cp_error check there, because for compress write, it uses OPU, it won't overwrite any existed data in device.

Seems it will be more appropriate to check cp_error in f2fs_write_compressed_pages() like we did in f2fs_write_single_data_page() rather than in __cluster_may_compress().

BTW, shouldn't we rename __cluster_may_compress() to cluster_beyond_filesize() for better readability?

Thanks,

Quoted 27 lines
Quoted 25 lines
---
  fs/f2fs/compress.c | 5 -----
  1 file changed, 5 deletions(-)
fs/f2fs/compress.c +0 -5
index 3c9d797dbdd6..532c311e3a89 100644
@@ -906,11 +906,6 @@ static bool __cluster_may_compress(struct compress_ctx *cc)
 
  		f2fs_bug_on(sbi, !page);
 
-		if (unlikely(f2fs_cp_error(sbi)))
-			return false;
-		if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
-			return false;
-
  		/* beyond EOF */
  		if (page->index >= nr_pages)
  			return false;
Signature · 1 line
2.29.2

.

maintainer
#3 lore raw
Quoted 17 lines · Chao Yu
Quoted 8 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu

In only call path of __cluster_may_compress(), __f2fs_write_data_pages() has checked SBI_POR_DOING condition, and also cluster_may_compress() has checked CP_ERROR_FLAG condition, so remove redundant check condition in __cluster_may_compress() for cleanup.

I think cp_error can get any time without synchronization. Is it safe to say it's redundant?

Yes,

But no matter how late we check cp_error, cp_error can happen after our check points, it won't cause regression if we remove cp_error check there, because for compress write, it uses OPU, it won't overwrite any existed data in device.

Quoted 6 lines

Seems it will be more appropriate to check cp_error in f2fs_write_compressed_pages() like we did in f2fs_write_single_data_page() rather than in __cluster_may_compress().

BTW, shouldn't we rename __cluster_may_compress() to cluster_beyond_filesize() for better readability?

f2fs_cluster_has_data()?

Quoted 28 lines

Thanks,

Quoted 25 lines
Quoted 23 lines
---
  fs/f2fs/compress.c | 5 -----
  1 file changed, 5 deletions(-)
fs/f2fs/compress.c +0 -5
index 3c9d797dbdd6..532c311e3a89 100644
@@ -906,11 +906,6 @@ static bool __cluster_may_compress(struct compress_ctx *cc)
  		f2fs_bug_on(sbi, !page);
-		if (unlikely(f2fs_cp_error(sbi)))
-			return false;
-		if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
-			return false;
-
  		/* beyond EOF */
  		if (page->index >= nr_pages)
  			return false;
Signature · 1 line
2.29.2

.

author
#4 lore raw
Quoted 18 lines · Jaegeuk Kim
Quoted 17 lines · Chao Yu
Quoted 8 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu

In only call path of __cluster_may_compress(), __f2fs_write_data_pages() has checked SBI_POR_DOING condition, and also cluster_may_compress() has checked CP_ERROR_FLAG condition, so remove redundant check condition in __cluster_may_compress() for cleanup.

I think cp_error can get any time without synchronization. Is it safe to say it's redundant?

Yes,

But no matter how late we check cp_error, cp_error can happen after our check points, it won't cause regression if we remove cp_error check there, because for compress write, it uses OPU, it won't overwrite any existed data in device.

Quoted 8 lines
Quoted 6 lines

Seems it will be more appropriate to check cp_error in f2fs_write_compressed_pages() like we did in f2fs_write_single_data_page() rather than in __cluster_may_compress().

BTW, shouldn't we rename __cluster_may_compress() to cluster_beyond_filesize() for better readability?

f2fs_cluster_has_data()?

Maybe cluster_has_invalid_data()? which indicates there is invalid data beyond filesize.

Thanks,

Quoted 31 lines
Quoted 29 lines

Thanks,

Quoted 25 lines
Quoted 23 lines
---
   fs/f2fs/compress.c | 5 -----
   1 file changed, 5 deletions(-)
fs/f2fs/compress.c +0 -5
index 3c9d797dbdd6..532c311e3a89 100644
@@ -906,11 +906,6 @@ static bool __cluster_may_compress(struct compress_ctx *cc)
   		f2fs_bug_on(sbi, !page);
-		if (unlikely(f2fs_cp_error(sbi)))
-			return false;
-		if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
-			return false;
-
   		/* beyond EOF */
   		if (page->index >= nr_pages)
   			return false;
Signature · 1 line
2.29.2

.

.

maintainer
#5 lore raw
Quoted 23 lines · Chao Yu
Quoted 22 lines · Jaegeuk Kim
Quoted 21 lines · Chao Yu
Quoted 8 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu

In only call path of __cluster_may_compress(), __f2fs_write_data_pages() has checked SBI_POR_DOING condition, and also cluster_may_compress() has checked CP_ERROR_FLAG condition, so remove redundant check condition in __cluster_may_compress() for cleanup.

I think cp_error can get any time without synchronization. Is it safe to say it's redundant?

Yes,

But no matter how late we check cp_error, cp_error can happen after our check points, it won't cause regression if we remove cp_error check there, because for compress write, it uses OPU, it won't overwrite any existed data in device.

Seems it will be more appropriate to check cp_error in f2fs_write_compressed_pages() like we did in f2fs_write_single_data_page() rather than in __cluster_may_compress().

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

BTW, shouldn't we rename __cluster_may_compress() to cluster_beyond_filesize() for better readability?

f2fs_cluster_has_data()?

Maybe cluster_has_invalid_data()? which indicates there is invalid data beyond filesize.

BTW, we can compress it with zero data?

Quoted 34 lines

Thanks,

Quoted 31 lines
Quoted 29 lines

Thanks,

Quoted 25 lines
Quoted 23 lines
---
   fs/f2fs/compress.c | 5 -----
   1 file changed, 5 deletions(-)
fs/f2fs/compress.c +0 -5
index 3c9d797dbdd6..532c311e3a89 100644
@@ -906,11 +906,6 @@ static bool __cluster_may_compress(struct compress_ctx *cc)
   		f2fs_bug_on(sbi, !page);
-		if (unlikely(f2fs_cp_error(sbi)))
-			return false;
-		if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
-			return false;
-
   		/* beyond EOF */
   		if (page->index >= nr_pages)
   			return false;
Signature · 1 line
2.29.2

.

.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author
#6 lore raw
Quoted 27 lines · Jaegeuk Kim
Quoted 26 lines · Chao Yu
Quoted 25 lines · Jaegeuk Kim
Quoted 23 lines · Chao Yu
Quoted 8 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu

In only call path of __cluster_may_compress(), __f2fs_write_data_pages() has checked SBI_POR_DOING condition, and also cluster_may_compress() has checked CP_ERROR_FLAG condition, so remove redundant check condition in __cluster_may_compress() for cleanup.

I think cp_error can get any time without synchronization. Is it safe to say it's redundant?

Yes,

But no matter how late we check cp_error, cp_error can happen after our check points, it won't cause regression if we remove cp_error check there, because for compress write, it uses OPU, it won't overwrite any existed data in device.

Seems it will be more appropriate to check cp_error in f2fs_write_compressed_pages() like we did in f2fs_write_single_data_page() rather than in __cluster_may_compress().

BTW, shouldn't we rename __cluster_may_compress() to cluster_beyond_filesize() for better readability?

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

f2fs_cluster_has_data()?

Maybe cluster_has_invalid_data()? which indicates there is invalid data beyond filesize.

BTW, we can compress it with zero data?

I doubt it will cause unnecessary overhead for below condition?
- write 1GB data into file
- truncate file to 0
- writeback 1GB compressed cluster contains zero data

Thanks,

Quoted 37 lines
Quoted 35 lines

Thanks,

Quoted 31 lines
Quoted 29 lines

Thanks,

Quoted 25 lines
Quoted 23 lines
---
    fs/f2fs/compress.c | 5 -----
    1 file changed, 5 deletions(-)
fs/f2fs/compress.c +0 -5
index 3c9d797dbdd6..532c311e3a89 100644
@@ -906,11 +906,6 @@ static bool __cluster_may_compress(struct compress_ctx *cc)
    		f2fs_bug_on(sbi, !page);
-		if (unlikely(f2fs_cp_error(sbi)))
-			return false;
-		if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
-			return false;
-
    		/* beyond EOF */
    		if (page->index >= nr_pages)
    			return false;
Signature · 1 line
2.29.2

.

.

.