All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: return correct wbc.nr_to_write in ext4_da_writepages
@ 2009-12-17 15:17 Richard Kennedy
  2009-12-17 15:40 ` Eric Sandeen
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Kennedy @ 2009-12-17 15:17 UTC (permalink / raw)
  To: tytso, adilger; +Cc: linux-ext4, lkml

ext4: always re-base nr_to_write in ext4_da_writepages

When ext4_da_writepages increases the nr_to_write in writeback_control
then it must always re-base the return value.

Without this change, when wb_writeback calculates how many pages were
actually written it can get a negative value and loop more times than
necessary. In tests I have seen nearly all the dirty pages pushed out to
writeback due to this issue.

Signed-off-by: Richard Kennedy <richard@rsk.demon.co.uk>

----

patch against 2.6.32
tested on x86_64

wb_writeback calculates (MAX_WRITE_PAGES - nr_to_write) & cannot know
that the value got changed.

I'm not sure what the test I removed was for.
Perhaps 
	if (nr_to_writebump)
		wbc->nr_to_write -= nr_to_writebump;
was intended?

regards
Richard

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 2c8caa5..52a573c 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2999,8 +2999,7 @@ retry:
 out_writepages:
 	if (!no_nrwrite_index_update)
 		wbc->no_nrwrite_index_update = 0;
-	if (wbc->nr_to_write > nr_to_writebump)
-		wbc->nr_to_write -= nr_to_writebump;
+	wbc->nr_to_write -= nr_to_writebump;
 	wbc->range_start = range_start;
 	trace_ext4_da_writepages_result(inode, wbc, ret, pages_written);
 	return ret;



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

* Re: [PATCH] ext4: return correct wbc.nr_to_write in ext4_da_writepages
  2009-12-17 15:17 [PATCH] ext4: return correct wbc.nr_to_write in ext4_da_writepages Richard Kennedy
@ 2009-12-17 15:40 ` Eric Sandeen
  2009-12-17 15:58   ` Richard Kennedy
  2009-12-17 17:32   ` Aneesh Kumar K.V
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Sandeen @ 2009-12-17 15:40 UTC (permalink / raw)
  To: Richard Kennedy; +Cc: tytso, adilger, linux-ext4, lkml

Richard Kennedy wrote:
> ext4: always re-base nr_to_write in ext4_da_writepages
> 
> When ext4_da_writepages increases the nr_to_write in writeback_control
> then it must always re-base the return value.
> 
> Without this change, when wb_writeback calculates how many pages were
> actually written it can get a negative value and loop more times than
> necessary. In tests I have seen nearly all the dirty pages pushed out to
> writeback due to this issue.
> 
> Signed-off-by: Richard Kennedy <richard@rsk.demon.co.uk>
> 
> ----
> 
> patch against 2.6.32
> tested on x86_64
> 
> wb_writeback calculates (MAX_WRITE_PAGES - nr_to_write) & cannot know
> that the value got changed.
> 
> I'm not sure what the test I removed was for.
> Perhaps 
> 	if (nr_to_writebump)
> 		wbc->nr_to_write -= nr_to_writebump;
> was intended?

Ted's commit 55138e0b added it (just part of the commit):

@@ -2914,7 +2994,8 @@ retry:
 out_writepages:
        if (!no_nrwrite_index_update)
                wbc->no_nrwrite_index_update = 0;
-       wbc->nr_to_write -= nr_to_writebump;
+       if (wbc->nr_to_write > nr_to_writebump)
+               wbc->nr_to_write -= nr_to_writebump;
        wbc->range_start = range_start;
        trace_ext4_da_writepages_result(inode, wbc, ret, pages_written);
        return ret;

so it looks like the intent there was to stop ->nr_to_write from
going negative ...


> regards
> Richard
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 2c8caa5..52a573c 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -2999,8 +2999,7 @@ retry:
>  out_writepages:
>  	if (!no_nrwrite_index_update)
>  		wbc->no_nrwrite_index_update = 0;
> -	if (wbc->nr_to_write > nr_to_writebump)
> -		wbc->nr_to_write -= nr_to_writebump;
> +	wbc->nr_to_write -= nr_to_writebump;
>  	wbc->range_start = range_start;
>  	trace_ext4_da_writepages_result(inode, wbc, ret, pages_written);
>  	return ret;
> 
> 
> --
> 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


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

