From patchwork Fri May 18 00:22:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 10407943 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 79B3C602CB for ; Fri, 18 May 2018 00:25:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 672FF287C7 for ; Fri, 18 May 2018 00:25:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C043287CB; Fri, 18 May 2018 00:25:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EABF2287C7 for ; Fri, 18 May 2018 00:25:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752420AbeERAYk (ORCPT ); Thu, 17 May 2018 20:24:40 -0400 Received: from a2nlsmtp01-04.prod.iad2.secureserver.net ([198.71.225.38]:34668 "EHLO a2nlsmtp01-04.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752128AbeERAXf (ORCPT ); Thu, 17 May 2018 20:23:35 -0400 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id JTAHfrHHtN7esJTAHfCI8a; Thu, 17 May 2018 17:22:33 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.91) (envelope-from ) id 1fJTAH-0001Un-0M; Thu, 17 May 2018 17:22:33 -0700 From: Long Li To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org Cc: Long Li Subject: [RFC PATCH 09/09] Introduce cache=rdma moutning option Date: Thu, 17 May 2018 17:22:14 -0700 Message-Id: <20180518002214.5657-10-longli@linuxonhyperv.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180518002214.5657-1-longli@linuxonhyperv.com> References: <20180518002214.5657-1-longli@linuxonhyperv.com> Reply-To: longli@microsoft.com X-CMAE-Envelope: MS4wfEhApYCCGHyCILD2EvvGQ8ryuS/zP8a5nYw7PcVOjY3aK0nlWnVrvOXxk9BN67bi0W9SwAjpDmEEL7PqQb+xsbYvIXkQsp8E26qJdH9RqA+Dhwdr9P8Q RfyKfXT8+3JreRtsrSC2Gk6ZukfOihxUOKdYCjf8HHc3darHNejgBtknb7vkL4/hDVkT3XW1oSxg6dQJGN4yY7kVXtZ79l2wiZhs8qaVyNqhv/3JP/9ZaF7E OFew7M7hvv9bufGOGldYM+gSxdb1PWQ8hHvfX4lKOAuMcB8T0WXmhU4FgmMcEXzlq6lyLiH9IIqPIzfQrWUx/NtTsD90td4aKyOtVzQ06CCds8t6Oi9Z06ng Nmaeny6J+YNnud9MpICPBOnAc0RK/UQxLnRKl1EJhZa9ryZXYJdePQGEsL8WsxBhv5kxFLwC Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Long Li When cache=rdma is enabled on mount options, CIFS do not allocate internal data buffer pages for I/O, data is read/writen directly to user memory via RDMA. Signed-off-by: Long Li --- fs/cifs/cifs_fs_sb.h | 2 ++ fs/cifs/cifsglob.h | 1 + fs/cifs/connect.c | 9 +++++++++ fs/cifs/dir.c | 5 +++++ fs/cifs/file.c | 4 ++++ fs/cifs/inode.c | 4 +++- 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h index 350fa55..7c28dc3 100644 --- a/fs/cifs/cifs_fs_sb.h +++ b/fs/cifs/cifs_fs_sb.h @@ -51,6 +51,8 @@ */ #define CIFS_MOUNT_UID_FROM_ACL 0x2000000 /* try to get UID via special SID */ +#define CIFS_MOUNT_DIRECT_RDMA 0x4000000 + struct cifs_sb_info { struct rb_root tlink_tree; spinlock_t tlink_tree_lock; diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index a51855c..3bec63f 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -518,6 +518,7 @@ struct smb_vol { bool server_ino:1; /* use inode numbers from server ie UniqueId */ bool direct_io:1; bool strict_io:1; /* strict cache behavior */ + bool rdma_io:1; bool remap:1; /* set to remap seven reserved chars in filenames */ bool sfu_remap:1; /* remap seven reserved chars ala SFU */ bool posix_paths:1; /* unset to not ask for posix pathnames. */ diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 46d0cf4..c92b3d8 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -282,6 +282,7 @@ enum { Opt_cache_loose, Opt_cache_strict, Opt_cache_none, + Opt_cache_rdma, Opt_cache_err }; @@ -289,6 +290,7 @@ static const match_table_t cifs_cacheflavor_tokens = { { Opt_cache_loose, "loose" }, { Opt_cache_strict, "strict" }, { Opt_cache_none, "none" }, + { Opt_cache_rdma, "rdma" }, { Opt_cache_err, NULL } }; @@ -1128,6 +1130,9 @@ cifs_parse_cache_flavor(char *value, struct smb_vol *vol) vol->direct_io = true; vol->strict_io = false; break; + case Opt_cache_rdma: + vol->rdma_io = true; + break; default: cifs_dbg(VFS, "bad cache= option: %s\n", value); return 1; @@ -3612,6 +3617,10 @@ int cifs_setup_cifs_sb(struct smb_vol *pvolume_info, cifs_dbg(FYI, "mounting share using direct i/o\n"); cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO; } + if (pvolume_info->rdma_io) { + cifs_dbg(VFS, "mounting share using rdma i/o\n"); + cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_RDMA; + } if (pvolume_info->mfsymlinks) { if (pvolume_info->sfu_emul) { /* diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 81ba6e0..ce69b1c 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -557,6 +557,11 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry, file->f_op = &cifs_file_direct_ops; } + if (file->f_flags & O_DIRECT && + CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_DIRECT_RDMA) + file->f_op = &cifs_file_direct_rdma_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 0b394db..30ccf6a 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -492,6 +492,10 @@ int cifs_open(struct inode *inode, struct file *file) file->f_op = &cifs_file_direct_ops; } + if (file->f_flags & O_DIRECT && + cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_RDMA) + file->f_op = &cifs_file_direct_rdma_ops; + if (server->oplocks) oplock = REQ_OPLOCK; else diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 3c371f7..7991298 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -44,7 +44,9 @@ static void cifs_set_ops(struct inode *inode) switch (inode->i_mode & S_IFMT) { case S_IFREG: inode->i_op = &cifs_file_inode_ops; - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_RDMA) + inode->i_fop = &cifs_file_direct_rdma_ops; + else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) inode->i_fop = &cifs_file_direct_nobrl_ops; else