From patchwork Fri Aug 22 05:22:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namjae Jeon X-Patchwork-Id: 4761331 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 28E40C0338 for ; Fri, 22 Aug 2014 05:23:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 120CE2018A for ; Fri, 22 Aug 2014 05:22:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 38DE62017A for ; Fri, 22 Aug 2014 05:22:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751943AbaHVFWy (ORCPT ); Fri, 22 Aug 2014 01:22:54 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:22533 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751927AbaHVFWy (ORCPT ); Fri, 22 Aug 2014 01:22:54 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NAP006SF0A4DB10@mailout4.samsung.com> for linux-cifs@vger.kernel.org; Fri, 22 Aug 2014 14:22:52 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.113]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 7C.8B.14752.BA3D6F35; Fri, 22 Aug 2014 14:22:52 +0900 (KST) X-AuditID: cbfee68f-b7fa26d0000039a0-97-53f6d3abf440 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 14.E2.04943.BA3D6F35; Fri, 22 Aug 2014 14:22:51 +0900 (KST) Received: from DONAMJAEJEO06 ([10.88.104.63]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NAP00CCU0A3GK00@mmp1.samsung.com>; Fri, 22 Aug 2014 14:22:51 +0900 (KST) From: Namjae Jeon To: Steve French Cc: linux-cifs@vger.kernel.org, 'Jeff Layton' , Ashish Sangwan Subject: [PATCH v2] cifs: Allow directIO read/write during cache=strict Date: Fri, 22 Aug 2014 14:22:51 +0900 Message-id: <000001cfbdc9$1ea5eb20$5bf1c160$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: Ac+9yRNGzyKjA61HSIWLBCU+kS09ng== Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRmVeSWpSXmKPExsWyRsSkUHfN5W/BBqe+s1gsnXiJ2WL1zCvM Fi/+72K2ePPiMJsDi8fOWXfZPebu6mP06NuyitHj8ya5AJYoLpuU1JzMstQifbsErozXT2oL lvFVLHrSzdjAeJW7i5GTQ0LAROLv3OWsELaYxIV769m6GLk4hASWMkp0tt0CcjjAiuYfTIOI L2KUeN1ziBmkQUjgL6PE5XuyIDVsAtoSf7aIgoRFBFQl3jVPBSthFsiWWNx2lwXEFhZwlzi7 7jIjiM0CVHP87H6wvbwClhKXPl2HsgUlfky+xwLRqyWxfudxJghbXmLzmrfMEHcqSOw4+5oR YpeeRMunZqhdIhL7XrxjBLlTQmAdu8St5Q2sEMsEJL5NPsQC8YusxKYDUHMkJQ6uuMEygVFs FpLVs5CsnoVk9SwkKxYwsqxiFE0tSC4oTkovMtYrTswtLs1L10vOz93ECIyw0/+e9e9gvHvA +hBjMtD6icxSosn5wAjNK4k3NDYzsjA1MTU2Mrc0I01YSZz3/sOkICGB9MSS1OzU1ILUov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Qu+9pQmrElburjX3UT1dmKbEUZyQa ajEXFScCACqLnEH1AgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently cifs have all or nothing approach for directIO operations. cache=strict mode does not allow directIO while cache=none mode performs all the operations as directIO even when user does not specify O_DIRECT flag. This patch enables strict cache mode to honour directIO semantics. Signed-off-by: Namjae Jeon Signed-off-by: Ashish Sangwan --- *Changelog v2: - Also consider CIFS_MOUNT_NO_BRL flag. fs/cifs/dir.c | 8 ++++++++ fs/cifs/file.c | 8 ++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 3db0c5f..6cbd9c6 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -497,6 +497,14 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry, goto out; } + if (file->f_flags & O_DIRECT && + CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) { + if (CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) + file->f_op = &cifs_file_direct_nobrl_ops; + else + file->f_op = &cifs_file_direct_ops; + } + file_info = cifs_new_fileinfo(&fid, file, tlink, oplock); if (file_info == NULL) { if (server->ops->close) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index bee733e..2e3720f 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -467,6 +467,14 @@ int cifs_open(struct inode *inode, struct file *file) cifs_dbg(FYI, "inode = 0x%p file flags are 0x%x for %s\n", inode, file->f_flags, full_path); + if (file->f_flags & O_DIRECT && + cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) { + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) + file->f_op = &cifs_file_direct_nobrl_ops; + else + file->f_op = &cifs_file_direct_ops; + } + if (server->oplocks) oplock = REQ_OPLOCK; else