提交 de5307e4 编写于 作者: J Jaegeuk Kim

f2fs: fix dropping inmemory pages in a wrong time

When one reader closes its file while the other writer is doing atomic writes,
f2fs_release_file drops atomic data resulting in an empty commit.
This patch fixes this wrong commit problem by checking openess of the file.

 Process0                       Process1
 				open file
 start atomic write
 write data
 read data
				close file
				f2fs_release_file()
				clear atomic data
 commit atomic write
Reported-by: NMiao Xie <miaoxie@huawei.com>
Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
上级 ff373558
...@@ -1254,6 +1254,14 @@ static long f2fs_fallocate(struct file *file, int mode, ...@@ -1254,6 +1254,14 @@ static long f2fs_fallocate(struct file *file, int mode,
static int f2fs_release_file(struct inode *inode, struct file *filp) static int f2fs_release_file(struct inode *inode, struct file *filp)
{ {
/*
* f2fs_relase_file is called at every close calls. So we should
* not drop any inmemory pages by close called by other process.
*/
if (!(filp->f_mode & FMODE_WRITE) ||
atomic_read(&inode->i_writecount) != 1)
return 0;
/* some remained atomic pages should discarded */ /* some remained atomic pages should discarded */
if (f2fs_is_atomic_file(inode)) if (f2fs_is_atomic_file(inode))
drop_inmem_pages(inode); drop_inmem_pages(inode);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册