Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 35b94063 authored by Sheng Yong's avatar Sheng Yong Committed by Jaegeuk Kim
Browse files

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: default avatarSheng Yong <shengyong1@huawei.com>
Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent b6453fcb
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -861,8 +861,14 @@ int f2fs_preallocate_blocks(struct inode *inode, loff_t pos,
		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;
}