From patchwork Mon Jul 14 09:01:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 4543631 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 159A2C0514 for ; Mon, 14 Jul 2014 09:02:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 309BF2010E for ; Mon, 14 Jul 2014 09:01:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 175622011E for ; Mon, 14 Jul 2014 09:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753125AbaGNJBi (ORCPT ); Mon, 14 Jul 2014 05:01:38 -0400 Received: from mail-lb0-f180.google.com ([209.85.217.180]:43975 "EHLO mail-lb0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751143AbaGNJBi (ORCPT ); Mon, 14 Jul 2014 05:01:38 -0400 Received: by mail-lb0-f180.google.com with SMTP id w7so2526657lbi.25 for ; Mon, 14 Jul 2014 02:01:36 -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=HKRz8NYNZmc02e2rBnAX6MmxTA8n9VkuLeo8LIfYGdg=; b=PRiJapfwV2YpvvF7Yf6QJqsICV+dSFq44MXp2nmDUPOZAmstgPKN+Mq3SVY6BRcBBg T5F2o3LahDPeq4RixZ/FiqkHPKLYMqmD4borM93lD34n3gVr6f5hsYc3vH5UyOyp/hi2 UQOLWP0vQSd+meVhv67pKsRXG3VohgTs8TRi5UyNXW7bexf2+cDtgVnQjzhUEkydyJ+E u0v/Ytk7SK8IooAqEVovbzrbU+6OaoMTTT6p2hfQkRbWAvcGtPcKyIsWNgPLU6zD1bgH 3aLu+mLx4pNUZF3HMoLGfDw6Jxxdmx7UU63/jdNQ/r39fGnpj9zfMZ9E2ial1RP8lcyK mgwA== X-Received: by 10.112.180.70 with SMTP id dm6mr12776280lbc.32.1405328496727; Mon, 14 Jul 2014 02:01:36 -0700 (PDT) Received: from localhost.localdomain ([92.43.3.85]) by mx.google.com with ESMTPSA id r2sm5063434lag.27.2014.07.14.02.01.35 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 14 Jul 2014 02:01:35 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH v2 7/7] CIFS: Optimize readpages in a short read case on reconnects Date: Mon, 14 Jul 2014 13:01:17 +0400 Message-Id: <1405328477-13484-8-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 marking pages with a data from a partially received response up-to-date. This is suitable for non-signed connections. 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 e42d26d..4b83d72 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; }