* Re: [PATCH] ext4: return correct wbc.nr_to_write in ext4_da_writepages
  2009-12-17 15:40 ` Eric Sandeen
@ 2009-12-17 15:58   ` Richard Kennedy
  2009-12-17 17:32   ` Aneesh Kumar K.V
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Kennedy @ 2009-12-17 15:58 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: tytso, adilger, linux-ext4, lkml

On Thu, 2009-12-17 at 09:40 -0600, Eric Sandeen wrote:
> Richard Kennedy wrote:
> > ext4: always re-base nr_to_write in ext4_da_writepages
> > 
> > When ext4_da_writepages increases the nr_to_write in writeback_control
> > then it must always re-base the return value.
> > 
> > Without this change, when wb_writeback calculates how many pages were
> > actually written it can get a negative value and loop more times than
> > necessary. In tests I have seen nearly all the dirty pages pushed out to
> > writeback due to this issue.
> > 
> > Signed-off-by: Richard Kennedy <richard@rsk.demon.co.uk>
> > 
> > ----
> > 
> > patch against 2.6.32
> > tested on x86_64
> > 
> > wb_writeback calculates (MAX_WRITE_PAGES - nr_to_write) & cannot know
> > that the value got changed.
> > 
> > I'm not sure what the test I removed was for.
> > Perhaps 
> > 	if (nr_to_writebump)
> > 		wbc->nr_to_write -= nr_to_writebump;
> > was intended?
> 
> Ted's commit 55138e0b added it (just part of the commit):
> 
> @@ -2914,7 +2994,8 @@ retry:
>  out_writepages:
>         if (!no_nrwrite_index_update)
>                 wbc->no_nrwrite_index_update = 0;
> -       wbc->nr_to_write -= nr_to_writebump;
> +       if (wbc->nr_to_write > nr_to_writebump)
> +               wbc->nr_to_write -= nr_to_writebump;
>         wbc->range_start = range_start;
>         trace_ext4_da_writepages_result(inode, wbc, ret, pages_written);
>         return ret;
> 
> so it looks like the intent there was to stop ->nr_to_write from
> going negative ...
> 
> 
wb_writeback is OK with negative, it just needs to know how many pages
were written. Then it can decide if it's done the work it was asked to
do. balance_dirty_pages uses this throttle a device by asking for
writeback on a small number of pages. 
regards
Richard 




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

* Re: [PATCH] ext4: return correct wbc.nr_to_write in ext4_da_writepages
  2009-12-17 15:40 ` Eric Sandeen
  2009-12-17 15:58   ` Richard Kennedy
@ 2009-12-17 17:32   ` Aneesh Kumar K.V
  2009-12-25 20:10     ` tytso
  1 sibling, 1 reply; 5+ messages in thread
From: Aneesh Kumar K.V @ 2009-12-17 17:32 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Richard Kennedy, tytso, adilger, linux-ext4, lkml

On Thu, Dec 17, 2009 at 09:40:25AM -0600, Eric Sandeen wrote:
> Richard Kennedy wrote:
> > ext4: always re-base nr_to_write in ext4_da_writepages
> > 
> > When ext4_da_writepages increases the nr_to_write in writeback_control
> > then it must always re-base the return value.
> > 
> > Without this change, when wb_writeback calculates how many pages were
> > actually written it can get a negative value and loop more times than
> > necessary. In tests I have seen nearly all the dirty pages pushed out to
> > writeback due to this issue.
> > 
> > Signed-off-by: Richard Kennedy <richard@rsk.demon.co.uk>
> > 
> > ----
> > 
> > patch against 2.6.32
> > tested on x86_64
> > 
> > wb_writeback calculates (MAX_WRITE_PAGES - nr_to_write) & cannot know
> > that the value got changed.
> > 
> > I'm not sure what the test I removed was for.
> > Perhaps 
> > 	if (nr_to_writebump)
> > 		wbc->nr_to_write -= nr_to_writebump;
> > was intended?
> 
> Ted's commit 55138e0b added it (just part of the commit):
> 
> @@ -2914,7 +2994,8 @@ retry:
>  out_writepages:
>         if (!no_nrwrite_index_update)
>                 wbc->no_nrwrite_index_update = 0;
> -       wbc->nr_to_write -= nr_to_writebump;
> +       if (wbc->nr_to_write > nr_to_writebump)
> +               wbc->nr_to_write -= nr_to_writebump;
>         wbc->range_start = range_start;
>         trace_ext4_da_writepages_result(inode, wbc, ret, pages_written);
>         return ret;
> 
> so it looks like the intent there was to stop ->nr_to_write from
> going negative ...

I guess writeback code can handle nr_to_write going negative. If we are
not updating wbc->nr_to_write then i guess writeback code will get a 
wrong value for number of pages written and can end up doing wrong things
We had it that way as a part of 22208dedbd7626e5fc4339c417f8d24cc21f79d7
and i guess we didn't had any problems with that

So for the patch

Acked-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

-aneesh

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

* Re: [PATCH] ext4: return correct wbc.nr_to_write in ext4_da_writepages
  2009-12-17 17:32   ` Aneesh Kumar K.V
@ 2009-12-25 20:10     ` tytso
  0 siblings, 0 replies; 5+ messages in thread
From: tytso @ 2009-12-25 20:10 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: Eric Sandeen, Richard Kennedy, adilger, linux-ext4, lkml

On Thu, Dec 17, 2009 at 11:02:32PM +0530, Aneesh Kumar K.V wrote:
> On Thu, Dec 17, 2009 at 09:40:25AM -0600, Eric Sandeen wrote:
> > Richard Kennedy wrote:
> > > ext4: always re-base nr_to_write in ext4_da_writepages
> > > 
> > > When ext4_da_writepages increases the nr_to_write in writeback_control
> > > then it must always re-base the return value.
> > > 
> > > Without this change, when wb_writeback calculates how many pages were
> > > actually written it can get a negative value and loop more times than
> > > necessary. In tests I have seen nearly all the dirty pages pushed out to
> > > writeback due to this issue.
> > > 
> > > Signed-off-by: Richard Kennedy <richard@rsk.demon.co.uk>

Added to the ext4 patch queue, thanks.

				- Ted

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

end of thread, other threads:[~2009-12-25 20:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-17 15:17 [PATCH] ext4: return correct wbc.nr_to_write in ext4_da_writepages Richard Kennedy
2009-12-17 15:40 ` Eric Sandeen
2009-12-17 15:58   ` Richard Kennedy
2009-12-17 17:32   ` Aneesh Kumar K.V
2009-12-25 20:10     ` tytso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.