diff --git a/fs/ext4/file.c b/fs/ext4/file.c index ec9770f4253..d490d6ec396 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -382,6 +382,8 @@ static int ext4_find_unwritten_pgoff(struct inode *inode, lastoff = page_offset(page); bh = head = page_buffers(page); do { + if (lastoff + bh->b_size <= startoff) + goto next; if (buffer_uptodate(bh) || buffer_unwritten(bh)) { if (whence == SEEK_DATA) @@ -396,6 +398,7 @@ static int ext4_find_unwritten_pgoff(struct inode *inode, unlock_page(page); goto out; } +next: lastoff += bh->b_size; bh = bh->b_this_page; } while (bh != head);