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>
This commit is contained in:
parent
47ee9b2598
commit
f130dbb98a
1 changed files with 8 additions and 2 deletions
|
@ -860,8 +860,14 @@ int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *from)
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (!f2fs_has_inline_data(inode))
|
if (!f2fs_has_inline_data(inode)) {
|
||||||
return f2fs_map_blocks(inode, &map, 1, F2FS_GET_BLOCK_PRE_AIO);
|
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;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue