linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: handle scanned setting properly in writeback
@ 2019-11-11 18:12 Josef Bacik
  0 siblings, 0 replies; only message in thread
From: Josef Bacik @ 2019-11-11 18:12 UTC (permalink / raw)
  To: linux-btrfs, kernel-team

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@toxicpanda.com>
---
 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-11 18:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11 18:12 [PATCH] btrfs: handle scanned setting properly in writeback Josef Bacik

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