From patchwork Tue Dec 6 22:02:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovskiy X-Patchwork-Id: 9463317 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 E5AFF60231 for ; Tue, 6 Dec 2016 22:17:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7259284F0 for ; Tue, 6 Dec 2016 22:17:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC19F284F5; Tue, 6 Dec 2016 22:17:50 +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 EC7BF284F8 for ; Tue, 6 Dec 2016 22:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751987AbcLFWRs (ORCPT ); Tue, 6 Dec 2016 17:17:48 -0500 Received: from mail-bn3nam01on0099.outbound.protection.outlook.com ([104.47.33.99]:15924 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751817AbcLFWRp (ORCPT ); Tue, 6 Dec 2016 17:17:45 -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=U2wtBI7ag00RDnQ3OAXwupldU0L72tFiyT3mIJ/xyddi7MBEVVJWSuF50DonVBYhEdAuVgHRJJXnFyWYhHm5sw23J4H8GzK5DiWVZ5IPmw+ijY/er6m0Y2efwzwRze/h08jmxSV+7YZQ4IODvh94XOu+ga+yV0iM5i8kjlsG/ME= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=pshilov@microsoft.com; Received: from ubuntu-vm.corp.microsoft.com (2001:4898:80e8:2::63b) by CY4PR03MB2549.namprd03.prod.outlook.com (10.173.41.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.761.9; Tue, 6 Dec 2016 22:02:48 +0000 From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 06/15] CIFS: Separate RFC1001 length processing for SMB2 read Date: Tue, 6 Dec 2016 14:02:29 -0800 Message-Id: <1481061758-52020-7-git-send-email-pshilov@microsoft.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481061758-52020-1-git-send-email-pshilov@microsoft.com> References: <1481061758-52020-1-git-send-email-pshilov@microsoft.com> MIME-Version: 1.0 X-Originating-IP: [2001:4898:80e8:2::63b] X-ClientProxiedBy: CY1PR17CA0004.namprd17.prod.outlook.com (10.163.68.14) To CY4PR03MB2549.namprd03.prod.outlook.com (10.173.41.148) X-MS-Office365-Filtering-Correlation-Id: 45db3b01-2083-4bfc-3fc1-08d41e239d7c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY4PR03MB2549; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2549; 3:0r4v+8xcVfKrKb4KNydLzfXHmnuPnN7Wo8/QLBB4hfByu48mtKGN2hifGAv/85c/RQfhWb3sRRQkHCr6uuAl4U6tl9kAq9kYm/koHXzDZKzLW86Hz1/uMEd7EYPdEGFrFLKigmKL30DjMIKj48QJWpDAdd1HhmzmXPCCj/m/5zKzfsBpLjgvwXFvgZgh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86qzp0B7OmXroq+4Q9N/4uQL9VOmnxC3Ngdxl65LObfRGa0ONSVj7UpVGjgbzhMfb0GlfB45HuLFWB7Fvc6tguc9NGmQwleZ5bx9GHZqCFnjp+x7tX6Q0WMeSiBdSH2Bq1PzhdNnrfef0B5RYkVnHuwOE07xFYAD2uKLMaNiw==; 20:YZyPrx4WZdPwLniLrhIOpv7ZVP69GOsbHUIt8Am4UjwHfHSkgVaK468XVOo4zKrhofppgQcGPF33xU3b9ubx0cYBZ7LRNcN4M4tGTOdOofZSzDHyeWDkx8XJ/kGZrg5VRB3eVy+qz7Bkl1OHeR04McYh75tGg1O2ulnNZNzzLmm5em1W+m/GveqGi+iAWjhfyMyxnPweoHHBx8zg8zT324l2rBKm2xuoBV/otv27obzCNDa2mbTslszzq3ZZCGOCOHYhorUXsMW0D65WxOkkGckUldeqvEGBu5OhQFdp+hLXIcjmRNeiLo/l3qW0v/jSRKWAghgVkJAB/Q+5b4DwHmuJIpTiI5OiPnopP8XdzbAXU+0/mCpdmehA7vZOk1xaamdUm3436JJvLf3BB8QUMQJh9uVp+NZY/8nUwlgJbTSXhP4vrFkcqbAStpI7vNJShgKLOQB+nU/dnACZ00dt6ItAweQ2VeewOQ9bZauGe0DcelyXpLGrbvukkwQXMz8z 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)(20161123560025)(20161123562025)(20161123564025)(20161123555025)(6047074)(6072148); SRVR:CY4PR03MB2549; BCL:0; PCL:0; RULEID:; SRVR:CY4PR03MB2549; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2549; 4:h9jBmwTO5BM0HiohnP33eSQHtDs1Q7T4cgYk88TjiRs2IrfmdthEPH+k6+gMiSrIAYTbWfdlJbLKiHqitLxY+NRkUKR0mc2+5ij8STxV1uJUu487xbK4/AlVoR6ntx9LZGX65xR1GtgsIsYGtQw4fgwwPQImAlfeCz+jVIj+FqOoFrOCNf1POZwrjpJTJEmroCiQAuK6fOUVKEJlBxcWNqm8W8nVGU2z5r4d9/W82o8FzuyVFi9P41c7hxv7Tr/CyAZV4pqJLmSRgrXPKjTyXXRuAj3JqaOBuQnj80k2Ynvs91DkXv+1CwavOwKRyD75k5ECRfi52PWuP3G9K7sUNfk+uaTfZ6JT+WSgss3k7MpMXGJ1xZPIsBSUjCbU3yGloA5xxZDju/6aGxhNCIut8eSKRtccxpfsb/9UUZ+vtrSXA89PKKDbZlVjYyX4ANIRiPjmRDE2ambPqVsUMmEfKv7gbIt4eClxmpOMOktlUVwhpGxA1HT7tsvAmZmg47BV1Z9/L9VFzGIn3d89Vb+Js9cmDlq0UdDchpjg/nOXTrpWWoIhVKdZ89VyKF6ZXrw4flK2FHKgI6fVr4QXP7Mvrw9DolDHIT75kZ3wADT43H9PC4uanDqiNKFQHkgjd52Kz+aTwZLPA8iac+1VPXcqWa//+81911zg4jHzxARHYKk= X-Forefront-PRVS: 01480965DA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(69234005)(199003)(189002)(50466002)(92566002)(101416001)(86362001)(33646002)(47776003)(48376002)(2950100002)(6916009)(106356001)(105586002)(6666003)(50986999)(42186005)(39860400001)(39850400001)(39840400001)(86612001)(76176999)(2361001)(110136003)(2351001)(450100001)(189998001)(5660300001)(10090500001)(5003940100001)(10290500002)(38730400001)(5005710100001)(8676002)(6116002)(36756003)(107886002)(39410400001)(733004)(7846002)(2906002)(39450400002)(6486002)(7736002)(50226002)(68736007)(305945005)(81156014)(97736004)(81166006); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR03MB2549; H:ubuntu-vm.corp.microsoft.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us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aUUbuw==; 5:godzd72/hoDIBCOo2Oreee3Mg+n01cHJ3jdYN10suBc11hQMQkT4kFncmYFOcWk7YqJjA0i9ucNFnEftDCT8ttCyiuDn/TZsO4yUOY+OCQc8QXCMtGTeULagUATfmAIKs0o7yv10UXjpDW33Jz+sXC0E+rCTSNLmyAK3PhD+MGQ=; 24:xjEs3ulJPJ+WmVPIRFmLJaSrrilf3n/MQTabt8u7xsbeJcmxQzxqFfEAj/ap/4+O5RA/rgv87t2TQIQjsXgsX8x7I/ZkVUUsItG9uyAcOFQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2549; 7:y7lWVeAkyALnbd5ta8f7tOzXb/No7D3XXNAPoz1zsjWinQSwsJ0t1PF0uogVQjTJGNoaFpRVrJAMipQ2FvQJ4tLq0IMrSwbqYvIXynOWihlck06wV1hWrQIC8FVeYMOW6Vn9MKVRe3/WHq7N3AO6S6yGLM/7eSPXAcIQUbOnAaAxZQpqhgjdCQKShSj97z5DtOAx6OBPQwtUV+5OnMYK4KZ2FKQhL8Wg7js2dFGkIoVQpkt8pDfzb8ct9NNixAyguUhr/fNcrjAgmHcjB8Vpn37rzY5IMO51yErIlzLOtdG+tyfCI5HYKMrdN2xkYLhdgWnmIY94Js+8e/vZK1Zwbrr+4lrDewK3yE173iefn9G/fiK+t3RlJCCYWXrWGkzcG4BSAz97oAGhnuNxuELKmEp/TIpK76FP0shLaUvUUFFsl9KLDvWPQ8gDtSiFP/mzsogqY5bfiVvqeze8XK9oTw== X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2016 22:02:48.0076 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB2549 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)