diff options
author | Jan Kara | 2017-09-06 16:21:27 -0700 |
---|---|---|
committer | Linus Torvalds | 2017-09-06 17:27:26 -0700 |
commit | dec0da7b608253b004daea1da5bd82b3b292ba0f (patch) | |
tree | ff616fc5f7fb3c24ac421473b6e068d20158a185 /fs/ext4 | |
parent | c10f778ddfc161f5c58a8d6de4ad92235ea2eeba (diff) |
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.
Link: http://lkml.kernel.org/r/20170726114704.7626-6-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>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/file.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 1c73b21fdc13..726344809721 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -464,12 +464,11 @@ static int ext4_find_unwritten_pgoff(struct inode *inode, pagevec_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(struct inode *inode, goto out; } - if (page->index > end) - goto out; - lock_page(page); if (unlikely(page->mapping != inode->i_mapping)) { @@ -533,12 +529,10 @@ next: unlock_page(page); } - /* The no. of pages is less than our desired, we are done. */ - if (nr_pages < num) - break; pagevec_release(&pvec); } while (index <= end); + /* There are no pages upto endoff - that would be a hole in there. */ if (whence == SEEK_HOLE && lastoff < endoff) { found = 1; *offset = lastoff; |