Skip to contentSkip to conversation

f2fs: compress: avoid unnecessary check in f2fs_prepare_compress_overwrite

PATCH Superseded Fengnan Chang 2 participants 2 messages Apr 28, 2021 – May 4, 2021 F2FS file system

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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 | 6 ++++++
 1 file changed, 6 insertions(+)
fs/f2fs/data.c +6 -0
index cf935474ffba..4cfc0472bc2d 100644
@@ -3270,6 +3270,9 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
 	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
 	struct page *page = NULL;
 	pgoff_t index = ((unsigned long long) pos) >> PAGE_SHIFT;
+#ifdef CONFIG_F2FS_FS_COMPRESSION
+	pgoff_t end = (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT;
+#endif
 	bool need_balance = false, drop_atomic = false;
 	block_t blkaddr = NULL_ADDR;
 	int err = 0;
@@ -3306,6 +3309,9 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
 
 		*fsdata = NULL;
 
+		if (index >= end)
+			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
maintainer
#1 lore raw
Quoted 14 lines · Fengnan Chang

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 | 6 ++++++
 1 file changed, 6 insertions(+)
fs/f2fs/data.c +0 -0
index cf935474ffba..4cfc0472bc2d 100644

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

Quoted 5 lines
fs/f2fs/data.c +2 -0
@@ -3270,6 +3270,9 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
 	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
 	struct page *page = NULL;
 	pgoff_t index = ((unsigned long long) pos) >> PAGE_SHIFT;
+#ifdef CONFIG_F2FS_FS_COMPRESSION
+	pgoff_t end = (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT;

Need to move this below?

Quoted 16 lines
fs/f2fs/data.c +4 -0
+#endif
 	bool need_balance = false, drop_atomic = false;
 	block_t blkaddr = NULL_ADDR;
 	int err = 0;
@@ -3306,6 +3309,9 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
 
 		*fsdata = NULL;
 
+		if (index >= end)
+			goto repeat;
+
 		ret = f2fs_prepare_compress_overwrite(inode, pagep,
 							index, fsdata);
 		if (ret < 0) {
Signature · 1 line
2.29.0

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