From patchwork Sat Mar 2 02:51:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 10836355 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 192EC180E for ; Sat, 2 Mar 2019 03:04:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B64328ABA for ; Sat, 2 Mar 2019 03:04:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF8162DE86; Sat, 2 Mar 2019 03:04:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9199E28ABA for ; Sat, 2 Mar 2019 03:04:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727840AbfCBDET (ORCPT ); Fri, 1 Mar 2019 22:04:19 -0500 Received: from a2nlsmtp01-05.prod.iad2.secureserver.net ([198.71.225.49]:45624 "EHLO a2nlsmtp01-05.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726693AbfCBDET (ORCPT ); Fri, 1 Mar 2019 22:04:19 -0500 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with ESMTP id zukrgx7wsvHD3zukrgCi7x; Fri, 01 Mar 2019 19:52:01 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.91) (envelope-from ) id 1gzukr-0000m7-77; Fri, 01 Mar 2019 19:52:01 -0700 From: Long Li To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org Cc: Long Li Subject: [PATCH 2/2] CIFS: Fix a bug with re-sending rdata when transport returning -EAGAIN Date: Sat, 2 Mar 2019 02:51:46 +0000 Message-Id: <20190302025146.2935-2-longli@linuxonhyperv.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190302025146.2935-1-longli@linuxonhyperv.com> References: <20190302025146.2935-1-longli@linuxonhyperv.com> MIME-Version: 1.0 Reply-To: longli@microsoft.com X-CMAE-Envelope: MS4wfHVMZ3YZdpaQQHlyI15jJkM14XlHjpQ2z4a/I0Cm5O+W3FVh39b/6Upqj9K4R/9Al2mKNZKPovFAnoIKB09kuUPEzx3YmD0ouGFezZUDU98gpPM8unsT 16Q71DqEq76upCWywgYPqvK9IrEV9eMtMkstIiERnDaLdt7ttt8unfhHot+jDYXTmNQZj/UDjG0dS8/TRCRWgUYqIQO02hB4Ln2h2nA9jrZGCPBqNkl3JLzY Vol31ubhDcLgk28qUooLZEHHp+kUOr6ICjcss7LbyZI13YMF5hUwaJSsjJymDJX8ONl/IxkwE8GbxKrqyNHehvANhw5bD1/XacqoNp3hQ+Lyd4myt3Nl23JM FHl1wCUMbYodxI5O3RpMmHOIlGDGhlelqK8D6VB2llHuSlaA+IacENdT2Q6QEsv07QeHJlSE Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Long Li When sending a rdata, transport may return -EAGAIN. In this case we should re-obtain credits because the session may have been reconnected. Signed-off-by: Long Li --- fs/cifs/file.c | 51 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 08e73759d6ec..c83ca96f883b 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -3335,44 +3335,45 @@ static int cifs_resend_rdata(struct cifs_readdata *rdata, struct TCP_Server_Info *server = tlink_tcon(rdata->cfile->tlink)->ses->server; - /* - * Wait for credits to resend this rdata. - * Note: we are attempting to resend the whole rdata not in segments - */ do { - rc = server->ops->wait_mtu_credits(server, rdata->bytes, + /* + * Wait for credits to resend this rdata. + * Note: we are attempting to resend the whole rdata not in + * segments + */ + do { + rc = server->ops->wait_mtu_credits(server, rdata->bytes, &rsize, &credits); - if (rc) - goto out; + if (rc) + goto fail; - if (rsize < rdata->bytes) { - add_credits_and_wake_if(server, &credits, 0); - msleep(1000); - } - } while (rsize < rdata->bytes); + if (rsize < rdata->bytes) { + add_credits_and_wake_if(server, &credits, 0); + msleep(1000); + } + } while (rsize < rdata->bytes); - rdata->credits = credits; - rc = -EAGAIN; - while (rc == -EAGAIN) { + rdata->credits = credits; rc = 0; if (rdata->cfile->invalidHandle) rc = cifs_reopen_file(rdata->cfile, true); if (!rc) rc = server->ops->async_readv(rdata); - } - if (!rc) { - /* Add to aio pending list */ - list_add_tail(&rdata->list, rdata_list); - return 0; - } + /* If the read was successfully sent, we are done */ + if (!rc) { + /* Add to aio pending list */ + list_add_tail(&rdata->list, rdata_list); + return 0; + } - add_credits_and_wake_if(server, &rdata->credits, 0); -out: - kref_put(&rdata->refcount, - cifs_uncached_readdata_release); + /* Roll back credits and retry if needed */ + add_credits_and_wake_if(server, &rdata->credits, 0); + } while (rc == -EAGAIN); +fail: + kref_put(&rdata->refcount, cifs_uncached_readdata_release); return rc; }