From: Chao Yu Date: Tue, 28 Jan 2014 02:29:26 +0000 (+0800) Subject: f2fs: use inode mutex to keep atomicity of f2fs_falloc X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3375f696bd9cfdfd385e2460a9cf021d8ef01eab;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git f2fs: use inode mutex to keep atomicity of f2fs_falloc 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 Signed-off-by: Jaegeuk Kim --- diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 0dfcef53a6ed..00f937ec4794 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -560,6 +560,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 @@ -569,6 +571,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; }