From patchwork Mon Jul 14 09:01:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 4543621 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0B3FB9F1D6 for ; Mon, 14 Jul 2014 09:01:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 174FD2010E for ; Mon, 14 Jul 2014 09:01:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 06BFB2010F for ; Mon, 14 Jul 2014 09:01:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751411AbaGNJBh (ORCPT ); Mon, 14 Jul 2014 05:01:37 -0400 Received: from mail-la0-f44.google.com ([209.85.215.44]:43116 "EHLO mail-la0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751143AbaGNJBg (ORCPT ); Mon, 14 Jul 2014 05:01:36 -0400 Received: by mail-la0-f44.google.com with SMTP id e16so1115766lan.3 for ; Mon, 14 Jul 2014 02:01:35 -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=bzdNkK15WJlu+T074VDoEVpPYA3XUH+oz4zHFROqEyk=; b=OAizkghB3pDvpAjVTnkjcvWk/Doq0xMRrmALZF0ffVq4RYkOWZ4pcObciUR1YOrQTR QUMVKZw8r+MyHsuqtFc0RooDqSZE13ZWsWi4krDc22aoFETOgFBZSYS3a4aXGXdVwgAa reSv9ltHyEocgKoFKheQYGbPO+eke+4Ln784dWvQ+X+FgUWA1VcMz/fJitTnj0q4NNM2 Qc/Ow6H415mfWe7NuxbzbLnG0XEgwJ19XPyXtEwr4XGq1apFC0vAAHoeN1vUyq8JrEoz He87tPoGbBvnDrFjpvMvbvUJT15n10FetLS8RkSxJhuJs4pchfdkzvLwMfRpwPIGfUsI urYw== X-Received: by 10.152.20.38 with SMTP id k6mr157845lae.10.1405328495080; Mon, 14 Jul 2014 02:01:35 -0700 (PDT) Received: from localhost.localdomain ([92.43.3.85]) by mx.google.com with ESMTPSA id r2sm5063434lag.27.2014.07.14.02.01.33 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 14 Jul 2014 02:01:34 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH v2 6/7] CIFS: Optimize cifs_user_read() in a short read case on reconnects Date: Mon, 14 Jul 2014 13:01:16 +0400 Message-Id: <1405328477-13484-7-git-send-email-pshilovsky@samba.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1405328477-13484-1-git-send-email-pshilovsky@samba.org> References: <1405328477-13484-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,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. This is suitable for non-signed connections. Signed-off-by: Pavel Shilovsky --- fs/cifs/cifssmb.c | 6 ++++++ fs/cifs/file.c | 23 ++++++++++++++++++++--- fs/cifs/smb2pdu.c | 6 ++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 5d6768f..2f7b43a 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1561,6 +1561,12 @@ cifs_readv_callback(struct mid_q_entry *mid) case MID_REQUEST_SUBMITTED: case MID_RETRY_NEEDED: rdata->result = -EAGAIN; + if (server->sign && rdata->got_bytes) + /* reset bytes number since we can not check a sign */ + rdata->got_bytes = 0; + /* FIXME: should this be counted toward the initiating task? */ + task_io_account_read(rdata->got_bytes); + cifs_stats_bytes_read(tcon, rdata->got_bytes); break; default: rdata->result = -EIO; diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 6896cb5..e42d26d 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 -- fill the buffer and continue + * reading. + */ + 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); diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 0aabd7c..9b38cd7 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -1740,6 +1740,12 @@ smb2_readv_callback(struct mid_q_entry *mid) case MID_REQUEST_SUBMITTED: case MID_RETRY_NEEDED: rdata->result = -EAGAIN; + if (server->sign && rdata->got_bytes) + /* reset bytes number since we can not check a sign */ + rdata->got_bytes = 0; + /* FIXME: should this be counted toward the initiating task? */ + task_io_account_read(rdata->got_bytes); + cifs_stats_bytes_read(tcon, rdata->got_bytes); break; default: if (rdata->result != -ENODATA)