Commit f2a459565b02b60408f3f2e5ca992a031319712b

Authored by Dave Chinner
Committed by Ben Myers
1 parent eb178619f9

xfs: limit speculative prealloc near ENOSPC thresholds

There is a window on small filesytsems where specualtive
preallocation can be larger than that ENOSPC throttling thresholds,
resulting in specualtive preallocation trying to reserve more space
than there is space available. This causes immediate ENOSPC to be
triggered, prealloc to be turned off and flushing to occur. One the
next write (i.e. next 4k page), we do exactly the same thing, and so
effective drive into synchronous 4k writes by triggering ENOSPC
flushing on every page while in the window between the prealloc size
and the ENOSPC prealloc throttle threshold.

Fix this by checking to see if the prealloc size would consume all
free space, and throttle it appropriately to avoid premature
ENOSPC...

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Ben Myers <bpm@sgi.com>

Showing 1 changed file with 9 additions and 0 deletions Side-by-side Diff

... ... @@ -351,6 +351,15 @@
351 351 }
352 352 if (shift)
353 353 alloc_blocks >>= shift;
  354 +
  355 + /*
  356 + * If we are still trying to allocate more space than is
  357 + * available, squash the prealloc hard. This can happen if we
  358 + * have a large file on a small filesystem and the above
  359 + * lowspace thresholds are smaller than MAXEXTLEN.
  360 + */
  361 + while (alloc_blocks >= freesp)
  362 + alloc_blocks >>= 4;
354 363 }
355 364  
356 365 if (alloc_blocks < mp->m_writeio_blocks)