xfs: flush delayed allcoation blocks on ENOSPC in create

If we are creating lots of small files, we can fail to get
a reservation for inode create earlier than we should due to
EOF preallocation done during delayed allocation reservation.
Hence on the first reservation ENOSPC failure flush all the
delayed allocation blocks out of the system and retry.

This fixes the last commonly triggered spurious ENOSPC issue
that has been reported.

Signed-off-by: Dave Chinner <david@fromorbit.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>

authored by

Dave Chinner and committed by
Christoph Hellwig
153fec43 e43afd72

+7
+7
fs/xfs/xfs_vnodeops.c
··· 1457 error = xfs_trans_reserve(tp, resblks, log_res, 0, 1458 XFS_TRANS_PERM_LOG_RES, log_count); 1459 if (error == ENOSPC) { 1460 resblks = 0; 1461 error = xfs_trans_reserve(tp, 0, log_res, 0, 1462 XFS_TRANS_PERM_LOG_RES, log_count);
··· 1457 error = xfs_trans_reserve(tp, resblks, log_res, 0, 1458 XFS_TRANS_PERM_LOG_RES, log_count); 1459 if (error == ENOSPC) { 1460 + /* flush outstanding delalloc blocks and retry */ 1461 + xfs_flush_inodes(dp); 1462 + error = xfs_trans_reserve(tp, resblks, XFS_CREATE_LOG_RES(mp), 0, 1463 + XFS_TRANS_PERM_LOG_RES, XFS_CREATE_LOG_COUNT); 1464 + } 1465 + if (error == ENOSPC) { 1466 + /* No space at all so try a "no-allocation" reservation */ 1467 resblks = 0; 1468 error = xfs_trans_reserve(tp, 0, log_res, 0, 1469 XFS_TRANS_PERM_LOG_RES, log_count);