Skip to contentSkip to conversation

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

PATCH Superseded Fengnan Chang 2 participants 3 messages Jul 23, 2021 – Aug 6, 2021 F2FS file system

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

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

For compressed file, after release compress blocks, don't allow write direct, but we should allow write direct after truncate to zero.

---
 fs/f2fs/file.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/f2fs/file.c +8 -0
index 6afd4562335f..094f6546fd00 100644
@@ -740,6 +740,14 @@ int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock)
 		return err;
 
 #ifdef CONFIG_F2FS_FS_COMPRESSION
+	/*
+	 * For compressed file, after release compress blocks, don't allow write
+	 * direct, but we should allow write direct after truncate to zero.
+	 */
+	if (f2fs_compressed_file(inode) && !free_from
+			&& is_inode_flag_set(inode, FI_COMPRESS_RELEASED))
+		clear_inode_flag(inode, FI_COMPRESS_RELEASED);
+
 	if (from != free_from) {
 		err = f2fs_truncate_partial_cluster(inode, from, lock);
 		if (err)
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

Um.. I think this version should be ok.

Thanks.

Quoted 18 lines · Fengnan Chang

For compressed file, after release compress blocks, don't allow write direct, but we should allow write direct after truncate to zero.

---
  fs/f2fs/file.c | 8 ++++++++
  1 file changed, 8 insertions(+)
fs/f2fs/file.c +1 -0
index 6afd4562335f..094f6546fd00 100644
@@ -740,6 +740,14 @@ int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock)
  		return err;
 
  #ifdef CONFIG_F2FS_FS_COMPRESSION
+	/*

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

Quoted 10 lines
fs/f2fs/file.c +7 -0
+	 * For compressed file, after release compress blocks, don't allow write
+	 * direct, but we should allow write direct after truncate to zero.
+	 */
+	if (f2fs_compressed_file(inode) && !free_from
+			&& is_inode_flag_set(inode, FI_COMPRESS_RELEASED))
+		clear_inode_flag(inode, FI_COMPRESS_RELEASED);
+
  	if (from != free_from) {
  		err = f2fs_truncate_partial_cluster(inode, from, lock);
  		if (err)

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

maintainer
#2 lore raw
Quoted 1 line · Fengnan Chang

Um.. I think this version should be ok.

Well, actually, I mean adding description of this behavior into compression section of f2fs.rst.

https://elixir.bootlin.com/linux/latest/source/Documentation/filesystems/f2fs.rst#L829

Thanks,

Quoted 19 lines

Thanks.

Quoted 15 lines · Fengnan Chang

For compressed file, after release compress blocks, don't allow write direct, but we should allow write direct after truncate to zero.

---
   fs/f2fs/file.c | 8 ++++++++
   1 file changed, 8 insertions(+)
fs/f2fs/file.c +0 -0
index 6afd4562335f..094f6546fd00 100644
@@ -740,6 +740,14 @@ int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock)
   		return err;
 
Quoted 13 lines

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

Quoted 13 lines
fs/f2fs/file.c +8 -0
   #ifdef CONFIG_F2FS_FS_COMPRESSION
+	/*
+	 * For compressed file, after release compress blocks, don't allow write
+	 * direct, but we should allow write direct after truncate to zero.
+	 */
+	if (f2fs_compressed_file(inode) && !free_from
+			&& is_inode_flag_set(inode, FI_COMPRESS_RELEASED))
+		clear_inode_flag(inode, FI_COMPRESS_RELEASED);
+
   	if (from != free_from) {
   		err = f2fs_truncate_partial_cluster(inode, from, lock);
   		if (err)

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