From patchwork Mon Aug 20 18:42:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 1350671 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 368403FC33 for ; Mon, 20 Aug 2012 18:43:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753154Ab2HTSny (ORCPT ); Mon, 20 Aug 2012 14:43:54 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:43553 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752962Ab2HTSny (ORCPT ); Mon, 20 Aug 2012 14:43:54 -0400 Received: by mail-lb0-f174.google.com with SMTP id gj3so3471930lbb.19 for ; Mon, 20 Aug 2012 11:43:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=fCFJhFPLgUPhG9sSXGxqk6fEHOcB12HTPAUV+lBKJwc=; b=uoFJ52AjdTU6c8OpAJnQQnWPt7AOrn/AxszKl1R6VmgSmRJDhwMnSdMJB+3f2AcwwS Ikw/p9IM6BASeOFL73c7ZChJCd3M2/k1aFnzMsCzxxtv5eq+B13iqaQhqGMpvdvj3lYt QONYMnfc5zKaKf0pE9FyLUPoa9XWXKPFyj69GPG9zyXLn3FDeFZAEJcN5mg1EnWloDx0 +RBzf/w9bj3XDkKoRgkvjQNu+tC8VbWkpAZZ3Lrc4ggCLDYK/lZhj8U7yobqd36GBsCR mb/M8uwLjr4MDe/QyHXbYCxS802sbEyjJY7cF1F/M2unR6LgYm5lxLm7fomWtoZ41+d5 IizA== Received: by 10.152.131.9 with SMTP id oi9mr14728329lab.39.1345488233266; Mon, 20 Aug 2012 11:43:53 -0700 (PDT) Received: from localhost.localdomain (PPPoE-78-29-75-95.san.ru. [78.29.75.95]) by mx.google.com with ESMTPS id mt19sm16434912lab.17.2012.08.20.11.43.51 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 20 Aug 2012 11:43:52 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Cc: Pavel Shilovsky Subject: [PATCH 07/10] CIFS: Fix cache coherency for read oplock case Date: Mon, 20 Aug 2012 22:42:57 +0400 Message-Id: <1345488180-5942-8-git-send-email-pshilovsky@samba.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1345488180-5942-1-git-send-email-pshilovsky@samba.org> References: <1345488180-5942-1-git-send-email-pshilovsky@samba.org> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Pavel Shilovsky 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 --- fs/cifs/file.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) 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