@@ -1266,6 +1266,7 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
unsigned long seg = 0;
size_t count;
loff_t *ppos = &iocb->ki_pos;
+ bool invalidate = false;
count = 0;
retval = generic_segment_checks(iov, &nr_segs, &count, VERIFY_WRITE);
@@ -1291,7 +1292,8 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
iov, pos, nr_segs);
}
if (retval > 0) {
- *ppos = pos + retval;
+ pos += retval;
+ *ppos = pos;
count -= retval;
}
@@ -1307,6 +1309,7 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
file_accessed(filp);
goto out;
}
+ invalidate = true;
}
}
@@ -1343,6 +1346,10 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
if (desc.count > 0)
break;
}
+ if (invalidate && retval > 0)
+ invalidate_mapping_pages(filp->f_mapping,
+ pos >> PAGE_CACHE_SHIFT,
+ (*ppos - 1) >> PAGE_CACHE_SHIFT);
out:
return retval;
}