aboutsummaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorWeichao Guo <guoweichao@huawei.com>2017-09-29 22:43:23 +0800
committerMister Oyster <oysterized@gmail.com>2017-12-06 16:40:32 +0100
commit454ce2774b62a37bc50bcc3c3b1e7fc8d08342bd (patch)
tree38730f689eb9e44b2d1094a2833856dfa36213ac /fs
parent3e8a09a99bc097c3868e98f09efe06b0f4a1bb0e (diff)
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/f2fs/data.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 424146e6d..8441ba12a 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -832,6 +832,13 @@ int f2fs_preallocate_blocks(struct inode *inode, loff_t pos,
struct f2fs_map_blocks map;
int err = 0;
+ /* convert inline data for Direct I/O*/
+ if (dio) {
+ err = f2fs_convert_inline_inode(inode);
+ if (err)
+ return err;
+ }
+
map.m_lblk = F2FS_BLK_ALIGN(pos);
map.m_len = F2FS_BYTES_TO_BLK(pos + count);
if (map.m_len > map.m_lblk)
@@ -841,15 +848,11 @@ int f2fs_preallocate_blocks(struct inode *inode, loff_t pos,
map.m_next_pgofs = NULL;
- if (dio) {
- err = f2fs_convert_inline_inode(inode);
- if (err)
- return err;
+ if (dio)
return f2fs_map_blocks(inode, &map, 1,
__force_buffered_io(inode, WRITE) ?
F2FS_GET_BLOCK_PRE_AIO :
F2FS_GET_BLOCK_PRE_DIO);
- }
if (pos + count > MAX_INLINE_DATA(inode)) {
err = f2fs_convert_inline_inode(inode);
if (err)