https://github.com/torvalds/linux
Revision f7f43cc84152e53b5687cd0eb8823310ba065524 authored by Chris Mason on 11 October 2011, 15:41:40 UTC, committed by Chris Mason on 11 October 2011, 15:45:55 UTC
The btrfs file defrag code will loop through the extents and
force COW on them.  But there is a concurrent truncate in the middle of
the defrag, it might end up defragging the same range over and over
again.

The problem is that writepage won't go through and do anything on pages
past i_size, so the cow won't happen, so the file will appear to still
be fragmented.  defrag will end up hitting the same extents again and
again.

In the worst case, the truncate can actually live lock with the defrag
because the defrag keeps creating new ordered extents which the truncate
code keeps waiting on.

The fix here is to make defrag check for i_size inside the main loop,
instead of just once before the looping starts.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
1 parent 2a0f7f5
Raw File
Tip revision: f7f43cc84152e53b5687cd0eb8823310ba065524 authored by Chris Mason on 11 October 2011, 15:41:40 UTC
Btrfs: make sure not to defrag extents past i_size
Tip revision: f7f43cc
Kconfig
#
# For a description of the syntax of this configuration file,
# see Documentation/kbuild/kconfig-language.txt.
#
mainmenu "Linux/$ARCH $KERNELVERSION Kernel Configuration"

config SRCARCH
	string
	option env="SRCARCH"

source "arch/$SRCARCH/Kconfig"
back to top