From patchwork Fri Jun 27 09:57:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 4434311 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 E5066BEEAA for ; Fri, 27 Jun 2014 09:58:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC827201EF for ; Fri, 27 Jun 2014 09:58:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D71EC2026D for ; Fri, 27 Jun 2014 09:58:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752869AbaF0J6N (ORCPT ); Fri, 27 Jun 2014 05:58:13 -0400 Received: from mail-la0-f54.google.com ([209.85.215.54]:62170 "EHLO mail-la0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753284AbaF0J6N (ORCPT ); Fri, 27 Jun 2014 05:58:13 -0400 Received: by mail-la0-f54.google.com with SMTP id mc6so2724770lab.41 for ; Fri, 27 Jun 2014 02:58:11 -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=aYL6bh8/a3Od4n6Y/SGPynIuz2muzAKzfesHNjAbKvA=; b=pvDEWoIlhxet8/vzcumQ7fGBq8kXOI9kLeEepBbKAXu+VduslstThWv0Tq3BqfaTtZ 6shO1xc4/f2RHGUEctC3/Z9b8BCOZ2TIz5mqLBBjMkzUXz5STfMZLrmZvGsFi+xm1I0l sDOgN5VdicFvw2xT8YysbgCYHLiraSikFmzezq8wIGNMmAZafIy1P9CHEKrST9kIniPE a8peevFmRZVidzw66/MEUwn2STkfRnubLnkk8RWTlbtMC0hR7iDFAPR4N9xPg9/OHMYS u1npl74UrXUewmmFBmHUPB7VwrWRCm8Ej8EEeWCYOgvoTGJ0W1+Vrkh/QaoviCjLU8op hbbA== X-Received: by 10.112.217.10 with SMTP id ou10mr15206596lbc.20.1403863091569; Fri, 27 Jun 2014 02:58:11 -0700 (PDT) Received: from localhost.localdomain ([92.43.3.6]) by mx.google.com with ESMTPSA id y8sm10969918lbr.18.2014.06.27.02.58.09 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Jun 2014 02:58:10 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH v2 05/16] CIFS: Fix wsize usage in writepages Date: Fri, 27 Jun 2014 13:57:42 +0400 Message-Id: <1403863073-19526-6-git-send-email-pshilovsky@samba.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1403863073-19526-1-git-send-email-pshilovsky@samba.org> References: <1403863073-19526-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 If a server change maximum buffer size for write (wsize) requests on reconnect we can fail on repeating with a big size buffer on -EAGAIN error in writepages. Fix this by checking wsize all the time before repeating request in writepages. Signed-off-by: Pavel Shilovsky --- fs/cifs/file.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 4117da0..21f9be0 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2009,19 +2009,17 @@ wdata_send_pages(struct cifs_writedata *wdata, unsigned int nr_pages, (loff_t)PAGE_CACHE_SIZE); wdata->bytes = ((nr_pages - 1) * PAGE_CACHE_SIZE) + wdata->tailsz; - do { - if (wdata->cfile != NULL) - cifsFileInfo_put(wdata->cfile); - wdata->cfile = find_writable_file(CIFS_I(mapping->host), false); - if (!wdata->cfile) { - cifs_dbg(VFS, "No writable handles for inode\n"); - rc = -EBADF; - break; - } + if (wdata->cfile != NULL) + cifsFileInfo_put(wdata->cfile); + wdata->cfile = find_writable_file(CIFS_I(mapping->host), false); + if (!wdata->cfile) { + cifs_dbg(VFS, "No writable handles for inode\n"); + rc = -EBADF; + } else { wdata->pid = wdata->cfile->pid; server = tlink_tcon(wdata->cfile->tlink)->ses->server; rc = server->ops->async_writev(wdata, cifs_writedata_release); - } while (wbc->sync_mode == WB_SYNC_ALL && rc == -EAGAIN); + } for (i = 0; i < nr_pages; ++i) unlock_page(wdata->pages[i]); @@ -2073,7 +2071,7 @@ static int cifs_writepages(struct address_space *mapping, retry: while (!done && index <= end) { unsigned int nr_pages, found_pages; - pgoff_t next = 0, tofind; + pgoff_t next = 0, tofind, saved_index = index; tofind = min((cifs_sb->wsize / PAGE_CACHE_SIZE) - 1, end - index) + 1; @@ -2102,6 +2100,11 @@ retry: rc = wdata_send_pages(wdata, nr_pages, mapping, wbc); kref_put(&wdata->refcount, cifs_writedata_release); + if (wbc->sync_mode == WB_SYNC_ALL && rc == -EAGAIN) { + index = saved_index; + continue; + } + wbc->nr_to_write -= nr_pages; if (wbc->nr_to_write <= 0) done = true;