Skip to content

Commit

Permalink
Merge tag 'iomap-4.21-merge-2' of git://git.kernel.org/pub/scm/fs/xfs…
Browse files Browse the repository at this point in the history
…/xfs-linux

Pull iomap update from Darrick Wong:
 "Fix a memory overflow bug for blocksize < pagesize"

* tag 'iomap-4.21-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
  iomap: don't search past page end in iomap_is_partially_uptodate
  • Loading branch information
torvalds committed Dec 28, 2018
2 parents 47a43f2 + 3cc31fa commit bc77789
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions fs/iomap.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,16 +492,29 @@ iomap_readpages(struct address_space *mapping, struct list_head *pages,
}
EXPORT_SYMBOL_GPL(iomap_readpages);

/*
* iomap_is_partially_uptodate checks whether blocks within a page are
* uptodate or not.
*
* Returns true if all blocks which correspond to a file portion
* we want to read within the page are uptodate.
*/
int
iomap_is_partially_uptodate(struct page *page, unsigned long from,
unsigned long count)
{
struct iomap_page *iop = to_iomap_page(page);
struct inode *inode = page->mapping->host;
unsigned first = from >> inode->i_blkbits;
unsigned last = (from + count - 1) >> inode->i_blkbits;
unsigned len, first, last;
unsigned i;

/* Limit range to one page */
len = min_t(unsigned, PAGE_SIZE - from, count);

/* First and last blocks in range within page */
first = from >> inode->i_blkbits;
last = (from + len - 1) >> inode->i_blkbits;

if (iop) {
for (i = first; i <= last; i++)
if (!test_bit(i, iop->uptodate))
Expand Down

0 comments on commit bc77789

Please sign in to comment.