Before satisfying a read with cache=loose, we should always check
that the pagecache is actually valid before using it.

Reported-by: Tetsuo Handa <[email protected]>
Signed-off-by: Jeff Layton <[email protected]>
---
 fs/cifs/cifsfs.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 8a7faf7bd9ee..799e37262832 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -726,6 +726,20 @@ out_nls:
        goto out;
 }
 
+static ssize_t
+cifs_loose_aio_read(struct kiocb *iocb, const struct iovec *iov,
+                  unsigned long nr_segs, loff_t pos)
+{
+       int rc;
+       struct inode *inode = file_inode(iocb->ki_filp);
+
+       rc = cifs_revalidate_mapping(inode);
+       if (rc)
+               return rc;
+
+       return generic_file_aio_read(iocb, iov, nr_segs, pos);
+}
+
 static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
                                   unsigned long nr_segs, loff_t pos)
 {
@@ -877,7 +891,7 @@ const struct inode_operations cifs_symlink_inode_ops = {
 const struct file_operations cifs_file_ops = {
        .read = do_sync_read,
        .write = do_sync_write,
-       .aio_read = generic_file_aio_read,
+       .aio_read = cifs_loose_aio_read,
        .aio_write = cifs_file_aio_write,
        .open = cifs_open,
        .release = cifs_close,
@@ -935,7 +949,7 @@ const struct file_operations cifs_file_direct_ops = {
 const struct file_operations cifs_file_nobrl_ops = {
        .read = do_sync_read,
        .write = do_sync_write,
-       .aio_read = generic_file_aio_read,
+       .aio_read = cifs_loose_aio_read,
        .aio_write = cifs_file_aio_write,
        .open = cifs_open,
        .release = cifs_close,
-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to