diff options
author | Sheng Yong <shengyong1@huawei.com> | 2017-11-22 18:23:39 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2018-01-02 19:27:27 -0800 |
commit | 25006645d2e79422b6b3f26e5a82b6cbb5d49a0e (patch) | |
tree | 51175b627d73cd92af3ce2be4143f23c92a0a1d0 /fs/f2fs/data.c | |
parent | f6df8f234e2502b7d8c6de42e066e01f908318cc (diff) | |
download | lwn-25006645d2e79422b6b3f26e5a82b6cbb5d49a0e.tar.gz lwn-25006645d2e79422b6b3f26e5a82b6cbb5d49a0e.zip |
f2fs: still write data if preallocate only partial blocks
If there is not enough space left, f2fs_preallocate_blocks may only
preallocte partial blocks. As a result, the write operation fails
but i_blocks is not 0. To avoid this, f2fs should write data in
non-preallocation way and write as many data as the size of i_blocks.
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/data.c')
-rw-r--r-- | fs/f2fs/data.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 516fa0d3ff9c..3fa20a932dd7 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -862,8 +862,14 @@ int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *from) if (err) return err; } - if (!f2fs_has_inline_data(inode)) - return f2fs_map_blocks(inode, &map, 1, F2FS_GET_BLOCK_PRE_AIO); + if (!f2fs_has_inline_data(inode)) { + err = f2fs_map_blocks(inode, &map, 1, F2FS_GET_BLOCK_PRE_AIO); + if (map.m_len > 0 && err == -ENOSPC) { + set_inode_flag(inode, FI_NO_PREALLOC); + err = 0; + } + return err; + } return err; } |