From patchwork Thu Jul 10 09:30:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 4522431 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 8AC79BEEAA for ; Thu, 10 Jul 2014 09:31:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9B1F2021B for ; Thu, 10 Jul 2014 09:31:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE27820200 for ; Thu, 10 Jul 2014 09:31:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752802AbaGJJbI (ORCPT ); Thu, 10 Jul 2014 05:31:08 -0400 Received: from mail-la0-f54.google.com ([209.85.215.54]:48274 "EHLO mail-la0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752423AbaGJJbH (ORCPT ); Thu, 10 Jul 2014 05:31:07 -0400 Received: by mail-la0-f54.google.com with SMTP id mc6so5978558lab.27 for ; Thu, 10 Jul 2014 02:31:06 -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=mRrcc1ts8pps+G0ezaZDrq88+469PzaLJvPLJY8TtDI=; b=IDhSGKJXGv9i02dnhE0KlHB72bQo9lrHAykJ34V49Fd+vVXp86nHOziskl9H18EeGh xjoq+Lki2BGGt12L0GN1/slOWkrH1P5M2U12s43SiIBLaPIdo0XsWrqwnHWFYVWGQa7O sgsczjclLwcbK5pj4VFKMZWUA1O3yHFZlIghgYuoS48aw5gbwpF0SfJ2HqKjpruJnzfV Z26ybMtxR/DnwobplO+Y9ODJDBVyjHQ6ofodvw73oJ4hkq8nlg7uj1Z1YaPGtqOcuGuA DYZ25qQpl5NKviPdmqf3uHzrqBh3IHBWwFcTkAXx7CHztLNf44WfqdmbtI9un7N4/DVq +Ecg== X-Received: by 10.112.17.102 with SMTP id n6mr3391501lbd.39.1404984666401; Thu, 10 Jul 2014 02:31:06 -0700 (PDT) Received: from localhost.localdomain ([92.43.3.36]) by mx.google.com with ESMTPSA id v6sm23257226lal.35.2014.07.10.02.31.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Jul 2014 02:31:05 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 6/7] CIFS: Optimize cifs_user_read() in a short read case on reconnects Date: Thu, 10 Jul 2014 13:30:46 +0400 Message-Id: <1404984647-8710-7-git-send-email-pshilovsky@samba.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1404984647-8710-1-git-send-email-pshilovsky@samba.org> References: <1404984647-8710-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=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 by filling the output buffer with a data got from a partially received response and requesting the remaining data from the server. Signed-off-by: Pavel Shilovsky --- fs/cifs/file.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 6896cb5..d7246cb 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -3029,13 +3029,30 @@ again: else if (rdata->result == -EAGAIN) { /* resend call if it's a retryable error */ struct list_head tmp_list; + unsigned int got_bytes = rdata->got_bytes; list_del_init(&rdata->list); INIT_LIST_HEAD(&tmp_list); - rc = cifs_send_async_read(rdata->offset, - rdata->bytes, rdata->cfile, - cifs_sb, &tmp_list); + /* + * Got a part of data and then reconnect has + * happened -- discard anything left and return + * a short read. + */ + if (got_bytes && got_bytes < rdata->bytes) { + rc = cifs_readdata_to_iov(rdata, to); + if (rc) { + kref_put(&rdata->refcount, + cifs_uncached_readdata_release); + continue; + } + } + + rc = cifs_send_async_read( + rdata->offset + got_bytes, + rdata->bytes - got_bytes, + rdata->cfile, cifs_sb, + &tmp_list); list_splice(&tmp_list, &rdata_list);