diff mbox series

cifs: invalidate and destage pages before re-reading them for cache=none

Message ID 20220919033747.461583-2-lsahlber@redhat.com (mailing list archive)
State New, archived
Headers show
Series cifs: invalidate and destage pages before re-reading them for cache=none | expand

Commit Message

Ronnie Sahlberg Sept. 19, 2022, 3:37 a.m. UTC
This is the opposite case of kernel bugzilla 216301.
If we mmap a file using cache=none and then proceed to update the mmapped
area these updates are not reflected in a later pread() of that part of the
file.
To fix this we must invalidate the mapping, forcing the changed pages to be
destaged to the server before we allow the pread() to proceed.

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/file.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 6f38b134a346..31ceef22ffe4 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -4314,6 +4314,9 @@  static ssize_t __cifs_readv(
 
 ssize_t cifs_direct_readv(struct kiocb *iocb, struct iov_iter *to)
 {
+	struct file *file = iocb->ki_filp;
+
+	cifs_revalidate_mapping(file->f_inode);
 	return __cifs_readv(iocb, to, true);
 }