Skip to content

Commit

Permalink
f2fs: fix to use mnt_{want,drop}_write_file replace file_{start,end}_…
Browse files Browse the repository at this point in the history
…wrtie

mnt_{want,drop}_write_file is more suitable than
file_{start,end}_wrtie and also is consistent with
other ioctl operations.

Signed-off-by: Zhiguo Niu <[email protected]>
Reviewed-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
Zhiguo Niu authored and Jaegeuk Kim committed Jun 18, 2024
1 parent 6aeb084 commit 1efb7c8
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions fs/f2fs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -3935,7 +3935,9 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)
IS_ENCRYPTED(inode) && f2fs_is_multi_device(sbi)))
return -EOPNOTSUPP;

file_start_write(filp);
ret = mnt_want_write_file(filp);
if (ret)
return ret;
inode_lock(inode);

if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode) ||
Expand Down Expand Up @@ -4061,7 +4063,7 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)
f2fs_up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
err:
inode_unlock(inode);
file_end_write(filp);
mnt_drop_write_file(filp);

return ret;
}
Expand Down Expand Up @@ -4115,7 +4117,9 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg)
option.algorithm >= COMPRESS_MAX)
return -EINVAL;

file_start_write(filp);
ret = mnt_want_write_file(filp);
if (ret)
return ret;
inode_lock(inode);

f2fs_down_write(&F2FS_I(inode)->i_sem);
Expand Down Expand Up @@ -4154,7 +4158,7 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg)
out:
f2fs_up_write(&F2FS_I(inode)->i_sem);
inode_unlock(inode);
file_end_write(filp);
mnt_drop_write_file(filp);

return ret;
}
Expand Down Expand Up @@ -4211,7 +4215,9 @@ static int f2fs_ioc_decompress_file(struct file *filp)

f2fs_balance_fs(sbi, true);

file_start_write(filp);
ret = mnt_want_write_file(filp);
if (ret)
return ret;
inode_lock(inode);

if (!f2fs_is_compress_backend_ready(inode)) {
Expand Down Expand Up @@ -4266,7 +4272,7 @@ static int f2fs_ioc_decompress_file(struct file *filp)
f2fs_update_time(sbi, REQ_TIME);
out:
inode_unlock(inode);
file_end_write(filp);
mnt_drop_write_file(filp);

return ret;
}
Expand All @@ -4288,7 +4294,9 @@ static int f2fs_ioc_compress_file(struct file *filp)

f2fs_balance_fs(sbi, true);

file_start_write(filp);
ret = mnt_want_write_file(filp);
if (ret)
return ret;
inode_lock(inode);

if (!f2fs_is_compress_backend_ready(inode)) {
Expand Down Expand Up @@ -4344,7 +4352,7 @@ static int f2fs_ioc_compress_file(struct file *filp)
f2fs_update_time(sbi, REQ_TIME);
out:
inode_unlock(inode);
file_end_write(filp);
mnt_drop_write_file(filp);

return ret;
}
Expand Down

0 comments on commit 1efb7c8

Please sign in to comment.