Btrfs: move btrfs_truncate_page to btrfs_cont_expand instead of btrfs_truncate
authorJosef Bacik <jbacik@fusionio.com>
Mon, 17 Jun 2013 21:14:39 +0000 (17:14 -0400)
committerJosef Bacik <jbacik@fusionio.com>
Mon, 1 Jul 2013 12:52:33 +0000 (08:52 -0400)
commita71754fc68f740b7ed46bb83123c63fbbc130611
treec39655c68a713d4707cb476ac28702bb4e302ed2
parent0b08851fdaa5f9f74357345d7be44ea584665d5f
Btrfs: move btrfs_truncate_page to btrfs_cont_expand instead of btrfs_truncate

This has plagued us forever and I'm so over working around it.  When we truncate
down to a non-page aligned offset we will call btrfs_truncate_page to zero out
the end of the page and write it back to disk, this will keep us from exposing
stale data if we truncate back up from that point.  The problem with this is it
requires data space to do this, and people don't really expect to get ENOSPC
from truncate() for these sort of things.  This also tends to bite the orphan
cleanup stuff too which keeps people from mounting.  To get around this we can
just move this into btrfs_cont_expand() to make sure if we are truncating up
from a non-page size aligned i_size we will zero out the rest of this page so
that we don't expose stale data.  This will give ENOSPC if you try to truncate()
up or if you try to write past the end of isize, which is much more reasonable.
This fixes xfstests generic/083 failing to mount because of the orphan cleanup
failing.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
fs/btrfs/extent_io.c
fs/btrfs/file.c
fs/btrfs/inode.c