From patchwork Mon Jul 21 15:45:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 4597121 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 6BA559F2B8 for ; Mon, 21 Jul 2014 15:46:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8E7BD200E9 for ; Mon, 21 Jul 2014 15:46:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B37A5200DE for ; Mon, 21 Jul 2014 15:46:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932832AbaGUPqn (ORCPT ); Mon, 21 Jul 2014 11:46:43 -0400 Received: from mail-la0-f44.google.com ([209.85.215.44]:50399 "EHLO mail-la0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932873AbaGUPqm (ORCPT ); Mon, 21 Jul 2014 11:46:42 -0400 Received: by mail-la0-f44.google.com with SMTP id e16so4921033lan.17 for ; Mon, 21 Jul 2014 08:46:41 -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=MsVpUaBXfvNxMrw4LIdPXeqrIJdPrNHwUpaTFXWzj2Y=; b=F2X1rQ5ymOamdFuUiAYZ6FI6fhH1lL3ufP8KJ7ypULI54oS+p6o8XsJ9hy2rybAifV E2YBCSflrO5UOVCl3Eu41dGPZ3bhOBrH4YOER75YFliMHoyBab9k396zfkgHSm+UjMER rw/DxSckXwMMVnYqa429tiMkfRTXIdGvz/1Xa2mqarFlPcoQSXpmzFoQWxnIo/ysLEuA zGfG7B5PWAhHHscZWtdti6N69NkI18frv0tvVP/ip0/UrWgkiKw7Cc2CivAlKoJRKIIc fE8vQDYxjgqzjaWGpVJ1tXqtgrwU4SetRmceCDEoiQirwx7i22yxx4+GBAwAKcT8U7EA xPow== X-Received: by 10.152.8.109 with SMTP id q13mr27515251laa.31.1405957601503; Mon, 21 Jul 2014 08:46:41 -0700 (PDT) Received: from localhost.localdomain ([92.43.3.35]) by mx.google.com with ESMTPSA id ok1sm25762485lbc.18.2014.07.21.08.46.39 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jul 2014 08:46:40 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH v3 14/16] CIFS: Fix rsize usage in user read Date: Mon, 21 Jul 2014 19:45:56 +0400 Message-Id: <1405957558-18476-15-git-send-email-pshilovsky@samba.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1405957558-18476-1-git-send-email-pshilovsky@samba.org> References: <1405957558-18476-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 If a server changes maximum buffer size for read (rsize) requests on reconnect we can fail on repeating with a big size buffer on -EAGAIN error in user read. Fix this by checking rsize all the time before repeating requests. Signed-off-by: Pavel Shilovsky Reviewed-by: Shirish Pargaonkar --- fs/cifs/file.c | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 7df4e46..bbc3859 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2828,26 +2828,6 @@ cifs_uncached_readdata_release(struct kref *refcount) cifs_readdata_release(refcount); } -static int -cifs_retry_async_readv(struct cifs_readdata *rdata) -{ - int rc; - struct TCP_Server_Info *server; - - server = tlink_tcon(rdata->cfile->tlink)->ses->server; - - do { - if (rdata->cfile->invalidHandle) { - rc = cifs_reopen_file(rdata->cfile, true); - if (rc != 0) - continue; - } - rc = server->ops->async_readv(rdata); - } while (rc == -EAGAIN); - - return rc; -} - /** * cifs_readdata_to_iov - copy data from pages in response to an iovec * @rdata: the readdata response with list of pages holding data @@ -2941,6 +2921,9 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, size_t cur_len; int rc; pid_t pid; + struct TCP_Server_Info *server; + + server = tlink_tcon(open_file->tlink)->ses->server; if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) pid = open_file->pid; @@ -2971,11 +2954,15 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, rdata->pagesz = PAGE_SIZE; rdata->read_into_pages = cifs_uncached_read_into_pages; - rc = cifs_retry_async_readv(rdata); + if (!rdata->cfile->invalidHandle || + !cifs_reopen_file(rdata->cfile, true)) + rc = server->ops->async_readv(rdata); error: if (rc) { kref_put(&rdata->refcount, cifs_uncached_readdata_release); + if (rc == -EAGAIN) + continue; break; } @@ -3023,8 +3010,8 @@ ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to) len = iov_iter_count(to); /* the loop below should proceed in the order of increasing offsets */ +again: list_for_each_entry_safe(rdata, tmp, &rdata_list, list) { - again: if (!rc) { /* FIXME: freezable sleep too? */ rc = wait_for_completion_killable(&rdata->done); @@ -3034,7 +3021,19 @@ ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to) rc = rdata->result; /* resend call if it's a retryable error */ if (rc == -EAGAIN) { - rc = cifs_retry_async_readv(rdata); + struct list_head tmp_list; + + 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); + + list_splice(&tmp_list, &rdata_list); + + kref_put(&rdata->refcount, + cifs_uncached_readdata_release); goto again; } } else {