summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2016-10-11 22:57:05 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2016-11-23 12:10:55 -0800
commitb691d98fdd4cc2514c60fd6975e6016da203e64f (patch)
treed76514a5fdeb82f28472b28521c1315ec8d912cd
parent58736fa60f6ae659ac72da8b1580c308b47e8edd (diff)
downloadlinux-b691d98fdd4cc2514c60fd6975e6016da203e64f.tar.bz2
f2fs: fix to update largest extent under lock
In order to avoid racing problem, make largest extent cache being updated under lock. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/inode.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index d7369895a78a..1fbebcb33a9d 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -252,6 +252,7 @@ retry:
int update_inode(struct inode *inode, struct page *node_page)
{
struct f2fs_inode *ri;
+ struct extent_tree *et = F2FS_I(inode)->extent_tree;
f2fs_inode_synced(inode);
@@ -267,11 +268,13 @@ int update_inode(struct inode *inode, struct page *node_page)
ri->i_size = cpu_to_le64(i_size_read(inode));
ri->i_blocks = cpu_to_le64(inode->i_blocks);
- if (F2FS_I(inode)->extent_tree)
- set_raw_extent(&F2FS_I(inode)->extent_tree->largest,
- &ri->i_ext);
- else
+ if (et) {
+ read_lock(&et->lock);
+ set_raw_extent(&et->largest, &ri->i_ext);
+ read_unlock(&et->lock);
+ } else {
memset(&ri->i_ext, 0, sizeof(ri->i_ext));
+ }
set_raw_inline(inode, ri);
ri->i_atime = cpu_to_le64(inode->i_atime.tv_sec);