From patchwork Mon Jan 30 21:39:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovskiy X-Patchwork-Id: 9546129 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 34DA860415 for ; Mon, 30 Jan 2017 21:44:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F6D1283B4 for ; Mon, 30 Jan 2017 21:44:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 344B6283F4; Mon, 30 Jan 2017 21:44:01 +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 C945E283E7 for ; Mon, 30 Jan 2017 21:43:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754517AbdA3Vny (ORCPT ); Mon, 30 Jan 2017 16:43:54 -0500 Received: from mail-by2nam03on0114.outbound.protection.outlook.com ([104.47.42.114]:27280 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754530AbdA3Vnn (ORCPT ); Mon, 30 Jan 2017 16:43:43 -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=gTiKuh5Y7AGe+XpbYSZ4pQ+BUeQJgxEMyaKyCI0Q9p0=; b=PbnuQ9daUwEk11TlwHX1UTR8qMqXuwe57KbCPAkbIil3eZeUkJDx9/x0ywjiG/KaBBiEMT1seOVf7x8tVbiPi7j+nd99QkSidTPQ0bABT69kkti6cdbTShZ20w57ELzHiUpQPstNRF21hzj4uh6KhO69Y5ll/HwNILUbKL0clHE= 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:41:09 +0000 From: Pavel Shilovsky To: Subject: [PATCH v2 12/15] CIFS: Add copy into pages callback for a read operation Date: Mon, 30 Jan 2017 13:39:41 -0800 Message-ID: <1485812384-28870-13-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: ed713064-125d-4f3e-7e13-08d44958b438 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN6PR03MB2545; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2545; 3:JovJO8yD2TLBc5QJWDRwr6pVm6EgUWIcK3xYJ8yCHjApnYwhoLX72D9sBaHNEeJbCMMvGSG6Y8JCs0Hv/ep6XP9Axx3x2zkuvrDJr/m1eRdWb6Q9T5k4Vm8hMWYDpnwl58+is29RvKAFWmdumUDKCOZI9xfe+a+cVcYOb+7Ix55Z/8pZ9kbggmByxremrJR12fusVk7FGvX4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lkslbKipEsBsZzhf259P9ckjmzSmmw1HSkZKUa9jNNqiJKfhbGreCBw3KdOnJ7R8EljRWdD2DM3hoB02pUZEfVhkS8sY138QE56PWFN9NJhLQ==; 20:Z8/mq9wwiyht2iqBiZgSTmCH2MjXkRutphDjlYE4f3SU74k9z6eyWfBy0oUMtH3SMe2dl10LQf1Mm+uk15+SvHQC2tCRPiaFSog4HcgcjArg3BHklnT1vRxzSjvhlkrvZXI/NAmzYOIR4SODgWTES1ePLBtC8bFTrx8UVPERo75o7aE03o2OHwkLyaSf5YaufeEcxZU4kwYg3rPMICyJLkM7nHTexE3L3v9hdMhVo8otNgKgCe/CKtjcaPcCJygJdhJTiWh59ZvOYCt974L0EmayAbCFAmmcwVdF+1dTnOdEDz6B6D1MywXynjpji6NuiLNHm3+7J+z+OZjkFja7i1kuPDblFYJbKgrSnZgB9Tt3pm3fFVdY83vLRIec5Csa+qdS1Iz0SA5pJ/k6DMKyfFjV4Xwx+586tAD0mvK+z7WIO27eZlCC6569hHz4SZs4UIf5lF0o3dimp3ktNul4Pn6JPiNNNA8oFxGfyEPh60rf7G2+Be3UN1jZY3DNFGLk 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)(20161123555025)(20161123564025)(20161123562025)(20161123560025)(6072148)(6047074); SRVR:BN6PR03MB2545; BCL:0; PCL:0; RULEID:; SRVR:BN6PR03MB2545; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2545; 4:bf/FBDSSqOmPLajdnkmeC/67yS6guPBblFWTReet3cLKTIJEyJGA7Fd/utbwBKEcj5K6Y+CH7SjCGr7SKTtUOJJsiLRORPeiVLlHdk3ATtDQ6rxM/Kgj9r30jWvdkPP0ZKcNIMsXHJqqwG1rTl/N0Rf6hkJQFn8N5MEpT0A6xPEPZCowonsau0aqMeEG8pvasE+yjw80pEM4Ji/C2Lgcc81+ltHR0E7BMi7MdIqX79y2hKaTsU/V5J/X0RkSnRKbh9wSeLf7igykAz9xnvMb1+ATM+znGd0X1Eeo9x3MqWFFaDkgtnP3ErS9YBgMt2H3S5IZsyReyB/Ua5yra0hPM9HoWXoGrRNXTpRG/6XOPtfLcHCUP+BxV2Kj3xOPbMlHJbwpv/kp/6mMithB2VNDOgrRjLN/sDYt6pptcYGTqBtk0E6XhMVPrLpCUoxfQhiX1vSBU4aCLJOoUb9ckZ+t1tlRXh/5BRFcncpovb7eSmbu4HDOLTC/Ed24yx+x5APofx3uyn57V8BQ5DvRiSksEKPWSfxWLKUs9IWwr5JBN7LweUMg8Xun05Xs8RLXS1TcaHk84AkQG1qeciq6sJg4bDS9Emags6+fPks8SR4cTwk= X-Forefront-PRVS: 0203C93D51 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(39850400002)(39860400002)(39840400002)(39450400003)(39410400002)(189002)(199003)(305945005)(5660300001)(8676002)(81166006)(5003940100001)(6116002)(50466002)(48376002)(81156014)(53936002)(101416001)(42186005)(110136003)(7736002)(10290500002)(47776003)(5005710100001)(10090500001)(33646002)(36756003)(92566002)(2351001)(6486002)(2950100002)(50226002)(105586002)(76176999)(189998001)(50986999)(106356001)(86362001)(38730400001)(86612001)(25786008)(6916009)(6666003)(2906002)(450100001)(107886002)(68736007)(97736004); 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:rrowRI1xyWJCz8izr4/V3Pl3jSCTgLqxajfZRS4B7?= =?us-ascii?Q?r47QT88aLL8OzdkSt6c5jL254ReO3cIHouLsv2O0ds1h2Lk3S675uLeAWsSU?= =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6CeNvxyC3boz2R4KUQKBImhCXx1xY47pJPWpyeYsr6hDUURvH7CMvJ74pCo6/u8KPDOy1w= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2545; 7:bGakTSHNqZTWyUvHdoR0oCrqjQolI6r+DhlNCAbX2C0+bA/mBj4DzZC7pLKJaCnM6nn9u4mqAu4zRqsAWDcHPdW1nfWV24sHJXtohoVNhlBIWUmW8bB+F2vAGiXYrc08u3YA6mGeT2/CBaQgfI6O4mXB6WWtisykKfqxbZx37IGDBiSA63hNDdP0aDCBwnNQiGHOq+k4mTTjDsZHa4h/+VUVxpj3/dlqer8dTepYyxoQXuo+msHfsTFqB9VH5u/V5iOQWeKK+zFAeJLAAWI2C2wqEBeRSJL7nF2wgCfkx4O/hp9R6Lx7pVA3JS2k8HZfVQx6P3g0S974goMOhXXN3UgKvdmdx5t0ra+EYLzrakTEIGxRKDv5Ai3dx4K/roHCSCi0u7QNAgP7wwls9A8Q8h4Bu0AE0DthHyHcTZYMeVSOusNXag1nzydw9XfhuCYIyomtIuXRsbIZb3ze2d8i4A== X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2017 21:41:09.3341 (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 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 7e23261..d7c5a2c 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2910,8 +2910,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; @@ -2940,7 +2941,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; @@ -2952,6 +2956,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) { @@ -2998,6 +3017,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 || @@ -3348,8 +3368,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; @@ -3403,7 +3424,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; @@ -3415,6 +3439,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) @@ -3568,6 +3607,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) {