[PATCH] btrfs: handle scanned setting properly in writeback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <josef@xxxxxxxxxxxxxx>
---
 fs/btrfs/extent_io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index ba1ddb2a5520..94412dc0b709 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -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];
 
-- 
2.13.5




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux