aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2014-04-28 21:03:03 -0400
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2014-05-06 21:21:58 -0400
commit8aa6f1c5bd7043734fff1961a4795da9cc5d0f50 (patch)
treec2b9ae38929b9511919fabda9429eec05e75d5c2 /fs/f2fs
parent817202d937e6cca7e60f42e6495aaa51d70d9d7e (diff)
f2fs: fix to truncate inline data in inode page when setattr
Previous we do not truncate inline data in inode page when setattr, so following case could still read the inline data which has already truncated: 1.write inline data 2.ftruncate size to 0 3.ftruncate size to max inline data size 4.read from offset 0 This patch introduces truncate_inline_data() to fix this problem. change log from v1: o fix a bug and do not truncate first page data after truncate inline data. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/f2fs.h1
-rw-r--r--fs/f2fs/file.c3
-rw-r--r--fs/f2fs/inline.c18
3 files changed, 22 insertions, 0 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 2b67679f88b6..676a2c6ccec7 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1410,5 +1410,6 @@ bool f2fs_may_inline(struct inode *);
1410int f2fs_read_inline_data(struct inode *, struct page *); 1410int f2fs_read_inline_data(struct inode *, struct page *);
1411int f2fs_convert_inline_data(struct inode *, pgoff_t); 1411int f2fs_convert_inline_data(struct inode *, pgoff_t);
1412int f2fs_write_inline_data(struct inode *, struct page *, unsigned int); 1412int f2fs_write_inline_data(struct inode *, struct page *, unsigned int);
1413void truncate_inline_data(struct inode *, u64);
1413int recover_inline_data(struct inode *, struct page *); 1414int recover_inline_data(struct inode *, struct page *);
1414#endif 1415#endif
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index b9f4fbf5c07e..d97e5c458f36 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -369,6 +369,9 @@ static void truncate_partial_data_page(struct inode *inode, u64 from)
369 unsigned offset = from & (PAGE_CACHE_SIZE - 1); 369 unsigned offset = from & (PAGE_CACHE_SIZE - 1);
370 struct page *page; 370 struct page *page;
371 371
372 if (f2fs_has_inline_data(inode))
373 return truncate_inline_data(inode, from);
374
372 if (!offset) 375 if (!offset)
373 return; 376 return;
374 377
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 3258c7cf00d5..d215dbb09f07 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -176,6 +176,24 @@ int f2fs_write_inline_data(struct inode *inode,
176 return 0; 176 return 0;
177} 177}
178 178
179void truncate_inline_data(struct inode *inode, u64 from)
180{
181 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
182 struct page *ipage;
183
184 if (from >= MAX_INLINE_DATA)
185 return;
186
187 ipage = get_node_page(sbi, inode->i_ino);
188 if (IS_ERR(ipage))
189 return;
190
191 zero_user_segment(ipage, INLINE_DATA_OFFSET + from,
192 INLINE_DATA_OFFSET + MAX_INLINE_DATA);
193 set_page_dirty(ipage);
194 f2fs_put_page(ipage, 1);
195}
196
179int recover_inline_data(struct inode *inode, struct page *npage) 197int recover_inline_data(struct inode *inode, struct page *npage)
180{ 198{
181 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 199 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);