From patchwork Mon Jun 23 14:58:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 4403631 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 35FE6BEEAA for ; Mon, 23 Jun 2014 14:59:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 427672018B for ; Mon, 23 Jun 2014 14:59:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 410052026C for ; Mon, 23 Jun 2014 14:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755856AbaFWO7E (ORCPT ); Mon, 23 Jun 2014 10:59:04 -0400 Received: from mail-lb0-f171.google.com ([209.85.217.171]:48749 "EHLO mail-lb0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755850AbaFWO7C (ORCPT ); Mon, 23 Jun 2014 10:59:02 -0400 Received: by mail-lb0-f171.google.com with SMTP id s7so4754930lbd.30 for ; Mon, 23 Jun 2014 07:59:01 -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=BN5H4tzhXihi9nCkpVp77rBRMaYcJbSZzlgUGF32agk=; b=gh69zhrAFSrmj4B65+BLPCS4/+ec6jGif9M2+2t/ca5KaNjHBLfOZB5PatiNoTDtXb 13H1XwrQ8Dhix5D7Mtr19bm55owTAAhNh7WgAnPuKNS5OXoR3YN7CLiVm6e9c/VFzTuO tr6w9si6XEeFlC0sI9pqhPBfGX+9LEQky8RNd7vcb3KQw31VoI/fG7g2g8VDwfge5pvj Dp3yf7V3HeQeZpk/mJTSzxs7mXso7myxt6uiHhz89XlHUjT83UyO4qs6sMoeNdqf7E2c S+MWyui+rq9FJWRkCH73PsXCL85G3f4VrYqE8bIybmPfpHZBsJUCgQc7QuRZ6xTw6z5p 1qaQ== X-Received: by 10.153.7.74 with SMTP id da10mr8910247lad.27.1403535541297; Mon, 23 Jun 2014 07:59:01 -0700 (PDT) Received: from localhost.localdomain ([92.43.3.32]) by mx.google.com with ESMTPSA id fb6sm7964060lac.40.2014.06.23.07.58.59 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 23 Jun 2014 07:59:00 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 7/9] CIFS: Separate writing from iovec write Date: Mon, 23 Jun 2014 18:58:35 +0400 Message-Id: <1403535517-8301-8-git-send-email-pshilovsky@samba.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1403535517-8301-1-git-send-email-pshilovsky@samba.org> References: <1403535517-8301-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 | 75 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 89d647b..887c18c 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2470,41 +2470,19 @@ wdata_fill_from_iovec(struct cifs_writedata *wdata, struct iov_iter *it, return rc; } -static ssize_t -cifs_iovec_write(struct file *file, const struct iovec *iov, - unsigned long nr_segs, loff_t *poffset) +static int +cifs_write_from_iovec(loff_t offset, size_t len, const struct iovec *iov, + unsigned long nr_segs, struct cifsFileInfo *open_file, + struct cifs_sb_info *cifs_sb, + struct list_head *wdata_list) { + int rc = 0; + size_t cur_len; unsigned long nr_pages, i; - size_t len, cur_len; - ssize_t total_written = 0; - loff_t offset; + struct cifs_writedata *wdata; struct iov_iter it; - struct cifsFileInfo *open_file; - struct cifs_tcon *tcon; - struct cifs_sb_info *cifs_sb; - struct cifs_writedata *wdata, *tmp; - struct list_head wdata_list; - int rc; pid_t pid; - len = iov_length(iov, nr_segs); - if (!len) - return 0; - - rc = generic_write_checks(file, poffset, &len, 0); - if (rc) - return rc; - - INIT_LIST_HEAD(&wdata_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_writev) - return -ENOSYS; - - offset = *poffset; - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) pid = open_file->pid; else @@ -2549,11 +2527,46 @@ cifs_iovec_write(struct file *file, const struct iovec *iov, break; } - list_add_tail(&wdata->list, &wdata_list); + list_add_tail(&wdata->list, wdata_list); offset += cur_len; len -= cur_len; } while (len > 0); + return rc; +} + +static ssize_t +cifs_iovec_write(struct file *file, const struct iovec *iov, + unsigned long nr_segs, loff_t *poffset) +{ + size_t len; + ssize_t total_written = 0; + struct cifsFileInfo *open_file; + struct cifs_tcon *tcon; + struct cifs_sb_info *cifs_sb; + struct cifs_writedata *wdata, *tmp; + struct list_head wdata_list; + int rc; + + len = iov_length(iov, nr_segs); + if (!len) + return 0; + + rc = generic_write_checks(file, poffset, &len, 0); + if (rc) + return rc; + + INIT_LIST_HEAD(&wdata_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_writev) + return -ENOSYS; + + rc = cifs_write_from_iovec(*poffset, len, iov, nr_segs, open_file, + cifs_sb, &wdata_list); + /* * If at least one write was successfully sent, then discard any rc * value from the later writes. If the other write succeeds, then