ext4: use pagevec_lookup_range() in ext4_find_unwritten_pgoff()
PATCH 52/119 ext4: use pagevec_lookup_range() in ext4_find_unwritten_pgoff()
From: Jan Kara <[email protected]>
Subject: ext4: use pagevec_lookup_range() in ext4_find_unwritten_pgoff()
Use pagevec_lookup_range() in ext4_find_unwritten_pgoff() since we are interested only in pages in the given range. Simplify the logic as a result of not getting pages out of range and index getting automatically advanced.
Signed-off-by Jan Kara <[email protected]>
Cc "Theodore Ts'o" <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
fs/ext4/file.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
fs/ext4/file.c renamed from fs/ext4/file.c~ext4-use-pagevec_lookup_range-in-ext4_find_unwritten_pgoff +3 -6
@@ -464,12 +464,11 @@ static int ext4_find_unwritten_pgoff(strpagevec_init (&pvec,0 ); do { - int i, num; + int i; unsigned long nr_pages; - num = min_t(pgoff_t, end - index, PAGEVEC_SIZE - 1) + 1; - nr_pages = pagevec_lookup(&pvec, inode->i_mapping, &index, - (pgoff_t)num); + nr_pages = pagevec_lookup_range(&pvec, inode->i_mapping, + &index, end, PAGEVEC_SIZE); if (nr_pages == 0) break;
@@ -488,9 +487,6 @@ static int ext4_find_unwritten_pgoff(str goto out; } -if (page->index > end) - goto out;