Skip to contentSkip to conversation

f2fs: compress: remove unneeded read when rewrite whole cluster

PATCH In review Fengnan Chang via Linux-f2fs-devel 3 participants 3 messages Jun 10, 2021 – Jun 21, 2021 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: compress: remove unneeded read when rewrite whole cluster

For now, when overwrite compressed file, we need read old data to page cache first and update pages.
But when we need overwrite whole cluster, we don't need old data anymore.
So, remove read data process in this case, I have made
some simple changes to test, tests have shown that this can lead to significant performance improvements, the speed of sequential write up to 2x.

This modificy just check wheather the whole page was dirty, because when writeback cache f2fs_prepare_compress_overwrite will be called again. when update whole cluster, cc in prepare_compress_overwrite will be empty, so will not read old data.
when only update one page in cluster, cc in prepae_compress_overwrite will not be empty, so will read old data.

---
 fs/f2fs/data.c | 3 +++
 1 file changed, 3 insertions(+)
fs/f2fs/data.c +3 -0
index d4795eda12fa..9376c62e0ecc 100644
@@ -3307,6 +3307,9 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
 
 		*fsdata = NULL;
 
+		if (len == PAGE_SIZE)
+			goto repeat;
+
 		ret = f2fs_prepare_compress_overwrite(inode, pagep,
 							index, fsdata);
 		if (ret < 0) {
Signature · 8 lines
2.29.0



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

Hi chao & jaegeuk:
Any comments about this?

Thanks.

Quoted 28 lines · Fengnan Chang

For now, when overwrite compressed file, we need read old data to page cache first and update pages.
But when we need overwrite whole cluster, we don't need old data anymore.
So, remove read data process in this case, I have made
some simple changes to test, tests have shown that this can lead to significant performance improvements, the speed of sequential write up to 2x.

This modificy just check wheather the whole page was dirty, because when writeback cache f2fs_prepare_compress_overwrite will be called again. when update whole cluster, cc in prepare_compress_overwrite will be empty, so will not read old data.
when only update one page in cluster, cc in prepae_compress_overwrite will not be empty, so will read old data.

---
  fs/f2fs/data.c | 3 +++
  1 file changed, 3 insertions(+)
fs/f2fs/data.c +0 -0
index d4795eda12fa..9376c62e0ecc 100644

fs/f2fs/data.c static int f2fs_write_begin(struct file *file, struct address_space *mapping, · line 3315

Quoted 9 lines
fs/f2fs/data.c +3 -0
@@ -3307,6 +3307,9 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
 
  		*fsdata = NULL;
 
+		if (len == PAGE_SIZE)
+			goto repeat;
+
  		ret = f2fs_prepare_compress_overwrite(inode, pagep,
  							index, fsdata);
  		if (ret < 0) {

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

maintainer Acked-by
#2 lore raw
Quoted 10 lines · Fengnan Chang

Hi chao & jaegeuk:
  Any comments about this?

Thanks.

Quoted 4 lines · Fengnan Chang

For now, when overwrite compressed file, we need read old data to page cache first and update pages.
But when we need overwrite whole cluster, we don't need old data anymore.

Commit message needs to be updated as:

when we overwrite the whole page in cluster, we don't need read original data before write, because after write_end(), writepages() can help to load left data in that cluster.

Thanks,

Quoted 26 lines
Quoted 26 lines

So, remove read data process in this case, I have made some simple changes to test, tests have shown that this can lead to significant performance improvements, the speed of sequential write up to 2x.

This modificy just check wheather the whole page was dirty, because when writeback cache f2fs_prepare_compress_overwrite will be called again. when update whole cluster, cc in prepare_compress_overwrite will be empty, so will not read old data.
when only update one page in cluster,  cc in prepae_compress_overwrite will not be empty, so will read old data.

---
  fs/f2fs/data.c | 3 +++

  1 file changed, 3 insertions(+)
fs/f2fs/data.c +0 -0
index d4795eda12fa..9376c62e0ecc 100644
@@ -3307,6 +3307,9 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
 
           *fsdata = NULL;
 
Quoted 7 lines

fs/f2fs/data.c static int f2fs_write_begin(struct file *file, struct address_space *mapping, · line 3315

Quoted 7 lines
fs/f2fs/data.c +3 -0
+        if (len == PAGE_SIZE)
+            goto repeat;
+
           ret = f2fs_prepare_compress_overwrite(inode, pagep,
                               index, fsdata);
           if (ret < 0) {

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