From patchwork Fri Jun 27 09:57:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 4434401 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 658629F2C8 for ; Fri, 27 Jun 2014 09:58:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 52AC8201EF for ; Fri, 27 Jun 2014 09:58:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4981220221 for ; Fri, 27 Jun 2014 09:58:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753311AbaF0J63 (ORCPT ); Fri, 27 Jun 2014 05:58:29 -0400 Received: from mail-la0-f43.google.com ([209.85.215.43]:40472 "EHLO mail-la0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751598AbaF0J63 (ORCPT ); Fri, 27 Jun 2014 05:58:29 -0400 Received: by mail-la0-f43.google.com with SMTP id e16so2765965lan.2 for ; Fri, 27 Jun 2014 02:58:28 -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=51qBRE+m8LCsmHS6x/y0wfzKCg9Yj0N3044Uoi08drQ=; b=UzeXeV5ALRSZ9NYOk137p5eb8sZHtP4HnuiG6jd+a0jcth7uS5FNSZoMj47pq7+3IA 6M3jXj0nJMahQmMb3cZyqUjkVZKdz785+r48LytMniqFzGhWqCtINe5VvItqShkeX729 AyhgmBZMBRmjBo4hBcHhPmMY4V3tfSiPmOqmpa3EnjbjPT//tHh4WQq9KJA/1zAtEPuu FTINVKqUVNrMDSCOKNjiw7CWqP0Em+fU78URBVZLEqTZXQ7nkwqFk3HRXSFGW58dJd3v Twm6oKLILI2PUS4kK6+/2dmdL4kZPvTQs1oaLd8DeIWHf0rupXhzy8Sn2saT6p0an+B0 u3zQ== X-Received: by 10.152.4.227 with SMTP id n3mr15748156lan.16.1403863108154; Fri, 27 Jun 2014 02:58:28 -0700 (PDT) Received: from localhost.localdomain ([92.43.3.6]) by mx.google.com with ESMTPSA id y8sm10969918lbr.18.2014.06.27.02.58.26 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Jun 2014 02:58:27 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH v2 14/16] CIFS: Fix rsize usage in user read Date: Fri, 27 Jun 2014 13:57:51 +0400 Message-Id: <1403863073-19526-15-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 (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 --- 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 6b5b95a..021adf6 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2827,26 +2827,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 @@ -2940,6 +2920,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; @@ -2970,11 +2953,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; } @@ -3022,8 +3009,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); @@ -3033,7 +3020,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 {