linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: fix free space estimate in ext4_nonda_switch()
@ 2013-04-03 17:19 Eric Whitney
  2013-04-09 13:28 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Whitney @ 2013-04-03 17:19 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso

Values stored in s_freeclusters_counter and s_dirtyclusters_counter
are both in cluster units.  Remove the cluster to block conversion
applied to s_freeclusters_counter causing an inflated estimate of
free space because s_dirtyclusters_counter is not similarly
converted.  Rename free_blocks and dirty_blocks to better reflect
the units these variables contain to avoid future confusion.  This
fix corrects ENOSPC failures for xfstests 127 and 231 on bigalloc
file systems.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
---
 fs/ext4/inode.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index b3a5213..5f5cc40 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2661,7 +2661,7 @@ out_writepages:
 
 static int ext4_nonda_switch(struct super_block *sb)
 {
-	s64 free_blocks, dirty_blocks;
+	s64 free_clusters, dirty_clusters;
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 
 	/*
@@ -2672,17 +2672,18 @@ static int ext4_nonda_switch(struct super_block *sb)
 	 * Delalloc need an accurate free block accounting. So switch
 	 * to non delalloc when we are near to error range.
 	 */
-	free_blocks  = EXT4_C2B(sbi,
-		percpu_counter_read_positive(&sbi->s_freeclusters_counter));
-	dirty_blocks = percpu_counter_read_positive(&sbi->s_dirtyclusters_counter);
+	free_clusters =
+		percpu_counter_read_positive(&sbi->s_freeclusters_counter);
+	dirty_clusters =
+		percpu_counter_read_positive(&sbi->s_dirtyclusters_counter);
 	/*
 	 * Start pushing delalloc when 1/2 of free blocks are dirty.
 	 */
-	if (dirty_blocks && (free_blocks < 2 * dirty_blocks))
+	if (dirty_clusters && (free_clusters < 2 * dirty_clusters))
 		try_to_writeback_inodes_sb(sb, WB_REASON_FS_FREE_SPACE);
 
-	if (2 * free_blocks < 3 * dirty_blocks ||
-		free_blocks < (dirty_blocks + EXT4_FREECLUSTERS_WATERMARK)) {
+	if (2 * free_clusters < 3 * dirty_clusters ||
+	    free_clusters < (dirty_clusters + EXT4_FREECLUSTERS_WATERMARK)) {
 		/*
 		 * free block count is less than 150% of dirty blocks
 		 * or free blocks is less than watermark
-- 
1.7.10.4


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

* Re: [PATCH] ext4: fix free space estimate in ext4_nonda_switch()
  2013-04-03 17:19 [PATCH] ext4: fix free space estimate in ext4_nonda_switch() Eric Whitney
@ 2013-04-09 13:28 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2013-04-09 13:28 UTC (permalink / raw)
  To: Eric Whitney; +Cc: linux-ext4

On Wed, Apr 03, 2013 at 01:19:31PM -0400, Eric Whitney wrote:
> Values stored in s_freeclusters_counter and s_dirtyclusters_counter
> are both in cluster units.  Remove the cluster to block conversion
> applied to s_freeclusters_counter causing an inflated estimate of
> free space because s_dirtyclusters_counter is not similarly
> converted.  Rename free_blocks and dirty_blocks to better reflect
> the units these variables contain to avoid future confusion.  This
> fix corrects ENOSPC failures for xfstests 127 and 231 on bigalloc
> file systems.
> 
> Signed-off-by: Eric Whitney <enwlinux@gmail.com>

Hi Eric,

This patch looks good.  Thanks for submitting it!!

I've applied it to the dev branch for testing.

					- Ted

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

end of thread, other threads:[~2013-04-09 13:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-03 17:19 [PATCH] ext4: fix free space estimate in ext4_nonda_switch() Eric Whitney
2013-04-09 13:28 ` Theodore Ts'o

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).