btrfs: use pagevec_lookup_range_tag()
authorJan Kara <jack@suse.cz>
Thu, 16 Nov 2017 01:34:37 +0000 (17:34 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 28 Jun 2018 22:49:24 +0000 (15:49 -0700)
We want only pages from given range in btree_write_cache_pages() and
extent_write_cache_pages().  Use pagevec_lookup_range_tag() instead of
pagevec_lookup_tag() and remove unnecessary code.

Link: http://lkml.kernel.org/r/20171009151359.31984-3-jack@suse.cz
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: David Sterba <dsterba@suse.com>
Reviewed-by: Daniel Jordan <daniel.m.jordan@oracle.com>
Cc: David Sterba <dsterba@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/btrfs/extent_io.c

index 7fa50e12f18e7371032438689e46ea158684862e..454d08585a3bbb4c4c975cf468ce1fa4d46ca8fc 100644 (file)
@@ -3819,8 +3819,8 @@ retry:
        if (wbc->sync_mode == WB_SYNC_ALL)
                tag_pages_for_writeback(mapping, index, end);
        while (!done && !nr_to_write_done && (index <= end) &&
-              (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, tag,
-                       min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1))) {
+              (nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end,
+                       tag, PAGEVEC_SIZE))) {
                unsigned i;
 
                scanned = 1;
@@ -3830,11 +3830,6 @@ retry:
                        if (!PagePrivate(page))
                                continue;
 
-                       if (!wbc->range_cyclic && page->index > end) {
-                               done = 1;
-                               break;
-                       }
-
                        spin_lock(&mapping->private_lock);
                        if (!PagePrivate(page)) {
                                spin_unlock(&mapping->private_lock);
@@ -3966,8 +3961,8 @@ retry:
                tag_pages_for_writeback(mapping, index, end);
        done_index = index;
        while (!done && !nr_to_write_done && (index <= end) &&
-              (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, tag,
-                       min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1))) {
+              (nr_pages = pagevec_lookup_range_tag(&pvec, mapping, &index, end,
+                       tag, PAGEVEC_SIZE))) {
                unsigned i;
 
                scanned = 1;
@@ -3992,12 +3987,6 @@ retry:
                                continue;
                        }
 
-                       if (!wbc->range_cyclic && page->index > end) {
-                               done = 1;
-                               unlock_page(page);
-                               continue;
-                       }
-
                        if (wbc->sync_mode != WB_SYNC_NONE) {
                                if (PageWriteback(page))
                                        flush_fn(data);