xfs: free cowblocks and retry on buffered write ENOSPC
authorBrian Foster <bfoster@redhat.com>
Sun, 17 Sep 2017 21:06:34 +0000 (14:06 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Sep 2017 06:19:58 +0000 (08:19 +0200)
commit cf2cb7845d6e101cb17bd62f8aa08cd514fc8988 upstream.

XFS runs an eofblocks reclaim scan before returning an ENOSPC error to
userspace for buffered writes. This facilitates aggressive speculative
preallocation without causing user visible side effects such as
premature ENOSPC.

Run a cowblocks scan in the same situation to reclaim lingering COW fork
preallocation throughout the filesystem.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/xfs/xfs_file.c

index 2e04b1cdb0d249cdc18003ab7bcf90ca9291f3cf..586b398f268d28ee42e610a89c5b6e1c2d1eee6b 100644 (file)
@@ -729,6 +729,7 @@ write_retry:
                xfs_rw_iunlock(ip, iolock);
                eofb.eof_flags = XFS_EOF_FLAGS_SYNC;
                xfs_icache_free_eofblocks(ip->i_mount, &eofb);
+               xfs_icache_free_cowblocks(ip->i_mount, &eofb);
                goto write_retry;
        }