@@ -3935,7 +3935,9 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)
39353935 IS_ENCRYPTED (inode ) && f2fs_is_multi_device (sbi )))
39363936 return - EOPNOTSUPP ;
39373937
3938- file_start_write (filp );
3938+ ret = mnt_want_write_file (filp );
3939+ if (ret )
3940+ return ret ;
39393941 inode_lock (inode );
39403942
39413943 if (f2fs_is_atomic_file (inode ) || f2fs_compressed_file (inode ) ||
@@ -4061,7 +4063,7 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)
40614063 f2fs_up_write (& F2FS_I (inode )-> i_gc_rwsem [WRITE ]);
40624064err :
40634065 inode_unlock (inode );
4064- file_end_write (filp );
4066+ mnt_drop_write_file (filp );
40654067
40664068 return ret ;
40674069}
@@ -4115,7 +4117,9 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg)
41154117 option .algorithm >= COMPRESS_MAX )
41164118 return - EINVAL ;
41174119
4118- file_start_write (filp );
4120+ ret = mnt_want_write_file (filp );
4121+ if (ret )
4122+ return ret ;
41194123 inode_lock (inode );
41204124
41214125 f2fs_down_write (& F2FS_I (inode )-> i_sem );
@@ -4154,7 +4158,7 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg)
41544158out :
41554159 f2fs_up_write (& F2FS_I (inode )-> i_sem );
41564160 inode_unlock (inode );
4157- file_end_write (filp );
4161+ mnt_drop_write_file (filp );
41584162
41594163 return ret ;
41604164}
@@ -4211,7 +4215,9 @@ static int f2fs_ioc_decompress_file(struct file *filp)
42114215
42124216 f2fs_balance_fs (sbi , true);
42134217
4214- file_start_write (filp );
4218+ ret = mnt_want_write_file (filp );
4219+ if (ret )
4220+ return ret ;
42154221 inode_lock (inode );
42164222
42174223 if (!f2fs_is_compress_backend_ready (inode )) {
@@ -4266,7 +4272,7 @@ static int f2fs_ioc_decompress_file(struct file *filp)
42664272 f2fs_update_time (sbi , REQ_TIME );
42674273out :
42684274 inode_unlock (inode );
4269- file_end_write (filp );
4275+ mnt_drop_write_file (filp );
42704276
42714277 return ret ;
42724278}
@@ -4288,7 +4294,9 @@ static int f2fs_ioc_compress_file(struct file *filp)
42884294
42894295 f2fs_balance_fs (sbi , true);
42904296
4291- file_start_write (filp );
4297+ ret = mnt_want_write_file (filp );
4298+ if (ret )
4299+ return ret ;
42924300 inode_lock (inode );
42934301
42944302 if (!f2fs_is_compress_backend_ready (inode )) {
@@ -4344,7 +4352,7 @@ static int f2fs_ioc_compress_file(struct file *filp)
43444352 f2fs_update_time (sbi , REQ_TIME );
43454353out :
43464354 inode_unlock (inode );
4347- file_end_write (filp );
4355+ mnt_drop_write_file (filp );
43484356
43494357 return ret ;
43504358}
0 commit comments