diff options
Diffstat (limited to 'fs/xfs/xfs_iomap.c')
-rw-r--r-- | fs/xfs/xfs_iomap.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 39b0fb7f7d6a..f22f0eef907b 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -246,6 +246,19 @@ xfs_iomap_write_direct( retry: error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, resrtextents, tflags, &tp); + /* + * We weren't able to reserve enough space for the direct write. Flush + * any disk space that was being held in the hopes of speeding up the + * filesystem. Historically, we expected callers to have preallocated + * all the space before a direct write, but this is not an absolute + * requirement. We still hold the IOLOCK so we cannot do a sync scan. + */ + if (error == -ENOSPC && !cleared_space) { + cleared_space = true; + error = xfs_inode_free_blocks(ip->i_mount, false); + if (!error) + goto retry; + } if (error) return error; |