Skip to contentSkip to conversation

f2fs: allow compression of files without blocks

PATCH In review Chao Liu 3 participants 4 messages Jul 7, 2022 – Jul 12, 2022 F2FS file system

lore
Share & tools
lore

Chao Liu

author
#0 lore raw

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

From: Chao Liu <[email protected]>

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

---
v2:
- update commit message: truncate -> truncate(1)

 fs/f2fs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/file.c +1 -1
index 0f29af7876a6..f7a82858486a 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);

--
2.36.1

maintainer
#2 lore raw
In reply to Chao Liu
Quoted 18 lines · Chao Liu

From: Chao Liu <[email protected]>

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

---
v2:
- update commit message: truncate -> truncate(1)

 fs/f2fs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/file.c +0 -0
index 0f29af7876a6..f7a82858486a 100644

fs/f2fs/file.c static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) · line 1882

Quoted 5 lines
fs/f2fs/file.c +1 -1
@@ -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))

What about inline_data case?

Quoted 5 lines
fs/f2fs/file.c +0 -1
 				return -EINVAL;
 
 			set_compress_context(inode);
--

2.36.1

maintainer
#3 lore raw
Quoted 14 lines · Jaegeuk Kim
Quoted 13 lines · Chao Liu

From: Chao Liu <[email protected]>

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

---
v2:
- update commit message: truncate -> truncate(1)

  fs/f2fs/file.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

fs/f2fs/file.c static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) · line 1882

Quoted 10 lines
fs/f2fs/file.c +1 -1
index 0f29af7876a6..f7a82858486a 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))

What about inline_data case?

How about fixing this w/ a separated patch?

f2fs: fix to check inline_data during compressed inode conversion

Thanks,

Quoted 6 lines
Quoted 6 lines
fs/f2fs/file.c +0 -1
  				return -EINVAL;
 
  			set_compress_context(inode);
--

2.36.1