diff options
author | Weichao Guo <guoweichao@huawei.com> | 2017-09-29 22:43:23 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2017-10-10 12:49:52 -0700 |
commit | 71ad682c1c295f1ba4eec7478384138b6ad4dab2 (patch) | |
tree | 5bf2e1c1375b2f8e7290df32f4a7f8dee58e6334 | |
parent | 71cb4afff80cee2b0f0dfda32f55e4e8d4f1153d (diff) | |
download | linux-71ad682c1c295f1ba4eec7478384138b6ad4dab2.tar.gz linux-71ad682c1c295f1ba4eec7478384138b6ad4dab2.tar.bz2 linux-71ad682c1c295f1ba4eec7478384138b6ad4dab2.zip |
f2fs: convert inline data for direct I/O & FI_NO_PREALLOC
In FI_NO_PREALLOC cases, direct I/O path may allocate blocks for an
inode but keep its inline data flag. This inconsistency may trigger
vfs clear_inode nrpages bug_on when evicting the inode. We should
convert inline data first in this case.
Signed-off-by: Weichao Guo <guoweichao@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fs/f2fs/data.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 9b68fb7eb5f1..a6288e276ff9 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -833,6 +833,13 @@ int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *from) struct f2fs_map_blocks map; int err = 0; + /* convert inline data for Direct I/O*/ + if (iocb->ki_flags & IOCB_DIRECT) { + err = f2fs_convert_inline_inode(inode); + if (err) + return err; + } + if (is_inode_flag_set(inode, FI_NO_PREALLOC)) return 0; @@ -845,15 +852,11 @@ int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *from) map.m_next_pgofs = NULL; - if (iocb->ki_flags & IOCB_DIRECT) { - err = f2fs_convert_inline_inode(inode); - if (err) - return err; + if (iocb->ki_flags & IOCB_DIRECT) return f2fs_map_blocks(inode, &map, 1, __force_buffered_io(inode, WRITE) ? F2FS_GET_BLOCK_PRE_AIO : F2FS_GET_BLOCK_PRE_DIO); - } if (iocb->ki_pos + iov_iter_count(from) > MAX_INLINE_DATA(inode)) { err = f2fs_convert_inline_inode(inode); if (err) |