Skip to content

Commit

Permalink
btrfs: Fix a data space underflow warning
Browse files Browse the repository at this point in the history
Even with quota disabled, generic/127 will trigger a kernel warning by
underflow data space info.

The bug is caused by buffered write, which in case of short copy, the
start parameter for btrfs_delalloc_release_space() is wrong, and
round_up/down() in btrfs_delalloc_release() extents the range to page
aligned, decreasing one more page than expected.

This patch will fix it by passing correct start.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
  • Loading branch information
Qu Wenruo authored and Chris Mason committed Nov 3, 2015
1 parent 90ce321 commit 485290a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1604,12 +1604,17 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
BTRFS_I(inode)->outstanding_extents++;
spin_unlock(&BTRFS_I(inode)->lock);
}
if (only_release_metadata)
if (only_release_metadata) {
btrfs_delalloc_release_metadata(inode,
release_bytes);
else
btrfs_delalloc_release_space(inode, pos,
} else {
u64 __pos;

__pos = round_down(pos, root->sectorsize) +
(dirty_pages << PAGE_CACHE_SHIFT);
btrfs_delalloc_release_space(inode, __pos,
release_bytes);
}
}

release_bytes = dirty_pages << PAGE_CACHE_SHIFT;
Expand Down

0 comments on commit 485290a

Please sign in to comment.