linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] ext4: flush delalloc blocks when space is low
@ 2009-12-11 23:07 Eric Sandeen
  2009-12-16 20:46 ` Jan Kara
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Sandeen @ 2009-12-11 23:07 UTC (permalink / raw)
  To: ext4 development; +Cc: linux-fsdevel, Jens Axboe

Creating many small files in rapid succession on a small
filesystem can lead to spurious ENOSPC; on a 104MB filesystem:

for i in `seq 1 22500`; do
    echo -n > $SCRATCH_MNT/$i
    echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > $SCRATCH_MNT/$i
done

leads to ENOSPC even though after a sync, 40% of the fs is free
again.

This is because we reserve worst-case metadata for delalloc writes,
and when data is allocated that worst-case reservation is not
usually needed.

When freespace is low, kicking off an async writeback will start
converting that worst-case space usage into something more realistic,
almost always freeing up space to continue.

This resolves the testcase for me, and survives all 4 generic
ENOSPC tests in xfstests.

We'll still need a hard synchronous sync to squeeze out the last bit,
but this fixes things up to a large degree.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 5c5bc5d..5b3f468 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3024,11 +3024,18 @@ static int ext4_nonda_switch(struct super_block *sb)
 	if (2 * free_blocks < 3 * dirty_blocks ||
 		free_blocks < (dirty_blocks + EXT4_FREEBLOCKS_WATERMARK)) {
 		/*
-		 * free block count is less that 150% of dirty blocks
-		 * or free blocks is less that watermark
+		 * free block count is less than 150% of dirty blocks
+		 * or free blocks is less than watermark
 		 */
 		return 1;
 	}
+	/*
+	 * Even if we don't switch but are nearing capacity,
+	 * start pushing delalloc when 1/2 of free blocks are dirty.
+	 */
+	if (free_blocks < 2 * dirty_blocks)
+		writeback_inodes_sb_if_idle(sb);
+
 	return 0;
 }
 


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] ext4: flush delalloc blocks when space is low
  2009-12-11 23:07 [PATCH 2/2] ext4: flush delalloc blocks when space is low Eric Sandeen
@ 2009-12-16 20:46 ` Jan Kara
  2009-12-23 13:01   ` tytso
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2009-12-16 20:46 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: ext4 development, linux-fsdevel, Jens Axboe

> Creating many small files in rapid succession on a small
> filesystem can lead to spurious ENOSPC; on a 104MB filesystem:
> 
> for i in `seq 1 22500`; do
>     echo -n > $SCRATCH_MNT/$i
>     echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > $SCRATCH_MNT/$i
> done
> 
> leads to ENOSPC even though after a sync, 40% of the fs is free
> again.
> 
> This is because we reserve worst-case metadata for delalloc writes,
> and when data is allocated that worst-case reservation is not
> usually needed.
> 
> When freespace is low, kicking off an async writeback will start
> converting that worst-case space usage into something more realistic,
> almost always freeing up space to continue.
> 
> This resolves the testcase for me, and survives all 4 generic
> ENOSPC tests in xfstests.
> 
> We'll still need a hard synchronous sync to squeeze out the last bit,
> but this fixes things up to a large degree.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
  Looks good.

  Acked-by: Jan Kara <jack@suse.cz>

							Honza
> ---
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 5c5bc5d..5b3f468 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -3024,11 +3024,18 @@ static int ext4_nonda_switch(struct super_block *sb)
>  	if (2 * free_blocks < 3 * dirty_blocks ||
>  		free_blocks < (dirty_blocks + EXT4_FREEBLOCKS_WATERMARK)) {
>  		/*
> -		 * free block count is less that 150% of dirty blocks
> -		 * or free blocks is less that watermark
> +		 * free block count is less than 150% of dirty blocks
> +		 * or free blocks is less than watermark
>  		 */
>  		return 1;
>  	}
> +	/*
> +	 * Even if we don't switch but are nearing capacity,
> +	 * start pushing delalloc when 1/2 of free blocks are dirty.
> +	 */
> +	if (free_blocks < 2 * dirty_blocks)
> +		writeback_inodes_sb_if_idle(sb);
> +
>  	return 0;
>  }
>  
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Jan Kara <jack@suse.cz>
SuSE CR Labs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] ext4: flush delalloc blocks when space is low
  2009-12-16 20:46 ` Jan Kara
@ 2009-12-23 13:01   ` tytso
  0 siblings, 0 replies; 3+ messages in thread
From: tytso @ 2009-12-23 13:01 UTC (permalink / raw)
  To: Jan Kara; +Cc: Eric Sandeen, ext4 development, linux-fsdevel, Jens Axboe

On Wed, Dec 16, 2009 at 09:46:02PM +0100, Jan Kara wrote:
> > Creating many small files in rapid succession on a small
> > filesystem can lead to spurious ENOSPC; on a 104MB filesystem:
> > 
> > for i in `seq 1 22500`; do
> >     echo -n > $SCRATCH_MNT/$i
> >     echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > $SCRATCH_MNT/$i
> > done
> > 
> > leads to ENOSPC even though after a sync, 40% of the fs is free
> > again.
> > 
> > This is because we reserve worst-case metadata for delalloc writes,
> > and when data is allocated that worst-case reservation is not
> > usually needed.
> > 
> > When freespace is low, kicking off an async writeback will start
> > converting that worst-case space usage into something more realistic,
> > almost always freeing up space to continue.
> > 
> > This resolves the testcase for me, and survives all 4 generic
> > ENOSPC tests in xfstests.
> > 
> > We'll still need a hard synchronous sync to squeeze out the last bit,
> > but this fixes things up to a large degree.
> > 
> > Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Thanks, added to the ext4 patch queue.

						- Ted

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-12-23 13:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-11 23:07 [PATCH 2/2] ext4: flush delalloc blocks when space is low Eric Sandeen
2009-12-16 20:46 ` Jan Kara
2009-12-23 13:01   ` tytso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).