Skip to contentSkip to conversation

f2fs: compress: avoid unnecessary check in f2fs_prepare_compress_overwrite

PATCH Superseded Fengnan Chang 1 participant 1 message May 6, 2021 F2FS file system

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 f2fs: compress: avoid unnecessary check in f2fs_prepare_compress_overwrite

when write compressed file with O_TRUNC, there will be a lot of unnecessary check valid blocks in f2fs_prepare_compress_overwrite, especially when written in page size, remove it.

---
 fs/f2fs/data.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/f2fs/data.c +4 -0
index cf935474ffba..8ce26decf382 100644
@@ -3303,9 +3303,13 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
 #ifdef CONFIG_F2FS_FS_COMPRESSION
 	if (f2fs_compressed_file(inode)) {
 		int ret;
+		pgoff_t end = (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT;
 
 		*fsdata = NULL;
 
+		if (index >= end)
+			goto repeat;
+
 		ret = f2fs_prepare_compress_overwrite(inode, pagep,
 							index, fsdata);
 		if (ret < 0) {

--
2.29.0

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