From patchwork Thu Jul 10 09:30:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 4522441 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 7368B9F26C for ; Thu, 10 Jul 2014 09:31:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B2C862021B for ; Thu, 10 Jul 2014 09:31:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CFF6120200 for ; Thu, 10 Jul 2014 09:31:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752804AbaGJJbK (ORCPT ); Thu, 10 Jul 2014 05:31:10 -0400 Received: from mail-lb0-f173.google.com ([209.85.217.173]:48770 "EHLO mail-lb0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752423AbaGJJbJ (ORCPT ); Thu, 10 Jul 2014 05:31:09 -0400 Received: by mail-lb0-f173.google.com with SMTP id s7so5885347lbd.18 for ; Thu, 10 Jul 2014 02:31:08 -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=G1d8RdPfIVOhPsk5aiNjNoYZgo3ZOgktJHhBWBRGUiE=; b=eeF+1/cEHuxoEif0xn1datV7LYOnRvHubi2t0YaUQX6+Xjd/8af4vZg8thNQQaWm84 Kh8/e9QhAGTj3mrpE8cBJjrdmBO8Rv9wc2qcrCFbi4KsQYZoqNY9GHtQ93SFafprCGE2 OpsywQSK9DVrSZUb5M720Z022yQRjuowpoiqyM1QbYa9PEuSskf3vlsSti1h/yPYa1mY 1jmFC98PXaFx9+IuEofbEPWtxknHublxM99k3vrssyY+6kJgAa+YyoJzk/zcapc2ka6R rlJ1IwbU/BgtuahO6hOm9g2sZZEv/RQEjGCzfI69B6KUJjlo5ovgAqqzrxv3LcYGsROz nVrg== X-Received: by 10.112.211.163 with SMTP id nd3mr2952369lbc.53.1404984668165; Thu, 10 Jul 2014 02:31:08 -0700 (PDT) Received: from localhost.localdomain ([92.43.3.36]) by mx.google.com with ESMTPSA id v6sm23257226lal.35.2014.07.10.02.31.06 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Jul 2014 02:31:07 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 7/7] CIFS: Optimize readpages in a short read case on reconnects Date: Thu, 10 Jul 2014 13:30:47 +0400 Message-Id: <1404984647-8710-8-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 marking pages with a data from a partially received response up-to-date. Signed-off-by: Pavel Shilovsky --- fs/cifs/file.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index d7246cb..d225895 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -3280,25 +3280,30 @@ int cifs_file_mmap(struct file *file, struct vm_area_struct *vma) static void cifs_readv_complete(struct work_struct *work) { - unsigned int i; + unsigned int i, got_bytes; struct cifs_readdata *rdata = container_of(work, struct cifs_readdata, work); + got_bytes = rdata->got_bytes; for (i = 0; i < rdata->nr_pages; i++) { struct page *page = rdata->pages[i]; lru_cache_add_file(page); - if (rdata->result == 0) { + if (rdata->result == 0 || + (rdata->result == -EAGAIN && got_bytes)) { flush_dcache_page(page); SetPageUptodate(page); } unlock_page(page); - if (rdata->result == 0) + if (rdata->result == 0 || + (rdata->result == -EAGAIN && got_bytes)) cifs_readpage_to_fscache(rdata->mapping->host, page); + got_bytes -= min_t(unsigned int, PAGE_CACHE_SIZE, got_bytes); + page_cache_release(page); rdata->pages[i] = NULL; }