aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/iomap.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/fs/iomap.c b/fs/iomap.c
index 5bc172f3dfe8..fba8fdb734e0 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -499,16 +499,29 @@ done:
499} 499}
500EXPORT_SYMBOL_GPL(iomap_readpages); 500EXPORT_SYMBOL_GPL(iomap_readpages);
501 501
502/*
503 * iomap_is_partially_uptodate checks whether blocks within a page are
504 * uptodate or not.
505 *
506 * Returns true if all blocks which correspond to a file portion
507 * we want to read within the page are uptodate.
508 */
502int 509int
503iomap_is_partially_uptodate(struct page *page, unsigned long from, 510iomap_is_partially_uptodate(struct page *page, unsigned long from,
504 unsigned long count) 511 unsigned long count)
505{ 512{
506 struct iomap_page *iop = to_iomap_page(page); 513 struct iomap_page *iop = to_iomap_page(page);
507 struct inode *inode = page->mapping->host; 514 struct inode *inode = page->mapping->host;
508 unsigned first = from >> inode->i_blkbits; 515 unsigned len, first, last;
509 unsigned last = (from + count - 1) >> inode->i_blkbits;
510 unsigned i; 516 unsigned i;
511 517
518 /* Limit range to one page */
519 len = min_t(unsigned, PAGE_SIZE - from, count);
520
521 /* First and last blocks in range within page */
522 first = from >> inode->i_blkbits;
523 last = (from + len - 1) >> inode->i_blkbits;
524
512 if (iop) { 525 if (iop) {
513 for (i = first; i <= last; i++) 526 for (i = first; i <= last; i++)
514 if (!test_bit(i, iop->uptodate)) 527 if (!test_bit(i, iop->uptodate))