From patchwork Mon Jan 30 21:39:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovskiy X-Patchwork-Id: 9546145 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 EBEE760425 for ; Mon, 30 Jan 2017 21:58:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E89C1283EB for ; Mon, 30 Jan 2017 21:58:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBE8A283EF; Mon, 30 Jan 2017 21:58:54 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 3D8A5283EB for ; Mon, 30 Jan 2017 21:58:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752915AbdA3V6w (ORCPT ); Mon, 30 Jan 2017 16:58:52 -0500 Received: from mail-by2nam03on0131.outbound.protection.outlook.com ([104.47.42.131]:42496 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752767AbdA3V6u (ORCPT ); Mon, 30 Jan 2017 16:58:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=uIc024jlqACRswj0mNmHXMx3ukR8w0Z3+GAy6ss2KEI=; b=RXlDwT5IQ91DOVjjahhbkNxDwZpGa1H4a3Enurclu1X05NHFYp/ffPiYD5UZraljIpNLPHRMjQ3Q/jtQwc1nbglTJTI0ey1TVX08SK/bnLXCIgHEyaYBjM0HPRXINDlhW5DEErPtW6p2RNBf6OUkE4AgCtz2WzmJ6k7fGOeReXM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=pshilov@microsoft.com; Received: from ubuntu-vm.corp.microsoft.com (2001:4898:80e8:b::63b) by BN6PR03MB2545.namprd03.prod.outlook.com (10.173.142.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.874.12; Mon, 30 Jan 2017 21:39:57 +0000 From: Pavel Shilovsky To: Subject: [PATCH v2 06/15] CIFS: Separate RFC1001 length processing for SMB2 read Date: Mon, 30 Jan 2017 13:39:35 -0800 Message-ID: <1485812384-28870-7-git-send-email-pshilov@microsoft.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485812384-28870-1-git-send-email-pshilov@microsoft.com> References: <1485812384-28870-1-git-send-email-pshilov@microsoft.com> MIME-Version: 1.0 X-Originating-IP: [2001:4898:80e8:b::63b] X-ClientProxiedBy: BN6PR1401CA0011.namprd14.prod.outlook.com (10.174.237.149) To BN6PR03MB2545.namprd03.prod.outlook.com (10.173.142.148) X-MS-Office365-Filtering-Correlation-Id: 78755489-8c75-4625-6dbc-08d449588952 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN6PR03MB2545; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2545; 3:OQxDoOk0KkRRC1QiELKBvh3YhXoeys6SqnB1EpnMZXGU/1IDo54kEu4GC11XRKHkIOGuuPXsE7HC2n/T4OY54JSbhG/7M0/ApNCkyoVbpR2zOjHJ54D4EPNhETJlPlyquaQMzgbQgSlu0TuVBTvOAqK2Z7FQmz55aZAxR3JEQ4PpWbqxJFLDBdRhJMvznoxY6Hxgjz9UqA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4S0csoJkIuTX2AyOv0nQmCa7Hp7MlCFyugev8lx3erNF1uLmd4P03Rn1Ag8EYPRWfJhEPIAB6O7eH66VYNrhfiP+Dqb2KSy6E5U6Yuydixiqa4L+5MZ++p8+KfV00yIdi67hMPe3KrRkdAin6pMmPLqNk8DCs3qC83q57+wPTQrvMQi7V+ShXfm247dSWlmcBO3wphDA5VQ2HDXBf6h/jvN2/Q5FjHoEKRTthxwalSWh9QiJYMgPy1Ig0EE/J0u+70pZhB40J4LoMJaoq/3aJa8yLL0V/K9QTfWcssDprWNiLBhDWIusgaEIx6S X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(158342451672863); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123564025)(20161123562025)(20161123560025)(6072148)(6047074); SRVR:BN6PR03MB2545; BCL:0; PCL:0; RULEID:; SRVR:BN6PR03MB2545; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2545; 4:S1IFTqpyKE2/jo+T1xjk4dUuXFDcFUvhxrJHACF7yD1l6UMu7CxhFsy4hzwYuPVYlzOiut78AIStioo/AECRRcKlkbUmDYf4TOSqfRM7pPK5RUIJ7k7r+IWRuknP0fHiVi0q1UiDFoNVCGNtopOZ+i0AJY4p8AKzTGf0prO2a7Q8K0ld9lTx7Q7ym0SdnTmqhXM/UxPZUnyzka0nAweUKDJ/gF4P08+6xVp29FZY/UHXJ6Y6cKgk6IsgTVnXeQbtwhwMvuX0FxDDoDUHu0iUhBYqAU0Va8qxvV+AOD+Syus1EUGDB0cdvWUOM/OZuUl2jA7zqH/hNWo9rxQJv3WSRSbyBe1cEZ+G7NANxw2M0kE620+AQdCZBS4Zfs0OS8FVGUt8GayqN91PcDGraiR85CHbPG9Hi54LY0QNQB9dU1vFpNJjz2LSy3oX/K1UplM4PSnt2/KWRyLOXc5yfS0njleRSNl+zrN3Z98T8IsrmnJBptEjlaj19wxZlYzj7onO+S71PxAT5UQzKalcCrpBOhRQNVKPn64mn2ym0YXQXIKhhlSGaLLxPPKJAMK91r4G8xtHBWBF9WfBFqnM0B6M34pm+aNlFs7wYPu8dIh2xbQXQgGqU9AQnlGoXL/dNRfQ9yVhb9l4qTC3RyxQz1Mtl7gklXf7+ijfpBQ/6kIRsWk= X-Forefront-PRVS: 0203C93D51 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(39450400003)(39410400002)(39840400002)(39860400002)(39850400002)(189002)(199003)(69234005)(86612001)(38730400001)(25786008)(6916009)(6666003)(106356001)(2950100002)(189998001)(50986999)(76176999)(86362001)(50226002)(105586002)(68736007)(107886002)(97736004)(2906002)(450100001)(6486002)(53936002)(101416001)(42186005)(8676002)(5660300001)(81166006)(305945005)(50466002)(81156014)(48376002)(5003940100001)(6116002)(36756003)(2351001)(92566002)(10290500002)(110136003)(7736002)(10090500001)(33646002)(47776003)(5005710100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BN6PR03MB2545; H:ubuntu-vm.corp.microsoft.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR03MB2545; 23:O9PBeGCKuCCoKylDO8Lk2B8gzUnWEwzzLRxUwTWij?= =?us-ascii?Q?7y/2YiafKmJ9xm7OrAKrv5Fa3fb+aeM/nMiD6m/6Qe6myjOR3AQ2tVjjDGTi?= =?us-ascii?Q?0BIMnAlgWKLE/FBC/lXOx5k648epa3k0B8j3aGQRToMcmXYhH/+uLxC20oyK?= =?us-ascii?Q?R29nK4hE78q1xtwojg30Otwvvh4qqePwO28QKvhF3qJEWwBb+411kTfZ1g39?= =?us-ascii?Q?QgtV8gN/OIw0wlrdfOn5Luyk8YnfWRom+pVwl+HSC5a6hVhyKXcj6c9dpTP9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7:a2LcjUrOw3A1vc1WofvDOnFu2XQCaY7ohZ/+FIKzA2DMlJW0QTO5SQfdvrD2s1qPxHtKT+SIQOrAsagivRJqOkAvJxouvDW0Nx9VCHilnbEc5B4chC9JcnNUlmacSY1/eWBYVn/9f/AXOkLF9fog/6xa8Gw5Je6/wJptobNtYEQugzrg79iB4T9JBTN3nVBR5XZD66mRZyrT5m3XDhMFhhx8IgmEecvxCWHYATIvDTIomlu68lI2WHNc9+QK0z9wgx3aQ9YjiMdzaYxufKok5gU2quk2tbf2z9Wv/BYJO4A108xH9/FD84UA75FBpDkcXXOg/gEqRtJ2uhCyG1fsyk1nxVIvBvoudD8La4b1aBul7FpQKoPJODDD8OTT3YiIih3BwqC8qt5b5DFaO4INdciomUGo3XUO8VERqUFfV6LOm19mOolJOQE4OZttTPxdkx8XWzXUpKEnGaxC7KUuiQ== X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2017 21:39:57.3640 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2545 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 Allocate and initialize SMB2 read request without RFC1001 length field to directly call cifs_send_recv() rather than SendReceive2() in a read codepath. Signed-off-by: Pavel Shilovsky --- fs/cifs/cifsproto.h | 3 ++ fs/cifs/smb2pdu.c | 89 ++++++++++++++++++++++++++++++++++++++++------------- fs/cifs/smb2pdu.h | 5 +-- fs/cifs/transport.c | 2 +- 4 files changed, 74 insertions(+), 25 deletions(-) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 8610f25..f87d1d6 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -78,6 +78,9 @@ extern int cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst, mid_receive_t *receive, mid_callback_t *callback, void *cbdata, const int flags); +extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses, + struct smb_rqst *rqst, int *resp_buf_type, + const int flags, struct kvec *resp_iov); extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *, struct smb_hdr * /* input */ , struct smb_hdr * /* out */ , diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index f6ba2c0..d1a9037 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -293,10 +293,46 @@ fill_small_buf(__le16 smb2_command, struct cifs_tcon *tcon, void *buf, *total_len = parmsize + sizeof(struct smb2_sync_hdr); } +/* init request without RFC1001 length at the beginning */ +static int +smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon, + void **request_buf, unsigned int *total_len) +{ + int rc; + struct smb2_sync_hdr *shdr; + + rc = smb2_reconnect(smb2_command, tcon); + if (rc) + return rc; + + /* BB eventually switch this to SMB2 specific small buf size */ + *request_buf = cifs_small_buf_get(); + if (*request_buf == NULL) { + /* BB should we add a retry in here if not a writepage? */ + return -ENOMEM; + } + + shdr = (struct smb2_sync_hdr *)(*request_buf); + + fill_small_buf(smb2_command, tcon, shdr, total_len); + + if (tcon != NULL) { +#ifdef CONFIG_CIFS_STATS2 + uint16_t com_code = le16_to_cpu(smb2_command); + + cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_sent[com_code]); +#endif + cifs_stats_inc(&tcon->num_smbs_sent); + } + + return rc; +} + /* * Allocate and return pointer to an SMB request hdr, and set basic * SMB information in the SMB header. If the return code is zero, this - * function must have filled in request_buf pointer. + * function must have filled in request_buf pointer. The returned buffer + * has RFC1001 length at the beginning. */ static int small_smb2_init(__le16 smb2_command, struct cifs_tcon *tcon, @@ -2140,16 +2176,17 @@ smb2_new_read_req(void **buf, unsigned int *total_len, int request_type) { int rc = -EACCES; - struct smb2_read_req *req = NULL; + struct smb2_read_plain_req *req = NULL; struct smb2_sync_hdr *shdr; - rc = small_smb2_init(SMB2_READ, io_parms->tcon, (void **) &req); + rc = smb2_plain_req_init(SMB2_READ, io_parms->tcon, (void **) &req, + total_len); if (rc) return rc; if (io_parms->tcon->ses->server == NULL) return -ECONNABORTED; - shdr = get_sync_hdr(req); + shdr = &req->sync_hdr; shdr->ProcessId = cpu_to_le32(io_parms->pid); req->PersistentFileId = io_parms->persistent_fid; @@ -2163,9 +2200,9 @@ smb2_new_read_req(void **buf, unsigned int *total_len, if (request_type & CHAINED_REQUEST) { if (!(request_type & END_OF_CHAIN)) { - /* 4 for rfc1002 length field */ - shdr->NextCommand = - cpu_to_le32(get_rfc1002_length(req) + 4); + /* next 8-byte aligned request */ + *total_len = DIV_ROUND_UP(*total_len, 8) * 8; + shdr->NextCommand = cpu_to_le32(*total_len); } else /* END_OF_CHAIN */ shdr->NextCommand = 0; if (request_type & RELATED_REQUEST) { @@ -2186,8 +2223,6 @@ smb2_new_read_req(void **buf, unsigned int *total_len, req->RemainingBytes = 0; *buf = req; - /* 4 for rfc1002 length field */ - *total_len = get_rfc1002_length(req) + 4; return rc; } @@ -2264,6 +2299,7 @@ smb2_async_readv(struct cifs_readdata *rdata) .rq_nvec = 2 }; struct TCP_Server_Info *server; unsigned int total_len; + __be32 req_len; cifs_dbg(FYI, "%s: offset=%llu bytes=%u\n", __func__, rdata->offset, rdata->bytes); @@ -2290,12 +2326,14 @@ smb2_async_readv(struct cifs_readdata *rdata) return rc; } - shdr = get_sync_hdr(buf); - /* 4 for rfc1002 length field */ - rdata->iov[0].iov_len = 4; - rdata->iov[0].iov_base = buf; - rdata->iov[1].iov_len = total_len - 4; - rdata->iov[1].iov_base = buf + 4; + req_len = cpu_to_be32(total_len); + + rdata->iov[0].iov_base = &req_len; + rdata->iov[0].iov_len = sizeof(__be32); + rdata->iov[1].iov_base = buf; + rdata->iov[1].iov_len = total_len; + + shdr = (struct smb2_sync_hdr *)buf; if (rdata->credits) { shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(rdata->bytes, @@ -2327,24 +2365,31 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms, unsigned int *nbytes, char **buf, int *buf_type) { int resp_buftype, rc = -EACCES; + struct smb2_read_plain_req *req = NULL; struct smb2_read_rsp *rsp = NULL; struct smb2_sync_hdr *shdr; - struct kvec iov[1]; + struct kvec iov[2]; struct kvec rsp_iov; unsigned int total_len; - char *req; + __be32 req_len; + struct smb_rqst rqst = { .rq_iov = iov, + .rq_nvec = 2 }; *nbytes = 0; rc = smb2_new_read_req((void **)&req, &total_len, io_parms, 0, 0); if (rc) return rc; - iov[0].iov_base = buf; - iov[0].iov_len = total_len; + req_len = cpu_to_be32(total_len); - rc = SendReceive2(xid, io_parms->tcon->ses, iov, 1, - &resp_buftype, CIFS_LOG_ERROR, &rsp_iov); - cifs_small_buf_release(iov[0].iov_base); + iov[0].iov_base = &req_len; + iov[0].iov_len = sizeof(__be32); + iov[1].iov_base = req; + iov[1].iov_len = total_len; + + rc = cifs_send_recv(xid, io_parms->tcon->ses, &rqst, &resp_buftype, + CIFS_LOG_ERROR, &rsp_iov); + cifs_small_buf_release(req); rsp = (struct smb2_read_rsp *)rsp_iov.iov_base; shdr = get_sync_hdr(rsp); diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 052342d..35ff9fa 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -823,8 +823,9 @@ struct smb2_flush_rsp { #define SMB2_CHANNEL_RDMA_V1 0x00000001 /* SMB3 or later */ #define SMB2_CHANNEL_RDMA_V1_INVALIDATE 0x00000001 /* SMB3.02 or later */ -struct smb2_read_req { - struct smb2_hdr hdr; +/* SMB2 read request without RFC1001 length at the beginning */ +struct smb2_read_plain_req { + struct smb2_sync_hdr sync_hdr; __le16 StructureSize; /* Must be 49 */ __u8 Padding; /* offset from start of SMB2 header to place read */ __u8 Flags; /* MBZ unless SMB3.02 or later */ diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 988f124..713981b2 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -665,7 +665,7 @@ cifs_setup_request(struct cifs_ses *ses, struct smb_rqst *rqst) return mid; } -static int +int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses, struct smb_rqst *rqst, int *resp_buf_type, const int flags, struct kvec *resp_iov)