diff mbox

[07/10] CIFS: Fix cache coherency for read oplock case

Message ID 1345488180-5942-8-git-send-email-pshilovsky@samba.org (mailing list archive)
State New, archived
Headers show

Commit Message

Pavel Shilovsky Aug. 20, 2012, 6:42 p.m. UTC
From: Pavel Shilovsky <piastry@etersoft.ru>

When we have a file opened with read oplock and we are writing a data
to this file, we need to store the data in the cache and then send to
the server to ensure that the next read operation will get a coherent
data.

Also mark it as CONFIG_CIFS_SMB2 because it's more suitable for SMB2
code but can fix some CIFS problems too (when server delays sending
an oplock break after a write request). We can drop this ifdefs
dependence in future.

Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru>
---
 fs/cifs/file.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 930a66a..af4a832 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2410,6 +2410,17 @@  ssize_t cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov,
 
 	if (CIFS_I(inode)->clientCanCacheAll)
 		return generic_file_aio_write(iocb, iov, nr_segs, pos);
+#ifdef CONFIG_CIFS_SMB2
+	else if (CIFS_I(inode)->clientCanCacheRead) {
+		ssize_t written;
+		int rc;
+		written = generic_file_aio_write(iocb, iov, nr_segs, pos);
+		rc = filemap_fdatawrite(inode->i_mapping);
+		if (rc)
+			return (ssize_t)rc;
+		return written;
+	}
+#endif
 
 	/*
 	 * In strict cache mode we need to write the data to the server exactly