From patchwork Fri Jun 27 09:57:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 4434411 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 D43A2BEEAA for ; Fri, 27 Jun 2014 09:58:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0578920221 for ; Fri, 27 Jun 2014 09:58:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 158272026D for ; Fri, 27 Jun 2014 09:58:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753312AbaF0J6b (ORCPT ); Fri, 27 Jun 2014 05:58:31 -0400 Received: from mail-la0-f48.google.com ([209.85.215.48]:41140 "EHLO mail-la0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751598AbaF0J6b (ORCPT ); Fri, 27 Jun 2014 05:58:31 -0400 Received: by mail-la0-f48.google.com with SMTP id el20so2731887lab.21 for ; Fri, 27 Jun 2014 02:58:30 -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=jGnOWWlvilPqQ4x+D6bGKAPhQgIkYQc0bviU9DGfJ0w=; b=D6W9kVExvX/jJ1hcpx8Ps/lsrrR11Fm5Orh1sRjnMcLAWHzIC5u2Gopyhd5FrPyWo/ YFQanKmZn/NVbvUrdt21Io8lqETHdjRo49Ur/W8eWznw3Dc6qv3xVUfqr2vJHDdvIKKk zl+2tzTH1oun63WK/lZgJuGuyNfgK2cdHjCbzFWCBG8Ce+nCsV5nWkyoWQRiYE35t+qL wWLzsBJVPJA2r4+Abmg71O6XR3pO4tKIWbT/kNrBlMtYKeU1mLbgTKgFkRkwi2WCKD45 rq4rjU2qnW41CHRp9L8cvcFctMupBKPZnAEd7ufA5nWEjeyIWcdeP1DWWx+FbsN+1kof AxsA== X-Received: by 10.152.21.98 with SMTP id u2mr793992lae.79.1403863109929; Fri, 27 Jun 2014 02:58:29 -0700 (PDT) Received: from localhost.localdomain ([92.43.3.6]) by mx.google.com with ESMTPSA id y8sm10969918lbr.18.2014.06.27.02.58.28 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Jun 2014 02:58:28 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH v2 15/16] CIFS: Fix rsize usage for sync read Date: Fri, 27 Jun 2014 13:57:52 +0400 Message-Id: <1403863073-19526-16-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 changes maximum buffer size for read requests (rsize) on reconnect we can fail on repeating with a big size buffer on -EAGAIN error in cifs_read. Fix this by checking rsize all the time before repeating requests. Signed-off-by: Pavel Shilovsky --- fs/cifs/file.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 021adf6..36fd042 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -3147,18 +3147,19 @@ cifs_read(struct file *file, char *read_data, size_t read_size, loff_t *offset) for (total_read = 0, cur_offset = read_data; read_size > total_read; total_read += bytes_read, cur_offset += bytes_read) { - current_read_size = min_t(uint, read_size - total_read, rsize); - /* - * For windows me and 9x we do not want to request more than it - * negotiated since it will refuse the read then. - */ - if ((tcon->ses) && !(tcon->ses->capabilities & + do { + current_read_size = min_t(uint, read_size - total_read, + rsize); + /* + * For windows me and 9x we do not want to request more + * than it negotiated since it will refuse the read + * then. + */ + if ((tcon->ses) && !(tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files)) { - current_read_size = min_t(uint, current_read_size, - CIFSMaxBufSize); - } - rc = -EAGAIN; - while (rc == -EAGAIN) { + current_read_size = min_t(uint, + current_read_size, CIFSMaxBufSize); + } if (open_file->invalidHandle) { rc = cifs_reopen_file(open_file, true); if (rc != 0) @@ -3171,7 +3172,8 @@ cifs_read(struct file *file, char *read_data, size_t read_size, loff_t *offset) rc = server->ops->sync_read(xid, open_file, &io_parms, &bytes_read, &cur_offset, &buf_type); - } + } while (rc == -EAGAIN); + if (rc || (bytes_read == 0)) { if (total_read) { break;