@@ -526,7 +526,11 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
526
526
527
527
file_accessed (file );
528
528
vma -> vm_ops = & f2fs_file_vm_ops ;
529
+
530
+ f2fs_down_read (& F2FS_I (inode )-> i_sem );
529
531
set_inode_flag (inode , FI_MMAP_FILE );
532
+ f2fs_up_read (& F2FS_I (inode )-> i_sem );
533
+
530
534
return 0 ;
531
535
}
532
536
@@ -1919,12 +1923,19 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
1919
1923
int err = f2fs_convert_inline_inode (inode );
1920
1924
if (err )
1921
1925
return err ;
1922
- if (!f2fs_may_compress (inode ))
1923
- return - EINVAL ;
1924
- if (S_ISREG (inode -> i_mode ) && F2FS_HAS_BLOCKS (inode ))
1926
+
1927
+ f2fs_down_write (& F2FS_I (inode )-> i_sem );
1928
+ if (!f2fs_may_compress (inode ) ||
1929
+ (S_ISREG (inode -> i_mode ) &&
1930
+ F2FS_HAS_BLOCKS (inode ))) {
1931
+ f2fs_up_write (& F2FS_I (inode )-> i_sem );
1925
1932
return - EINVAL ;
1926
- if (set_compress_context (inode ))
1927
- return - EOPNOTSUPP ;
1933
+ }
1934
+ err = set_compress_context (inode );
1935
+ f2fs_up_write (& F2FS_I (inode )-> i_sem );
1936
+
1937
+ if (err )
1938
+ return err ;
1928
1939
}
1929
1940
}
1930
1941
@@ -3976,6 +3987,7 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg)
3976
3987
file_start_write (filp );
3977
3988
inode_lock (inode );
3978
3989
3990
+ f2fs_down_write (& F2FS_I (inode )-> i_sem );
3979
3991
if (f2fs_is_mmap_file (inode ) || get_dirty_pages (inode )) {
3980
3992
ret = - EBUSY ;
3981
3993
goto out ;
@@ -3995,6 +4007,7 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg)
3995
4007
f2fs_warn (sbi , "compression algorithm is successfully set, "
3996
4008
"but current kernel doesn't support this algorithm." );
3997
4009
out :
4010
+ f2fs_up_write (& F2FS_I (inode )-> i_sem );
3998
4011
inode_unlock (inode );
3999
4012
file_end_write (filp );
4000
4013
0 commit comments