From patchwork Mon Jul 21 15:45:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 4596991 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 3CB4DC0514 for ; Mon, 21 Jul 2014 15:46:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6416C200E1 for ; Mon, 21 Jul 2014 15:46:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 872F8200DE for ; Mon, 21 Jul 2014 15:46:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932608AbaGUPqS (ORCPT ); Mon, 21 Jul 2014 11:46:18 -0400 Received: from mail-la0-f48.google.com ([209.85.215.48]:43379 "EHLO mail-la0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932481AbaGUPqR (ORCPT ); Mon, 21 Jul 2014 11:46:17 -0400 Received: by mail-la0-f48.google.com with SMTP id gl10so4854269lab.7 for ; Mon, 21 Jul 2014 08:46:15 -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=wNdbdIyz4kSVK9aJxpuhuYSE59IUZbGKj9KOxILqqzo=; b=0eNJA3PyJAASKWsQ4at+ybQk/a/CeRMZbfa3BCSDTXofHKIkPXFtMh+HLWsqIl63+H TqSbu1V1jKifLID70qPXA46nD+4p4NepCCuAq0WhWhx3Qz/emwiMEfdH82a2QzxocYnY Ayz6zZsaQxURDi7fgAe1MhNaMl3aXUidWbQeBUvbs1dumriy+Z9+tdklHVIvVPJVK1cR LmOPBqEPDB1L5CFATUoTLe0O232p+1W3vDOJFiL4khykqe47hRt3ehudwAUiA0CHvcyw dTkb+zTiSroL7/kknfwoXgt/IMmH3cvwk/kWZyOrNkVKjV4w0fUAfc1Xkz1Mz0Q7cqQa pvyQ== X-Received: by 10.152.180.36 with SMTP id dl4mr27576923lac.26.1405957575810; Mon, 21 Jul 2014 08:46:15 -0700 (PDT) Received: from localhost.localdomain ([92.43.3.35]) by mx.google.com with ESMTPSA id ok1sm25762485lbc.18.2014.07.21.08.46.13 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jul 2014 08:46:14 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH v3 01/16] CIFS: Fix async reading on reconnects Date: Mon, 21 Jul 2014 19:45:43 +0400 Message-Id: <1405957558-18476-2-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 we get into read_into_pages() from cifs_readv_receive() and then loose a network, we issue cifs_reconnect that moves all mids to a private list and issue their callbacks. The callback of the async read request sets a mid to retry, frees it and wakes up a process that waits on the rdata completion. After the connection is established we return from read_into_pages() with a short read, use the mid that was freed before and try to read the remaining data from the a newly created socket. Both actions are not what we want to do. In reconnect cases (-EAGAIN) we should not mask off the error with a short read but should return the error code instead. Acked-by: Jeff Layton Signed-off-by: Pavel Shilovsky --- fs/cifs/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index e90a1e9..6b6df30 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2823,7 +2823,7 @@ cifs_uncached_read_into_pages(struct TCP_Server_Info *server, total_read += result; } - return total_read > 0 ? total_read : result; + return total_read > 0 && result != -EAGAIN ? total_read : result; } ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to) @@ -3231,7 +3231,7 @@ cifs_readpages_read_into_pages(struct TCP_Server_Info *server, total_read += result; } - return total_read > 0 ? total_read : result; + return total_read > 0 && result != -EAGAIN ? total_read : result; } static int cifs_readpages(struct file *file, struct address_space *mapping,