Commit 2f9420d3 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: compress: fix to cover f2fs_disable_compressed_file() w/ i_sem

- f2fs_disable_compressed_file
  - check inode_has_data
					- f2fs_file_mmap
					- mkwrite
					 - f2fs_get_block_locked
					 : update metadata in compressed
					   inode's disk layout
  - fi->i_flags &= ~F2FS_COMPR_FL
  - clear_inode_flag(inode, FI_COMPRESSED_FILE);

we should use i_sem lock to prevent above race case.

Fixes: 4c8ff709 ("f2fs: support data compression")
Signed-off-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 0b8eb814
...@@ -4415,15 +4415,24 @@ static inline bool f2fs_disable_compressed_file(struct inode *inode) ...@@ -4415,15 +4415,24 @@ static inline bool f2fs_disable_compressed_file(struct inode *inode)
{ {
struct f2fs_inode_info *fi = F2FS_I(inode); struct f2fs_inode_info *fi = F2FS_I(inode);
if (!f2fs_compressed_file(inode)) f2fs_down_write(&F2FS_I(inode)->i_sem);
if (!f2fs_compressed_file(inode)) {
f2fs_up_write(&F2FS_I(inode)->i_sem);
return true; return true;
if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode)) }
if (f2fs_is_mmap_file(inode) ||
(S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode))) {
f2fs_up_write(&F2FS_I(inode)->i_sem);
return false; return false;
}
fi->i_flags &= ~F2FS_COMPR_FL; fi->i_flags &= ~F2FS_COMPR_FL;
stat_dec_compr_inode(inode); stat_dec_compr_inode(inode);
clear_inode_flag(inode, FI_COMPRESSED_FILE); clear_inode_flag(inode, FI_COMPRESSED_FILE);
f2fs_mark_inode_dirty_sync(inode, true); f2fs_mark_inode_dirty_sync(inode, true);
f2fs_up_write(&F2FS_I(inode)->i_sem);
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment