From patchwork Fri Jun 27 09:57:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 4434391 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 91F72BEEAA for ; Fri, 27 Jun 2014 09:58:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A0A53201EF for ; Fri, 27 Jun 2014 09:58:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BA4AD2026D for ; Fri, 27 Jun 2014 09:58:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753308AbaF0J62 (ORCPT ); Fri, 27 Jun 2014 05:58:28 -0400 Received: from mail-la0-f45.google.com ([209.85.215.45]:56534 "EHLO mail-la0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751598AbaF0J61 (ORCPT ); Fri, 27 Jun 2014 05:58:27 -0400 Received: by mail-la0-f45.google.com with SMTP id hr17so2817419lab.32 for ; Fri, 27 Jun 2014 02:58:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=d/ZUKvUdf1SAhcoYVqSChHrBDb5KCe+vXi4h6TfBTLA=; b=ps7IqNZzsuJshjIBb176yxnfo2f3tnZV3J17HDMViz3IlXLhczS3Mf3SAUG+TDfQzB jEvmxgx+l0Aj6gSrqxzUKci/szbNv2zCD9vVKRa4WBOFMtFWXAYjFRmaICyBWIfrWVSU O//0QlSCe5yR2xmQKLJyuELnfN9tW5Xzf4Z/3L1YBaa1EWNFKGMNOSvVg+BE5SzUPMz2 +qHDLNP8jEfIM6+fXMbInyIt24WxN1e+wP7WncMf3TsybeTIY5scuRQypC0hb1ttNfCD 1ZcM785/WC+OrRNtS6fbaHlcB9C3pkDx69/7zBMtD4jCTdlG8Qf7B/yY5QSsCeLsUwjq lS2Q== X-Received: by 10.152.5.4 with SMTP id o4mr1218678lao.64.1403863106469; Fri, 27 Jun 2014 02:58:26 -0700 (PDT) Received: from localhost.localdomain ([92.43.3.6]) by mx.google.com with ESMTPSA id y8sm10969918lbr.18.2014.06.27.02.58.24 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Jun 2014 02:58:25 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH v2 13/16] CIFS: Separate page reading from user read Date: Fri, 27 Jun 2014 13:57:50 +0400 Message-Id: <1403863073-19526-14-git-send-email-pshilovsky@samba.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1403863073-19526-1-git-send-email-pshilovsky@samba.org> References: <1403863073-19526-1-git-send-email-pshilovsky@samba.org> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Pavel Shilovsky --- fs/cifs/file.c | 69 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 5f3fa33..6b5b95a 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2931,43 +2931,23 @@ cifs_uncached_read_into_pages(struct TCP_Server_Info *server, return total_read > 0 && result != -EAGAIN ? total_read : result; } -ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to) +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) { - struct file *file = iocb->ki_filp; - ssize_t rc; - size_t len, cur_len; - ssize_t total_read = 0; - loff_t offset = iocb->ki_pos; + struct cifs_readdata *rdata; unsigned int npages; - struct cifs_sb_info *cifs_sb; - struct cifs_tcon *tcon; - struct cifsFileInfo *open_file; - struct cifs_readdata *rdata, *tmp; - struct list_head rdata_list; + size_t cur_len; + int rc; pid_t pid; - len = iov_iter_count(to); - if (!len) - return 0; - - INIT_LIST_HEAD(&rdata_list); - cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); - open_file = file->private_data; - tcon = tlink_tcon(open_file->tlink); - - if (!tcon->ses->server->ops->async_readv) - return -ENOSYS; - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) pid = open_file->pid; else pid = current->tgid; - if ((file->f_flags & O_ACCMODE) == O_WRONLY) - cifs_dbg(FYI, "attempting read on write only file instance\n"); - do { - cur_len = min_t(const size_t, len - total_read, cifs_sb->rsize); + cur_len = min_t(const size_t, len, cifs_sb->rsize); npages = DIV_ROUND_UP(cur_len, PAGE_SIZE); /* allocate a readdata struct */ @@ -2998,11 +2978,44 @@ error: break; } - list_add_tail(&rdata->list, &rdata_list); + list_add_tail(&rdata->list, rdata_list); offset += cur_len; len -= cur_len; } while (len > 0); + return rc; +} + +ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to) +{ + struct file *file = iocb->ki_filp; + ssize_t rc; + size_t len; + ssize_t total_read = 0; + loff_t offset = iocb->ki_pos; + struct cifs_sb_info *cifs_sb; + struct cifs_tcon *tcon; + struct cifsFileInfo *open_file; + struct cifs_readdata *rdata, *tmp; + struct list_head rdata_list; + + len = iov_iter_count(to); + if (!len) + return 0; + + INIT_LIST_HEAD(&rdata_list); + cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); + open_file = file->private_data; + tcon = tlink_tcon(open_file->tlink); + + if (!tcon->ses->server->ops->async_readv) + return -ENOSYS; + + if ((file->f_flags & O_ACCMODE) == O_WRONLY) + cifs_dbg(FYI, "attempting read on write only file instance\n"); + + rc = cifs_send_async_read(offset, len, open_file, cifs_sb, &rdata_list); + /* if at least one read request send succeeded, then reset rc */ if (!list_empty(&rdata_list)) rc = 0;