* [f2fs-dev] [PATCH] f2fs: use inode mutex to keep atomicity of f2fs_falloc
@ 2014-01-28 2:29 Chao Yu
2014-01-28 6:00 ` Jaegeuk Kim
0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2014-01-28 2:29 UTC (permalink / raw)
To: ???; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel
Previously without protection of inode mutex, f2fs_falloc and other data
correlated operations will interfere with each other.
So let's use inode mutex to keep atomicity of f2fs_falloc.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
fs/f2fs/file.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 85e91ca..ece380f 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -559,6 +559,8 @@ static long f2fs_fallocate(struct file *file, int mode,
if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
return -EOPNOTSUPP;
+ mutex_lock(&inode->i_mutex);
+
if (mode & FALLOC_FL_PUNCH_HOLE)
ret = punch_hole(inode, offset, len);
else
@@ -568,6 +570,9 @@ static long f2fs_fallocate(struct file *file, int mode,
inode->i_mtime = inode->i_ctime = CURRENT_TIME;
mark_inode_dirty(inode);
}
+
+ mutex_unlock(&inode->i_mutex);
+
trace_f2fs_fallocate(inode, mode, offset, len, ret);
return ret;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: use inode mutex to keep atomicity of f2fs_falloc
2014-01-28 2:29 [f2fs-dev] [PATCH] f2fs: use inode mutex to keep atomicity of f2fs_falloc Chao Yu
@ 2014-01-28 6:00 ` Jaegeuk Kim
2014-01-28 8:51 ` Chao Yu
0 siblings, 1 reply; 3+ messages in thread
From: Jaegeuk Kim @ 2014-01-28 6:00 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel
Hi,
2014-01-28 (화), 10:29 +0800, Chao Yu:
> Previously without protection of inode mutex, f2fs_falloc and other data
> correlated operations will interfere with each other.
Could you explain a little bit more what kind of scenarios wrt this?
> So let's use inode mutex to keep atomicity of f2fs_falloc.
>
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> ---
> fs/f2fs/file.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 85e91ca..ece380f 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -559,6 +559,8 @@ static long f2fs_fallocate(struct file *file, int mode,
> if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
> return -EOPNOTSUPP;
>
> + mutex_lock(&inode->i_mutex);
> +
> if (mode & FALLOC_FL_PUNCH_HOLE)
> ret = punch_hole(inode, offset, len);
> else
> @@ -568,6 +570,9 @@ static long f2fs_fallocate(struct file *file, int mode,
> inode->i_mtime = inode->i_ctime = CURRENT_TIME;
> mark_inode_dirty(inode);
> }
> +
> + mutex_unlock(&inode->i_mutex);
> +
> trace_f2fs_fallocate(inode, mode, offset, len, ret);
> return ret;
> }
--
Jaegeuk Kim
Samsung
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [f2fs-dev] [PATCH] f2fs: use inode mutex to keep atomicity of f2fs_falloc
2014-01-28 6:00 ` Jaegeuk Kim
@ 2014-01-28 8:51 ` Chao Yu
0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2014-01-28 8:51 UTC (permalink / raw)
To: jaegeuk.kim; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel
Hi,
> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk.kim@samsung.com]
> Sent: Tuesday, January 28, 2014 2:00 PM
> To: Chao Yu
> Cc: linux-fsdevel@vger.kernel.org; linux-kernel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net
> Subject: Re: [f2fs-dev] [PATCH] f2fs: use inode mutex to keep atomicity of f2fs_falloc
>
> Hi,
>
> 2014-01-28 (화), 10:29 +0800, Chao Yu:
> > Previously without protection of inode mutex, f2fs_falloc and other data
> > correlated operations will interfere with each other.
>
> Could you explain a little bit more what kind of scenarios wrt this?
1. Without protection of i_mutex, status(e.g. i_size) of inode could be changed
by other operation(e.g. vfs_write()/vfs_truncate()) when we fallocate a file, it
may cause us walk into wrong branch code after we check these status of inode,
and vice versa.
2. i_size_write()/inode_newsize_ok() is called in f2fs_fallocate(), usually we
use i_mutex to protect these functions.
>
>
> > So let's use inode mutex to keep atomicity of f2fs_falloc.
> >
> > Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> > ---
> > fs/f2fs/file.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> > index 85e91ca..ece380f 100644
> > --- a/fs/f2fs/file.c
> > +++ b/fs/f2fs/file.c
> > @@ -559,6 +559,8 @@ static long f2fs_fallocate(struct file *file, int mode,
> > if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
> > return -EOPNOTSUPP;
> >
> > + mutex_lock(&inode->i_mutex);
> > +
> > if (mode & FALLOC_FL_PUNCH_HOLE)
> > ret = punch_hole(inode, offset, len);
> > else
> > @@ -568,6 +570,9 @@ static long f2fs_fallocate(struct file *file, int mode,
> > inode->i_mtime = inode->i_ctime = CURRENT_TIME;
> > mark_inode_dirty(inode);
> > }
> > +
> > + mutex_unlock(&inode->i_mutex);
> > +
> > trace_f2fs_fallocate(inode, mode, offset, len, ret);
> > return ret;
> > }
>
> --
> Jaegeuk Kim
> Samsung
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-01-28 8:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-28 2:29 [f2fs-dev] [PATCH] f2fs: use inode mutex to keep atomicity of f2fs_falloc Chao Yu
2014-01-28 6:00 ` Jaegeuk Kim
2014-01-28 8:51 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).