ext4: return correct wbc.nr_to_write in ext4_da_writepages
PATCH 1/1 ext4: return correct wbc.nr_to_write in ext4_da_writepages
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.
----
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
fs/ext4/inode.c +1 -2
@@ -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;
Quoted 17 lines · Richard Kennedy
ext4: always re-base
nr_to_writeinext4_da_writepagesWhen
ext4_da_writepagesincreases thenr_to_writeinwriteback_controlthen it must always re-base the return value.Without this change, when
wb_writebackcalculates 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 <[email protected]>----
patch against 2.6.32
tested onx86_64
Quoted 8 lines
wb_writebackcalculates (MAX_WRITE_PAGES-nr_to_write) & cannot know that the value got changed.I'm not sure what the test I removed was for.
Perhapsif (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 ...
Quoted 23 lines
regards
Richardfs/ext4/inode.c +1
-3@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 40 lines · Eric Sandeen
Quoted 17 lines · Richard Kennedy
ext4: always re-base
nr_to_writeinext4_da_writepagesWhen
ext4_da_writepagesincreases thenr_to_writeinwriteback_controlthen it must always re-base the return value.Without this change, when
wb_writebackcalculates 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 <[email protected]>----
patch against 2.6.32
tested onx86_64Quoted 8 lines
wb_writebackcalculates (MAX_WRITE_PAGES-nr_to_write) & cannot know that the value got changed.I'm not sure what the test I removed was for.
Perhapsif (nr_to_writebump) wbc->nr_to_write -= nr_to_writebump;was intended?
Ted's commit
55138e0badded it (just part of the commit):fs/ext4/inode.c +2
-1@@ -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;
Quoted 4 lines
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
Aneesh Kumar K.V
Acked-byQuoted 40 lines · Eric Sandeen
Quoted 17 lines · Richard Kennedy
ext4: always re-base
nr_to_writeinext4_da_writepagesWhen
ext4_da_writepagesincreases thenr_to_writeinwriteback_controlthen it must always re-base the return value.Without this change, when
wb_writebackcalculates 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 <[email protected]>----
patch against 2.6.32
tested onx86_64Quoted 8 lines
wb_writebackcalculates (MAX_WRITE_PAGES-nr_to_write) & cannot know that the value got changed.I'm not sure what the test I removed was for.
Perhapsif (nr_to_writebump) wbc->nr_to_write -= nr_to_writebump;was intended?
Ted's commit
55138e0badded it (just part of the commit):fs/ext4/inode.c +2
-1@@ -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;
Quoted 2 lines
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
-aneesh
[email protected]
maintainerQuoted 7 lines · Aneesh Kumar K.V
Quoted 6 lines · Eric Sandeen
Quoted 5 lines · Richard Kennedy
ext4: always re-base
nr_to_writeinext4_da_writepagesWhen
ext4_da_writepagesincreases thenr_to_writeinwriteback_controlthen it must always re-base the return value.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Without this change, when
wb_writebackcalculates 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 <[email protected]>
Added to the ext4 patch queue, thanks.
- Ted