Skip to contentSkip to conversation

f2fs: compress: allow write compress released file after truncate to zero

PATCH Superseded Fengnan Chang 3 participants 3 messages Jun 28, 2021 – Jul 1, 2021 F2FS file system

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: compress: allow write compress released file after truncate to zero

We should allow write compress released file after truncate to zero.

---
 fs/f2fs/file.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/file.c +5 -1
index 6afd4562335f..b91ae8f751c5 100644
@@ -730,9 +730,13 @@ int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock)
 	 * for compressed file, only support cluster size
 	 * aligned truncation.
 	 */
-	if (f2fs_compressed_file(inode))
+	if (f2fs_compressed_file(inode)) {
 		free_from = round_up(from,
 				F2FS_I(inode)->i_cluster_size << PAGE_SHIFT);
+		if (!free_from)
+			clear_inode_flag(inode, FI_COMPRESS_RELEASED);
+	}
+
 #endif
 
 	err = f2fs_do_truncate_blocks(inode, free_from, lock);
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 12 lines · Fengnan Chang

We should allow write compress released file after truncate to zero.

---
 fs/f2fs/file.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/f2fs/file.c +0 -0
index 6afd4562335f..b91ae8f751c5 100644

fs/f2fs/file.c int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock) · line 737

Quoted 9 lines
fs/f2fs/file.c +3 -1
@@ -730,9 +730,13 @@ int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock)
 	 * for compressed file, only support cluster size
 	 * aligned truncation.
 	 */
-	if (f2fs_compressed_file(inode))
+	if (f2fs_compressed_file(inode)) {
 		free_from = round_up(from,
 				F2FS_I(inode)->i_cluster_size << PAGE_SHIFT);
+		if (!free_from)
+			clear_inode_flag(inode, FI_COMPRESS_RELEASED);

We can do after truncating all the blocks successfully?

Quoted 7 lines
fs/f2fs/file.c +2 -0
+	}
+
 #endif
 
 	err = f2fs_do_truncate_blocks(inode, free_from, lock);
Signature · 1 line
2.29.0

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

maintainer
#2 lore raw
Quoted 8 lines · Jaegeuk Kim
Quoted 7 lines · Fengnan Chang

We should allow write compress released file after truncate to zero.

---
  fs/f2fs/file.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
Quoted 16 lines
Quoted 5 lines
fs/f2fs/file.c +0 -0
index 6afd4562335f..b91ae8f751c5 100644

fs/f2fs/file.c int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock) · line 737

Quoted 9 lines
fs/f2fs/file.c +3 -1
@@ -730,9 +730,13 @@ int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock)
  	 * for compressed file, only support cluster size
  	 * aligned truncation.
  	 */
-	if (f2fs_compressed_file(inode))
+	if (f2fs_compressed_file(inode)) {
  		free_from = round_up(from,
  				F2FS_I(inode)->i_cluster_size << PAGE_SHIFT);
+		if (!free_from)
+			clear_inode_flag(inode, FI_COMPRESS_RELEASED);

We can do after truncating all the blocks successfully?

Agreed, but please document this behavior as well.

Thanks,

Quoted 8 lines
Quoted 8 lines
fs/f2fs/file.c +2 -0
+	}
+
  #endif
 
  	err = f2fs_do_truncate_blocks(inode, free_from, lock);
Signature · 1 line
2.29.0

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