Commit 26dc3d44 authored by Jaegeuk Kim's avatar Jaegeuk Kim

f2fs: unset atomic/volatile flag in f2fs_release_file

The atomic/volatile operation should be done in pair of start and commit
ioctl.
For example, if a killed process remains open-ended atomic operation, we should
drop its flag as well as its atomic data. Otherwise, if sqlite initiates another
operation which doesn't require atomic writes, it will lose every data, since
f2fs still treats with them as atomic writes; nobody will trigger its commit.
Reported-by: default avatarMiao Xie <miaoxie@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent de5307e4
...@@ -1266,6 +1266,7 @@ static int f2fs_release_file(struct inode *inode, struct file *filp) ...@@ -1266,6 +1266,7 @@ static int f2fs_release_file(struct inode *inode, struct file *filp)
if (f2fs_is_atomic_file(inode)) if (f2fs_is_atomic_file(inode))
drop_inmem_pages(inode); drop_inmem_pages(inode);
if (f2fs_is_volatile_file(inode)) { if (f2fs_is_volatile_file(inode)) {
clear_inode_flag(F2FS_I(inode), FI_VOLATILE_FILE);
set_inode_flag(F2FS_I(inode), FI_DROP_CACHE); set_inode_flag(F2FS_I(inode), FI_DROP_CACHE);
filemap_fdatawrite(inode->i_mapping); filemap_fdatawrite(inode->i_mapping);
clear_inode_flag(F2FS_I(inode), FI_DROP_CACHE); clear_inode_flag(F2FS_I(inode), FI_DROP_CACHE);
...@@ -1449,10 +1450,8 @@ static int f2fs_ioc_abort_volatile_write(struct file *filp) ...@@ -1449,10 +1450,8 @@ static int f2fs_ioc_abort_volatile_write(struct file *filp)
if (ret) if (ret)
return ret; return ret;
if (f2fs_is_atomic_file(inode)) { if (f2fs_is_atomic_file(inode))
clear_inode_flag(F2FS_I(inode), FI_ATOMIC_FILE);
drop_inmem_pages(inode); drop_inmem_pages(inode);
}
if (f2fs_is_volatile_file(inode)) { if (f2fs_is_volatile_file(inode)) {
clear_inode_flag(F2FS_I(inode), FI_VOLATILE_FILE); clear_inode_flag(F2FS_I(inode), FI_VOLATILE_FILE);
ret = f2fs_sync_file(filp, 0, LLONG_MAX, 0); ret = f2fs_sync_file(filp, 0, LLONG_MAX, 0);
......
...@@ -239,6 +239,8 @@ void drop_inmem_pages(struct inode *inode) ...@@ -239,6 +239,8 @@ void drop_inmem_pages(struct inode *inode)
{ {
struct f2fs_inode_info *fi = F2FS_I(inode); struct f2fs_inode_info *fi = F2FS_I(inode);
clear_inode_flag(F2FS_I(inode), FI_ATOMIC_FILE);
mutex_lock(&fi->inmem_lock); mutex_lock(&fi->inmem_lock);
__revoke_inmem_pages(inode, &fi->inmem_pages, true, false); __revoke_inmem_pages(inode, &fi->inmem_pages, true, false);
mutex_unlock(&fi->inmem_lock); mutex_unlock(&fi->inmem_lock);
......
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