From patchwork Tue Dec 6 22:02:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovskiy X-Patchwork-Id: 9463323 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 9F0E860231 for ; Tue, 6 Dec 2016 22:17:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90951284F0 for ; Tue, 6 Dec 2016 22:17:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85823284F4; Tue, 6 Dec 2016 22:17:56 +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 0FEE9284F0 for ; Tue, 6 Dec 2016 22:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752103AbcLFWRz (ORCPT ); Tue, 6 Dec 2016 17:17:55 -0500 Received: from mail-bn3nam01on0107.outbound.protection.outlook.com ([104.47.33.107]:27253 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751618AbcLFWRy (ORCPT ); Tue, 6 Dec 2016 17:17:54 -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=8UH8cjb6VEnrXxD0cvgD8d0Gg2elmcTnG5OKkLAyqRk=; b=j75Avw61HWV7F2QhtyNcrArnKjGtmxQd26cp87h6PahTCyrfe0pGkCjeIy43MMZwLv1uCIiDH0uXkNxGmfzHshO/t42f5TV7Mw4vUWOnAoB2yWYavVLuebLzca91K4f09+NdAMEUY+UiJTXvV+6TRS8hmcNWJo6auWl9oS13CTk= 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:49 +0000 From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 12/15] CIFS: Add copy into pages callback for a read operation Date: Tue, 6 Dec 2016 14:02:35 -0800 Message-Id: <1481061758-52020-13-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: a3182b5c-fd51-44d6-9ffd-08d41e239e8b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY4PR03MB2549; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2549; 3:FQ1xm6tgEvDb8iHsh6zaORgw3NNZugkFuAANpfyuuKemToK6fAYdKETqDzcp9Hd1vDHAxnBZzdSM8fiige3UlZDWSko9j2dXCj2G6ZtwYT7HWJpxein6kHkgRewi+xDHV3iirjOy6ox2VIumfzWrvd8+vnYnyeSj8S5juAEmSQWPCEerrK7hemCzeYR4o4CJa54VI5dpyo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pppeipcIHeI3QqCaGHtkK9nWB+QcC80EPRhk8V0dfm1Te69jVkfwhHa+IizPh5RNsROvvW/ggaYuwlYiw4JhhRdF86Hk0AkPIt2tFrVA32en4VH9TX4Fss3iy4VMQHxWYEmfHdRv0lQjiYsQScXHUUy9CQ75/RVMES6fQqkR0TWMPzzuHgEExpIV20uiXQfgYipVUr7jOcxlMOABv3Y6vzphLw2NTTg94QbCHgKaY1e2WrrYhtKcR5uQWyShri7nfH0MfB/Zyf2zkO2jifK/GKsaJFdKQ8pdsJwOHqCeDNs4AuLur X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; 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:Nt5Y2BvEt/u7RB5DaodW3STlrQqbua682AuZHPSlevGngqh2G1qVVlc5M/xz/+Zfj1tO0D6ZHNGDNg3JTSc4WQhENu+ydGe2z1jkyiz3B76OR3B1lUdi9BF4cL+qYjLCWs2O919CiZPEaNBnU0ocVHYh4SAhtO+yNeiZI76HFjjXa+FE6Qbjee472/Y208i6Re6jjYf/cJNOCSeQwPxU+OO6FKK89ccBE+d7ECY/JwyElciwjbukE+ybv1cH9M2LUHRW5Ob5GZbO1SmZY3pPhjIXAYUkoAFmawVe0c/8JtIX3egDaIU+BJk3J0LCGezF9Oq3ibfJeu9hsxvq8C9VOSy6/sNxSzpBSRfHl6p5apjgG5MRBOVz7HhwQKFK5HcEsgyIsu2Dj6GevXaGg9OTKtf38JiUVwEyb5ldgJD2dN0c4Jmzu7mdXAynANjXUzANxslkfeFWwP4IDUKuYK+liZcjR0/FsjWkxDaTSCQyEijEEpJyfQK/PHC8Y6NRSJ9ycjpZ3yf0qmfBrUjcD3oKpi4J7wA8vYYDwrCMZxjn1PhrBa/0dCBigo8hEcCHQ9f1f4pZOHXPAn7InuQkJ/t2tuaChTXPztHFRQPQ0HEJ5NA= X-Forefront-PRVS: 01480965DA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(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-ascii?Q?1; CY4PR03MB2549; 23:vQG9kHujlERKFcb34LO7x6ZuVXCjIfdN2AH6BMDPC?= =?us-ascii?Q?5S3CNtnGuvJyRSC9VvQK9mJWCoq/D06Wt67B7o2Fr26JALixWRorMCN6xSmc?= =?us-ascii?Q?FS8xWBXR8HGLxYdjgRZnTwS3Pz/bYmHNPftIKpYtBbji0CT397lH9C2V/0b2?= =?us-ascii?Q?yn6kXVbDV4OYqiJTDd4MjYszIi+RjNEqVG8AkdjZa9HnlSOJcGZc2xZAuNic?= =?us-ascii?Q?k7qv3rCSJHOSeOdUZ5SQAmnulMiuZG/et0gBbKXRgIUoSQknXW6oUbLN357C?= =?us-ascii?Q?l40pYBluliK0xIbLGy+kk8yY9EREyfYMCM7Ef87VvwG56uQQmJUKzQQHKFLI?= =?us-ascii?Q?lRYTu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KvaU+1GCo8?= =?us-ascii?Q?sfVY+aecsZFKzkgkBQRWm8xyRTZ2ug0OIXLwJ6Hj+AUbkvyDfZX6W6Zq5wuj?= =?us-ascii?B?Zz09?= X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2549; 6:66MszkfzjLojuTRk8moGVswE/+MNaoq7vOZyP1ujevjPudsPq7dqrYAI7noQJVgsDVxKP1WbKoXmpv3DjolH1OISbPkA0EKYoXWoCH88PNeME9XzN2ilmxzmcbPPmjTwKdnE1JIAjNmTzWz5AOVvMauZp/ALY20jILWrH0hYLbNRZUsDv540PJrM/nQ2bN7FRPki1nuzmEN6IJz2elpRel16YPrOO/IoQmOOa24Lf42Q6K5TD5C+LzJnJpSqrHb25sivhfBUjQ0gZZIhTEKbVbl8XjeyIbF5vlM9FpEXclxOnhfaaTZYSAOMUd590wdTP32AotgGM9w3ptsEujk7yDBnKRKxU2Cp4zliccifdtvYyzoZ3v6QdrsbSq0aznkbJKjBbJbhKmMH3qBmiRfd172cWHKkYyBfqFXPfB0lSTXdn6uv6hF5+m2ueK/iKwGUa6AbuMImGrhoHPMcd5uYDg==; 5:Vi9iBIoxSGA114e5vlqLCc5FKu6lf39jkFzqn7CdfM9dZAitbF+4LCtP/GqyuSsB2vhPdMswSkteKKngAZkkc6GCviSe1Pz1E3TT3K42xTD9kIG/dzxU7UtcpyXmLslvEWi435mfqSA6qdezxz5vcyxsnrEeJgArx/0f81Gx31o=; 24:/fiQ733ZY7Csau+pdvKg0o0yPbld6d94yJ/DsKbV9cQdE7JPWDUsCJLoRAQZZeQh5KICoNRG37Dl0+SgKASjgYw0eLrnhPXFuC8xhcvehco= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2549; 7:FE+Og2n65vb8L+wAnVrVCwbwnO4I6/5qiIwTyQyKNlkud/UAFTjf9MRCMEhJ8kmkGplYqdxkKA7d6qskdg5QjHqqFwVjBs+sFal4+XguCWEZXyzxef0S4kNSEirJEo0GetaMdUmSPB20TotStLmo4JjYKg+7GUFlBeQtq0xlfreIRIGryYCCGZBQeXRPDvNPA7jUtApT4GBG3jPLdAq+Wh+sERCZtPDSbsSAuixYWl4iPOFgjF1FdnJj48kiBR8Kog+TnS5kivYtAksy7lJ6e3dSDAZ1lGGqIvXd54npHN6c+YLGa7ZP1rDn2vNe6kieeJGdwK/oWbHxPNqgKPI/WWjTzOpW0qSUhhl78agBbl6NW8EaSFbukqrNhYnlfr3rL1lLH/rNRCoGdSABy6vJOw0TQcjv5Fz4OMNYuDPaWKeI0BnhjfetGJBreO9FgUXerz4KY4lwtcI/XOWl841Q5g== X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2016 22:02:49.7871 (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 Since we have two different types of reads (pagecache and direct) we need to process such responses differently after decryption of a packet. The change allows to specify a callback that copies a read payload data into preallocated pages. Signed-off-by: Pavel Shilovsky --- fs/cifs/cifsglob.h | 3 +++ fs/cifs/file.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index dc41ae4..fa56f47 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -1127,6 +1127,9 @@ struct cifs_readdata { int (*read_into_pages)(struct TCP_Server_Info *server, struct cifs_readdata *rdata, unsigned int len); + int (*copy_into_pages)(struct TCP_Server_Info *server, + struct cifs_readdata *rdata, + struct iov_iter *iter); struct kvec iov[2]; unsigned int pagesz; unsigned int tailsz; diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 18a1e1d..2586ba1 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2903,8 +2903,9 @@ cifs_uncached_readv_complete(struct work_struct *work) } static int -cifs_uncached_read_into_pages(struct TCP_Server_Info *server, - struct cifs_readdata *rdata, unsigned int len) +uncached_fill_pages(struct TCP_Server_Info *server, + struct cifs_readdata *rdata, struct iov_iter *iter, + unsigned int len) { int result = 0; unsigned int i; @@ -2933,7 +2934,10 @@ cifs_uncached_read_into_pages(struct TCP_Server_Info *server, rdata->tailsz = len; len = 0; } - result = cifs_read_page_from_socket(server, page, n); + if (iter) + result = copy_page_from_iter(page, 0, n, iter); + else + result = cifs_read_page_from_socket(server, page, n); if (result < 0) break; @@ -2945,6 +2949,21 @@ cifs_uncached_read_into_pages(struct TCP_Server_Info *server, } static int +cifs_uncached_read_into_pages(struct TCP_Server_Info *server, + struct cifs_readdata *rdata, unsigned int len) +{ + return uncached_fill_pages(server, rdata, NULL, len); +} + +static int +cifs_uncached_copy_into_pages(struct TCP_Server_Info *server, + struct cifs_readdata *rdata, + struct iov_iter *iter) +{ + return uncached_fill_pages(server, rdata, iter, iter->count); +} + +static int cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, struct cifs_sb_info *cifs_sb, struct list_head *rdata_list) { @@ -2991,6 +3010,7 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, rdata->pid = pid; rdata->pagesz = PAGE_SIZE; rdata->read_into_pages = cifs_uncached_read_into_pages; + rdata->copy_into_pages = cifs_uncached_copy_into_pages; rdata->credits = credits; if (!rdata->cfile->invalidHandle || @@ -3341,8 +3361,9 @@ cifs_readv_complete(struct work_struct *work) } static int -cifs_readpages_read_into_pages(struct TCP_Server_Info *server, - struct cifs_readdata *rdata, unsigned int len) +readpages_fill_pages(struct TCP_Server_Info *server, + struct cifs_readdata *rdata, struct iov_iter *iter, + unsigned int len) { int result = 0; unsigned int i; @@ -3396,7 +3417,10 @@ cifs_readpages_read_into_pages(struct TCP_Server_Info *server, continue; } - result = cifs_read_page_from_socket(server, page, n); + if (iter) + result = copy_page_from_iter(page, 0, n, iter); + else + result = cifs_read_page_from_socket(server, page, n); if (result < 0) break; @@ -3408,6 +3432,21 @@ cifs_readpages_read_into_pages(struct TCP_Server_Info *server, } static int +cifs_readpages_read_into_pages(struct TCP_Server_Info *server, + struct cifs_readdata *rdata, unsigned int len) +{ + return readpages_fill_pages(server, rdata, NULL, len); +} + +static int +cifs_readpages_copy_into_pages(struct TCP_Server_Info *server, + struct cifs_readdata *rdata, + struct iov_iter *iter) +{ + return readpages_fill_pages(server, rdata, iter, iter->count); +} + +static int readpages_get_pages(struct address_space *mapping, struct list_head *page_list, unsigned int rsize, struct list_head *tmplist, unsigned int *nr_pages, loff_t *offset, unsigned int *bytes) @@ -3561,6 +3600,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, rdata->pid = pid; rdata->pagesz = PAGE_SIZE; rdata->read_into_pages = cifs_readpages_read_into_pages; + rdata->copy_into_pages = cifs_readpages_copy_into_pages; rdata->credits = credits; list_for_each_entry_safe(page, tpage, &tmplist, lru) {