Skip to contentSkip to conversation

f2fs: allow compression of files without blocks

PATCH Superseded Chao Liu 2 participants 6 messages Jun 21, 2022 – Jul 7, 2022 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chao Liu

author
#0 lore raw

PATCH 1/1 f2fs: allow compression of files without blocks

From: Chao Liu <[email protected]>

Files created by truncate have a size but no blocks, so they can be allowed to enable compression.

---
 fs/f2fs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/file.c +1 -1
index 2d1114b0ceef..daaa0dfd2d2e 100644
@@ -1879,7 +1879,7 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
 		if (iflags & F2FS_COMPR_FL) {
 			if (!f2fs_may_compress(inode))
 				return -EINVAL;
-			if (S_ISREG(inode->i_mode) && inode->i_size)
+			if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode))
 				return -EINVAL;
 
 			set_compress_context(inode);
Signature · 1 line
2.36.1
maintainer
#1 lore raw
Quoted 3 lines · Chao Liu

From: Chao Liu <[email protected]>

Files created by truncate have a size but no blocks, so

I didn't get it, how can we create file by truncation...

Thanks,

Quoted 20 lines

they can be allowed to enable compression.

---
  fs/f2fs/file.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/file.c +1 -1
index 2d1114b0ceef..daaa0dfd2d2e 100644
@@ -1879,7 +1879,7 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
  		if (iflags & F2FS_COMPR_FL) {
  			if (!f2fs_may_compress(inode))
  				return -EINVAL;
-			if (S_ISREG(inode->i_mode) && inode->i_size)
+			if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode))
  				return -EINVAL;
 
  			set_compress_context(inode);
author
#2 lore raw
Quoted 6 lines · Chao Yu
Quoted 3 lines · Chao Liu

From: Chao Liu <[email protected]>

Files created by truncate have a size but no blocks, so

I didn't get it, how can we create file by truncation...

I'm sorry I didn't make it clear. We can create a file by passing a FILE parameter that does not exist to the user command truncate(1) [1].

How about using truncate(1) instead of truncate in the description of the change?

Thanks,

[1] truncate(1): https://man7.org/linux/man-pages/man1/truncate.1.html

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

author
#3 lore raw

Ping.

Quoted 18 lines · Chao Liu
Quoted 6 lines · Chao Yu
Quoted 3 lines · Chao Liu

From: Chao Liu <[email protected]>

Files created by truncate have a size but no blocks, so

I didn't get it, how can we create file by truncation...

I'm sorry I didn't make it clear. We can create a file by passing a FILE parameter that does not exist to the user command truncate(1) [1].

How about using truncate(1) instead of truncate in the description of the change?

Thanks,

[1] truncate(1): https://man7.org/linux/man-pages/man1/truncate.1.html

maintainer
#4 lore raw
In reply to Chao Liu
Quoted 6 lines · Chao Liu
Quoted 5 lines · Chao Yu
Quoted 3 lines · Chao Liu

From: Chao Liu <[email protected]>

Files created by truncate have a size but no blocks, so

Quoted 8 lines
Quoted 1 line

I didn't get it, how can we create file by truncation...

I'm sorry I didn't make it clear. We can create a file by passing a FILE parameter that does not exist to the user command truncate(1) [1].

How about using truncate(1) instead of truncate in the description of the change?

Fine to me, as f2fs_disable_compressed_file() uses the same check condition. ;)

Thanks,

Quoted 4 lines

Thanks,

[1] truncate(1): https://man7.org/linux/man-pages/man1/truncate.1.html

author
#5 lore raw
Quoted 13 lines · Chao Yu
Quoted 12 lines · Chao Liu
Quoted 6 lines · Chao Yu
Quoted 3 lines · Chao Liu

From: Chao Liu <[email protected]>

Files created by truncate have a size but no blocks, so

I didn't get it, how can we create file by truncation...

I'm sorry I didn't make it clear. We can create a file by passing a FILE parameter that does not exist to the user command truncate(1) [1].

Quoted 5 lines
Quoted 2 lines

How about using truncate(1) instead of truncate in the description of the change?

Fine to me, as f2fs_disable_compressed_file() uses the same check condition. ;)

Thank you, let me send a v2 patch later. :-D

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