Commit 92dffd01 authored by Jaegeuk Kim's avatar Jaegeuk Kim
Browse files

f2fs: convert inline_data when i_size becomes large



If i_size becomes large outside of MAX_INLINE_DATA, we shoud convert the inode.
Otherwise, we can make some dirty pages during the truncation, and those pages
will be written through f2fs_write_data_page.
At that moment, the inode has still inline_data, so that it tries to write non-
zero pages into inline_data area.
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 764d2c80
...@@ -522,6 +522,12 @@ void f2fs_truncate(struct inode *inode) ...@@ -522,6 +522,12 @@ void f2fs_truncate(struct inode *inode)
trace_f2fs_truncate(inode); trace_f2fs_truncate(inode);
/* we should check inline_data size */
if (f2fs_has_inline_data(inode) && !f2fs_may_inline(inode)) {
if (f2fs_convert_inline_inode(inode))
return;
}
if (!truncate_blocks(inode, i_size_read(inode), true)) { if (!truncate_blocks(inode, i_size_read(inode), true)) {
inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_mtime = inode->i_ctime = CURRENT_TIME;
mark_inode_dirty(inode); mark_inode_dirty(inode);
......
...@@ -24,6 +24,9 @@ bool f2fs_may_inline(struct inode *inode) ...@@ -24,6 +24,9 @@ bool f2fs_may_inline(struct inode *inode)
if (!S_ISREG(inode->i_mode)) if (!S_ISREG(inode->i_mode))
return false; return false;
if (i_size_read(inode) > MAX_INLINE_DATA)
return false;
return true; return true;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment