diff options
author | Chao Yu <yuchao0@huawei.com> | 2016-05-09 13:56:33 +0200 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-05-11 18:56:34 +0200 |
commit | 0fac558b96584799876498248020dc49a98bd131 (patch) | |
tree | e0de3f5ec34c7b4a98a090aa3e403ebb251d60ae | |
parent | f2fs: use mnt_{want,drop}_write_file in ioctl (diff) | |
download | linux-0fac558b96584799876498248020dc49a98bd131.tar.xz linux-0fac558b96584799876498248020dc49a98bd131.zip |
f2fs: make atomic/volatile operation exclusive
atomic/volatile ioctl interfaces are exposed to user like other file
operation interface, it needs to make them getting exclusion against
to each other to avoid potential conflict among these operations
in concurrent scenario.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fs/f2fs/file.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 2f8f225ddbc5..f67ca62c4f2a 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1363,6 +1363,8 @@ static int f2fs_ioc_start_atomic_write(struct file *filp) if (ret) return ret; + inode_lock(inode); + if (f2fs_is_atomic_file(inode)) goto out; @@ -1383,6 +1385,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp) if (ret) clear_inode_flag(F2FS_I(inode), FI_ATOMIC_FILE); out: + inode_unlock(inode); mnt_drop_write_file(filp); return ret; } @@ -1399,6 +1402,8 @@ static int f2fs_ioc_commit_atomic_write(struct file *filp) if (ret) return ret; + inode_lock(inode); + if (f2fs_is_volatile_file(inode)) goto err_out; @@ -1413,6 +1418,7 @@ static int f2fs_ioc_commit_atomic_write(struct file *filp) ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 0, true); err_out: + inode_unlock(inode); mnt_drop_write_file(filp); return ret; } @@ -1429,6 +1435,8 @@ static int f2fs_ioc_start_volatile_write(struct file *filp) if (ret) return ret; + inode_lock(inode); + if (f2fs_is_volatile_file(inode)) goto out; @@ -1439,6 +1447,7 @@ static int f2fs_ioc_start_volatile_write(struct file *filp) set_inode_flag(F2FS_I(inode), FI_VOLATILE_FILE); f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); out: + inode_unlock(inode); mnt_drop_write_file(filp); return ret; } @@ -1455,6 +1464,8 @@ static int f2fs_ioc_release_volatile_write(struct file *filp) if (ret) return ret; + inode_lock(inode); + if (!f2fs_is_volatile_file(inode)) goto out; @@ -1465,6 +1476,7 @@ static int f2fs_ioc_release_volatile_write(struct file *filp) ret = punch_hole(inode, 0, F2FS_BLKSIZE); out: + inode_unlock(inode); mnt_drop_write_file(filp); return ret; } @@ -1481,6 +1493,8 @@ static int f2fs_ioc_abort_volatile_write(struct file *filp) if (ret) return ret; + inode_lock(inode); + if (f2fs_is_atomic_file(inode)) drop_inmem_pages(inode); if (f2fs_is_volatile_file(inode)) { @@ -1488,6 +1502,8 @@ static int f2fs_ioc_abort_volatile_write(struct file *filp) ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 0, true); } + inode_unlock(inode); + mnt_drop_write_file(filp); f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); return ret; |