From 015e6c14f5d2fbb0ddfbf62868c72c12a6a8898d Mon Sep 17 00:00:00 2001 From: Pavel Shilovsky Date: Wed, 19 Sep 2012 06:22:45 -0700 Subject: [PATCH] --- yaml --- r: 326311 b: refs/heads/master c: 25078105fbe14e7b3270391eaa11514bec787a52 h: refs/heads/master i: 326309: e81397327c6211178e98ab094ab16d52ea26c188 326307: 2f9f22a347fe92af83cd97f406eada06dd7864b9 326303: a93d24d8605b2b7752ce0bcd8aea327684ba8251 v: v3 --- [refs] | 2 +- trunk/fs/cifs/file.c | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 0a9571aca9df..e4ab2b0d712b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b8c32dbb0deb287a5fcb78251e4eae6c7275760d +refs/heads/master: 25078105fbe14e7b3270391eaa11514bec787a52 diff --git a/trunk/fs/cifs/file.c b/trunk/fs/cifs/file.c index ccad858d2d67..e93e3d2c69e6 100644 --- a/trunk/fs/cifs/file.c +++ b/trunk/fs/cifs/file.c @@ -2461,11 +2461,30 @@ cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov, iocb->ki_filp->private_data; struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); +#ifdef CONFIG_CIFS_SMB2 /* - * In strict cache mode we need to write the data to the server exactly - * from the pos to pos+len-1 rather than flush all affected pages - * because it may cause a error with mandatory locks on these pages but - * not on the region from pos to ppos+len-1. + * If we have an oplock for read and want to write a data to the file + * we need to store it in the page cache and then push it to the server + * to be sure the next read will get a valid data. + */ + if (!cinode->clientCanCacheAll && cinode->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 + + /* + * For non-oplocked files in strict cache mode we need to write the data + * to the server exactly from the pos to pos+len-1 rather than flush all + * affected pages because it may cause a error with mandatory locks on + * these pages but not on the region from pos to ppos+len-1. */ if (!cinode->clientCanCacheAll)