提交 dacb473a 编写于 作者: Y Yan 提交者: Chris Mason

Btrfs: Fix hole creation in file_write

Signed-off-by: NChris Mason <chris.mason@oracle.com>
上级 47b0c4f8
...@@ -265,16 +265,14 @@ static int noinline dirty_and_release_pages(struct btrfs_trans_handle *trans, ...@@ -265,16 +265,14 @@ static int noinline dirty_and_release_pages(struct btrfs_trans_handle *trans,
set_extent_uptodate(io_tree, start_pos, end_of_last_block, GFP_NOFS); set_extent_uptodate(io_tree, start_pos, end_of_last_block, GFP_NOFS);
/* FIXME...EIEIO, ENOSPC and more */ /* FIXME...EIEIO, ENOSPC and more */
/* insert any holes we need to create */ /* insert any holes we need to create */
if (inode->i_size < start_pos) { if (isize < end_pos) {
u64 last_pos_in_file; u64 last_pos_in_file;
u64 hole_size; u64 hole_size;
u64 mask = root->sectorsize - 1; u64 mask = root->sectorsize - 1;
last_pos_in_file = (isize + mask) & ~mask; last_pos_in_file = (isize + mask) & ~mask;
hole_size = (end_pos - last_pos_in_file + mask) & ~mask; hole_size = (end_pos - last_pos_in_file + mask) & ~mask;
if (last_pos_in_file < end_pos) {
if (last_pos_in_file < start_pos) {
err = btrfs_drop_extents(trans, root, inode, err = btrfs_drop_extents(trans, root, inode,
last_pos_in_file, last_pos_in_file,
last_pos_in_file + hole_size, last_pos_in_file + hole_size,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册