Skip to contentSkip to conversation

f2fs: make file immutable even if releasing zero compression block

PATCH In review Daeho Jeong 2 participants 2 messages Jul 30, 2020 – Aug 4, 2020 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: make file immutable even if releasing zero compression block

From: Daeho Jeong <[email protected]>

When we use F2FS_IOC_RELEASE_COMPRESS_BLOCKS ioctl, if we can't find any compressed blocks in the file even with large file size, the ioctl just ends up without changing the file's status as immutable. It makes the user, who expects that the file is immutable when it returns successfully, confused.

---
 fs/f2fs/file.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/f2fs/file.c +3 -3
index cc7f5670390f..8a422400e824 100644
@@ -3535,14 +3535,14 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
 	if (ret)
 		goto out;
 
-	if (!F2FS_I(inode)->i_compr_blocks)
-		goto out;
-
 	F2FS_I(inode)->i_flags |= F2FS_IMMUTABLE_FL;
 	f2fs_set_inode_flags(inode);
 	inode->i_ctime = current_time(inode);
 	f2fs_mark_inode_dirty_sync(inode, true);
 
+	if (!F2FS_I(inode)->i_compr_blocks)
+		goto out;
+
 	down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
 	down_write(&F2FS_I(inode)->i_mmap_sem);
 
Signature · 1 line
2.28.0.rc0.142.g3c755180ce-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Daeho Jeong

From: Daeho Jeong <[email protected]>

When we use F2FS_IOC_RELEASE_COMPRESS_BLOCKS ioctl, if we can't find any compressed blocks in the file even with large file size, the ioctl just ends up without changing the file's status as immutable. It makes the user, who expects that the file is immutable when it returns successfully, confused.

Thanks,