ext4: flush delalloc blocks when space is low
authorEric Sandeen <sandeen@redhat.com>
Wed, 23 Dec 2009 12:58:12 +0000 (07:58 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 26 Apr 2010 14:41:36 +0000 (07:41 -0700)
commit5d40c8cbd548e3259589d364dd5bf64ab504f147
tree9acb2b80e86321180b60a198ac22ceeeeeb2c4e4
parentb78a38dca6e04634ddc718e315712b45abcf92fd
ext4: flush delalloc blocks when space is low

commit c8afb44682fcef6273e8b8eb19fab13ddd05b386 upstream.

Creating many small files in rapid succession on a small
filesystem can lead to spurious ENOSPC; on a 104MB filesystem:

for i in `seq 1 22500`; do
    echo -n > $SCRATCH_MNT/$i
    echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > $SCRATCH_MNT/$i
done

leads to ENOSPC even though after a sync, 40% of the fs is free
again.

This is because we reserve worst-case metadata for delalloc writes,
and when data is allocated that worst-case reservation is not
usually needed.

When freespace is low, kicking off an async writeback will start
converting that worst-case space usage into something more realistic,
almost always freeing up space to continue.

This resolves the testcase for me, and survives all 4 generic
ENOSPC tests in xfstests.

We'll still need a hard synchronous sync to squeeze out the last bit,
but this fixes things up to a large degree.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: maximilian attems <max@stro.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/ext4/inode.c