From patchwork Fri Jun 27 09:57:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 4434271 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 17D0A9F2C8 for ; Fri, 27 Jun 2014 09:58:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3558320351 for ; Fri, 27 Jun 2014 09:58:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 13981201EF for ; Fri, 27 Jun 2014 09:58:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753288AbaF0J6I (ORCPT ); Fri, 27 Jun 2014 05:58:08 -0400 Received: from mail-lb0-f181.google.com ([209.85.217.181]:60292 "EHLO mail-lb0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753284AbaF0J6F (ORCPT ); Fri, 27 Jun 2014 05:58:05 -0400 Received: by mail-lb0-f181.google.com with SMTP id p9so3761294lbv.40 for ; Fri, 27 Jun 2014 02:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=iHqljpvGpo4Z3txivliAdjpsuWoNY/UmfMqWrimXsu4=; b=Gn775hRbEJ5fdHtpisVGRfamDnadVXwPN4uXudNJiuu0nbPaFLOsje8Kev56FNbDPu nGIOT0VNDOQu7JCRy7Yn8w+2FXVQ0A7VLIb8I3JkDVPWUDtXOpBD8yFS/e2YAtAoPz0m sw7cK16F5+k+wbzwlPpRk3fXnSQe9NL9dYKdApVkQYO31M4QSWfb6vzG28eb6E5KPG1h J2U9Q+R31Q1UkJXHwpZCY/zJHQuCezbdih4K5cGzjZWnh5vu+YG7hDHuheOtOMYLZ9fn ya8JfYyuCWYjRmmh3jzF+vu4/ltps2YdDeEADRCnDetN8Vljnck9scGXZ/jzOubCY0e+ 0fBg== X-Received: by 10.152.37.229 with SMTP id b5mr15707021lak.40.1403863083858; Fri, 27 Jun 2014 02:58:03 -0700 (PDT) Received: from localhost.localdomain ([92.43.3.6]) by mx.google.com with ESMTPSA id y8sm10969918lbr.18.2014.06.27.02.58.02 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Jun 2014 02:58:02 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Cc: Jeff Layton Subject: [PATCH v2 01/16] CIFS: Fix async reading on reconnects Date: Fri, 27 Jun 2014 13:57:38 +0400 Message-Id: <1403863073-19526-2-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 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. Cc: Jeff Layton Signed-off-by: Pavel Shilovsky Acked-by: Jeff Layton --- 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,