ext4: use pagevec_lookup_range() in writeback code
authorJan Kara <jack@suse.cz>
Wed, 6 Sep 2017 23:21:30 +0000 (16:21 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 7 Sep 2017 00:27:27 +0000 (17:27 -0700)
Both occurences of pagevec_lookup() actually want only pages from a
given range.  Use pagevec_lookup_range() for the lookup.

Link: http://lkml.kernel.org/r/20170726114704.7626-7-jack@suse.cz
Signed-off-by: Jan Kara <jack@suse.cz>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ext4/inode.c

index b3ce1c6d9f23b413e0cfb1ead62960d9efc0e6e6..6103ce0430dfc07f5f5a434ce159c3ed8b6e80d5 100644 (file)
@@ -1720,13 +1720,13 @@ static void mpage_release_unused_pages(struct mpage_da_data *mpd,
 
        pagevec_init(&pvec, 0);
        while (index <= end) {
 
        pagevec_init(&pvec, 0);
        while (index <= end) {
-               nr_pages = pagevec_lookup(&pvec, mapping, &index, PAGEVEC_SIZE);
+               nr_pages = pagevec_lookup_range(&pvec, mapping, &index, end,
+                                               PAGEVEC_SIZE);
                if (nr_pages == 0)
                        break;
                for (i = 0; i < nr_pages; i++) {
                        struct page *page = pvec.pages[i];
                if (nr_pages == 0)
                        break;
                for (i = 0; i < nr_pages; i++) {
                        struct page *page = pvec.pages[i];
-                       if (page->index > end)
-                               break;
+
                        BUG_ON(!PageLocked(page));
                        BUG_ON(PageWriteback(page));
                        if (invalidate) {
                        BUG_ON(!PageLocked(page));
                        BUG_ON(PageWriteback(page));
                        if (invalidate) {
@@ -2347,15 +2347,13 @@ static int mpage_map_and_submit_buffers(struct mpage_da_data *mpd)
 
        pagevec_init(&pvec, 0);
        while (start <= end) {
 
        pagevec_init(&pvec, 0);
        while (start <= end) {
-               nr_pages = pagevec_lookup(&pvec, inode->i_mapping, &start,
-                                         PAGEVEC_SIZE);
+               nr_pages = pagevec_lookup_range(&pvec, inode->i_mapping,
+                                               &start, end, PAGEVEC_SIZE);
                if (nr_pages == 0)
                        break;
                for (i = 0; i < nr_pages; i++) {
                        struct page *page = pvec.pages[i];
 
                if (nr_pages == 0)
                        break;
                for (i = 0; i < nr_pages; i++) {
                        struct page *page = pvec.pages[i];
 
-                       if (page->index > end)
-                               break;
                        bh = head = page_buffers(page);
                        do {
                                if (lblk < mpd->map.m_lblk)
                        bh = head = page_buffers(page);
                        do {
                                if (lblk < mpd->map.m_lblk)