Re: ENOSPC returned during writepages

Theodore Tso
2008-08-20T19:34:09Z

On Wed, Aug 20, 2008 at 01:25:36PM -0600, Andreas Dilger wrote:
> What I think makes sense, however, is that if freeblocks < $threshold that
> a global spinlock is taken and the percpu_counter_sum() is done under the
> lock before deciding if enough space is left. Since it is impossible that
> the other CPUs get below -FBC_BATCH away from the correct free space they
> should all get the spinlock at the same time when we get too low.

Yep, I agree. I suggested something very similar as my first suggestion.

I do think though that we need to rationalize the percpu_counter
interface, though; those are two separable issues, and both IMHO need
fixing... The fact that we have a #ifdef CONFIG_SMP in
fs/ext4/inode.c and we are doing wierd things with percpu_counter_sum
and percpu_counter_sum_and_set is ugly. And it would be good if most
of the time we can avoid taking the filesystem-level spinlock, and
rely on the percpu_counter except when we start getting low on space.

- Ted