btrfs: handle scanned setting properly in writeback
PATCH 1/1 btrfs: handle scanned setting properly in writeback
When doing background writeback we start at the last index we wroteback on an inode. However we want to loop around and scan from the beginning if we do not meet our write out targets. We keep track of this with the scanned variable, which is supposed to be set to 1 if we don't need to loop around. Unfortunately we set this if we find any pages at all, so if our writeback_index is slightly before the end of the file and we find a dirty page we'll set scanned = 1 and thus never loop around to the beginning of the file. Fix this by only setting scanned = 1 in the range_cyclic case if we are starting at index == 0, or if we've actually looped around to the beginning.
Signed-off-by Josef Bacik <[email protected]>
--- fs/btrfs/extent_io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/extent_io.c +2 -1
@@ -3937,6 +3937,7 @@ int btree_write_cache_pages(struct address_space *mapping,if (wbc->range_cyclic) { index = mapping->writeback_index;/* Start from prev offset */ end =-1 ; + scanned = (index ==0 ); }else { index = wbc->range_start >>PAGE_SHIFT ; end = wbc->range_end >>PAGE_SHIFT ;
@@ -4083,6 +4084,7 @@ static int extent_write_cache_pages(struct address_space *mapping,if (wbc->range_cyclic) { index = mapping->writeback_index;/* Start from prev offset */ end =-1 ; + scanned = (index ==0 ); }else { index = wbc->range_start >>PAGE_SHIFT ; end = wbc->range_end >>PAGE_SHIFT ;
@@ -4116,7 +4118,6 @@ static int extent_write_cache_pages(struct address_space *mapping, &index, end, tag))) {unsigned i; - scanned =1 ;for (i =0 ; i < nr_pages; i++) {struct page *page = pvec.pages[i];
Signature · 1 line
2.13.5