From patchwork Sat Jul 6 06:13:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 11033559 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFDE0138B for ; Sat, 6 Jul 2019 06:14:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CC1228AC8 for ; Sat, 6 Jul 2019 06:14:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9098A28AD5; Sat, 6 Jul 2019 06:14:04 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 0F9FB28AC8 for ; Sat, 6 Jul 2019 06:14:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725900AbfGFGOD (ORCPT ); Sat, 6 Jul 2019 02:14:03 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45631 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725887AbfGFGOD (ORCPT ); Sat, 6 Jul 2019 02:14:03 -0400 Received: by mail-pl1-f193.google.com with SMTP id y8so840097plr.12 for ; Fri, 05 Jul 2019 23:14:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=IFrctn3G5hJQKPOD5ymme59A3yIl5LKicKYiHLn37OU=; b=Jy5hvf04AqlXFIFTPNzg9OOMovTLDJuh17ZkaJRRP/BlHjVwvaPEjvv5xgcvhRGolD wexsgQpsePkj5xHYm9B7jqv+0vZ3GQRAbnwbhFdTcsa7uWHK+a2cv/BvkZg0vo4nPyDB zqN395GjG69FCRI+6kM/HmS78DWcKjgBEzTD0a+5QKTHK1Yx4g88Rv/0bcvuaR4eZtF7 qSa848UwOTWxCEma4Ts8zIalVHBfVjugdzqQ/9TmWmVDF910ntQ6wmbYuHUA2lW9Hn+V S/YrN4PcSnxVpp27E8hTb8f/ZolONIglI8wAcsnnQ16cH3CYwawOob6sGpiZITtnH2RM K2jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=IFrctn3G5hJQKPOD5ymme59A3yIl5LKicKYiHLn37OU=; b=AViWb+dIZhv6DA4MzsnAkCNK7j9rz/loIj5w/0xJMZkZMU/g2TUVK3Z+XKu9uvupdD P8GUsUZ1OrHd10eoXDEIhQ0K85y9eS8HZV2hA+OhUiyTQ8x1KJ/QUJrKb0bNyR30l/hy w7DzxFH+VO+kWnaK4Z6E6IIWJuRSlPxZJ9DDJeQ3+iUbqRc5BaojO48Zn37EyNlleJQM Hb9JMa+GdHaFgGgWu7pyc9duzaIZc2rZCNvItVC8Oz9z9jYAAUdzZLo66XlYFRdSuqZB f9vsx+zOifb6fOOo37jDhKMjpI24/rrAsTfntbhaEcShIPfr94SqIX1FA4WwZxEuvgnX oz/A== X-Gm-Message-State: APjAAAU2AU5fLh+H7WXUslvH190XWE+Vzri733HqLjRk46x3I49kb97O WsQ48fZpQDx8lMwnjeCmccQ+759RslktTCoy4jv5BHtmsUE= X-Google-Smtp-Source: APXvYqyu+zQWpPUhSK39k4D4RUhFjetnEH1up4EM+Xp1O/Hv73r7yeNz+2eg9noCtXeomDelsDrJKqtKpzToowGRFyM= X-Received: by 2002:a17:902:2a68:: with SMTP id i95mr9980386plb.167.1562393642145; Fri, 05 Jul 2019 23:14:02 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Sat, 6 Jul 2019 01:13:51 -0500 Message-ID: Subject: [PATCH] Improve performance of POSIX open - request query disk id open context To: CIFS Cc: samba-technical 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 We can cut the number of roundtrips on open (may also help some rename cases as well) by returning the inode number in the SMB2 open request itself instead of querying it afterwards via a query FILE_INTERNAL_INFO. This should significantly improve the performance of posix open. Add SMB2_CREATE_QUERY_ON_DISK_ID create context request on open calls so that when server supports this we can save a roundtrip for QUERY_INFO on every open. Follow on patch will add the response processing for SMB2_CREATE_QUERY_ON_DISK_ID context and optimize smb2_open_file to avoid the extra network roundtrip on every posix open. This patch adds the context on SMB2/SMB3 open requests. From eb91a7da9d286c46bcaf30c9d8bd9ca977ad9832 Mon Sep 17 00:00:00 2001 From: Steve French Date: Sat, 6 Jul 2019 01:03:07 -0500 Subject: [PATCH] SMB3: query inode number on open via create context We can cut the number of roundtrips on open (may also help some rename cases as well) by returning the inode number in the SMB2 open request itself instead of querying it afterwards via a query FILE_INTERNAL_INFO. This should significantly improve the performance of posix open. Add SMB2_CREATE_QUERY_ON_DISK_ID create context request on open calls so that when server supports this we can save a roundtrip for QUERY_INFO on every open. Follow on patch will add the response processing for SMB2_CREATE_QUERY_ON_DISK_ID context and optimize smb2_open_file to avoid the extra network roundtrip on every posix open. This patch adds the context on SMB2/SMB3 open requests. Signed-off-by: Steve French --- fs/cifs/smb2pdu.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ fs/cifs/smb2pdu.h | 6 ++++++ 2 files changed, 54 insertions(+) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 34d5397a1989..f58e4dc3987b 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2118,6 +2118,48 @@ add_twarp_context(struct kvec *iov, unsigned int *num_iovec, __u64 timewarp) return 0; } +static struct crt_query_id_ctxt * +create_query_id_buf(void) +{ + struct crt_query_id_ctxt *buf; + + buf = kzalloc(sizeof(struct crt_query_id_ctxt), GFP_KERNEL); + if (!buf) + return NULL; + + buf->ccontext.DataOffset = cpu_to_le16(0); + buf->ccontext.DataLength = cpu_to_le32(0); + buf->ccontext.NameOffset = cpu_to_le16(offsetof + (struct crt_query_id_ctxt, Name)); + buf->ccontext.NameLength = cpu_to_le16(4); + /* SMB2_CREATE_QUERY_ON_DISK_ID is "QFid" */ + buf->Name[0] = 'Q'; + buf->Name[1] = 'F'; + buf->Name[2] = 'i'; + buf->Name[3] = 'd'; + return buf; +} + +/* See MS-SMB2 2.2.13.2.9 */ +static int +add_query_id_context(struct kvec *iov, unsigned int *num_iovec) +{ + struct smb2_create_req *req = iov[0].iov_base; + unsigned int num = *num_iovec; + + iov[num].iov_base = create_query_id_buf(); + if (iov[num].iov_base == NULL) + return -ENOMEM; + iov[num].iov_len = sizeof(struct crt_query_id_ctxt); + if (!req->CreateContextsOffset) + req->CreateContextsOffset = cpu_to_le32( + sizeof(struct smb2_create_req) + + iov[num - 1].iov_len); + le32_add_cpu(&req->CreateContextsLength, sizeof(struct crt_query_id_ctxt)); + *num_iovec = num + 1; + return 0; +} + static int alloc_path_with_tree_prefix(__le16 **out_path, int *out_size, int *out_len, const char *treename, const __le16 *path) @@ -2446,6 +2488,12 @@ SMB2_open_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, __u8 *oplock, return rc; } + if (n_iov > 2) { + struct create_context *ccontext = + (struct create_context *)iov[n_iov-1].iov_base; + ccontext->Next = cpu_to_le32(iov[n_iov-1].iov_len); + } + add_query_id_context(iov, &n_iov); rqst->rq_nvec = n_iov; return 0; diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 053ec621e7b9..a397cea744cd 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -841,6 +841,12 @@ struct crt_twarp_ctxt { } __packed; +/* See MS-SMB2 2.2.13.2.9 */ +struct crt_query_id_ctxt { + struct create_context ccontext; + __u8 Name[8]; +} __packed; + #define COPY_CHUNK_RES_KEY_SIZE 24 struct resume_key_req { char ResumeKey[COPY_CHUNK_RES_KEY_SIZE]; -- 2.20.1