Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10287151imu; Wed, 5 Dec 2018 20:53:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/ULYrhfbu3eQ4dV9wbHUhzY1w4LQCHYBIHMwcdL7L97lwfhSE/3pXO0iMhaDNKJ8ZAkhSBh X-Received: by 2002:a63:7a5b:: with SMTP id j27mr22990456pgn.112.1544072021381; Wed, 05 Dec 2018 20:53:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544072021; cv=none; d=google.com; s=arc-20160816; b=E55mlUaD5d4Xd5KrYPVRK0cC2EMimHEtyr0de3kGCXzEEWD/PRceHTOzhRVxtW91Fo 9qqaWM1Sx/r0YJz/HWALocBc19WVGCXug9tmNY14uFaRKTpaLxV2Am95nWC0/G2hrFz1 yQdVDj4TbJe8yV1qu2Vz5VBnqvb7cfTsyoWI6xT+o4xwwUXy2JndLomWJM1ov9NBdtZX EMmmqzuXNJk20zQzITjK6UQVlmE6N26pYlH2F4zsYIFREIUYvgVlHDHu3J+9j1ZVgp7X PGp6i8fJcOj8X6GJDorFFsSsJrzlcwuZ6oSdnIO5OuIYndvwgSdIZKJjPzFSW+9GYaVU 5RTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:reply-to :mime-version:message-id:date:subject:cc:to:from; bh=xYotV3UHW18RhHGN1pEFcQt+QlqTeiY0pZpOd9oxuK8=; b=VTuWzO1srr640pI33bRjMRLZ931dLnpUnOkrw/9G8bswUYhRgNBsvPTFIiThr/oWVn y8pmEQBx/E4IXsnYGRv+ePCHBT0F/sdvtedJGhT6k7uo03IMzmNHuz+7N6lTmfP/93Tz 0D5vAtzUTMw2pRWYC127EHDo8D2MjzuhVT9l9qllRyKxaCxR2KreYLpTYomAbVQfKVj2 HyRncbahjZxmIIcTnyGP5+4d6TJE7YAqGYr17GvMNvF3Wd91uWJJCA13JjQfEWJDDyP1 0Opf8MGmqrLm1zwOca/mZDhWc1MaXnGmb1/HH3R9acUj3D4AQGdfv6vQ3zIKDEiluWXw kQ8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j195si25370501pfd.165.2018.12.05.20.53.24; Wed, 05 Dec 2018 20:53:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729014AbeLFEwV (ORCPT + 99 others); Wed, 5 Dec 2018 23:52:21 -0500 Received: from a2nlsmtp01-04.prod.iad2.secureserver.net ([198.71.225.38]:45772 "EHLO a2nlsmtp01-04.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727940AbeLFEwV (ORCPT ); Wed, 5 Dec 2018 23:52:21 -0500 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with ESMTP id Uld9gCuEJThUeUld9gmPSE; Wed, 05 Dec 2018 21:51:19 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.91) (envelope-from ) id 1gUld9-0002gu-2j; Wed, 05 Dec 2018 21:51:19 -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, Dan Carpenter Cc: Long Li Subject: [PATCH] CIFS: Avoid returning EBUSY to upper layer VFS Date: Thu, 6 Dec 2018 04:51:06 +0000 Message-Id: <20181206045106.10307-1-longli@linuxonhyperv.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Reply-To: longli@microsoft.com Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfClKI8v2oRk6JDdYiuZS2omecvMEn+QmMHXK60o81X8WC9WNllrv8KcL4ygEqW79NhzRC9UL2bjCi84P1N+mt/2vdwHGZn25cIFtgqcRdax3d7l9zrVm v8ZVz3xE5ksWERIhUuA+xexH0Ge7WazNGOd9sNUlrfwlOxdMAVpxQpjlX+v1pq0tKtu70LaIE9Wcg58hDQWHf73kOMiIAETCwHlOV4XlXyDgCIFpkbyu2o4D iaD/kQmuX+295W/6ES9QP7bzXEwxUMn0NAsxLYH20C7wkheRHYqLZaVR8me7cJzm7gScXfqTg8ACgwV7nJAAOSGtrlJdyMWnel6lCYDDcf2IiBBakNCYrj2k wW05vEQBDNizKDqDGex3eBuYQXt7XMFaOW9e5oeScIHoMn4AZ8220xLjNXHWv7RO5tPywoqLfUciS4M1dMOkDPxRzZrHUtKPpxv2F/bnXdCVPnZpXy0= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Long Li EBUSY is not handled by VFS, and will be passed to user-mode. This is not correct as we need to wait for more credits. This patch also fixes a bug where rsize or wsize is used uninitialized when the call to server->ops->wait_mtu_credits() fails. Reported-by: Dan Carpenter Signed-off-by: Long Li --- fs/cifs/file.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 74c33d5..c9bc56b 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2541,14 +2541,13 @@ static int cifs_resend_wdata(struct cifs_writedata *wdata, struct list_head *wdata_list, struct cifs_aio_ctx *ctx) { - int wait_retry = 0; unsigned int wsize, credits; int rc; struct TCP_Server_Info *server = tlink_tcon(wdata->cfile->tlink)->ses->server; /* - * Try to resend this wdata, waiting for credits up to 3 seconds. + * Wait for credits to resend this wdata. * Note: we are attempting to resend the whole wdata not in segments */ do { @@ -2556,19 +2555,13 @@ cifs_resend_wdata(struct cifs_writedata *wdata, struct list_head *wdata_list, server, wdata->bytes, &wsize, &credits); if (rc) - break; + goto out; if (wsize < wdata->bytes) { add_credits_and_wake_if(server, credits, 0); msleep(1000); - wait_retry++; } - } while (wsize < wdata->bytes && wait_retry < 3); - - if (wsize < wdata->bytes) { - rc = -EBUSY; - goto out; - } + } while (wsize < wdata->bytes); rc = -EAGAIN; while (rc == -EAGAIN) { @@ -3234,14 +3227,13 @@ static int cifs_resend_rdata(struct cifs_readdata *rdata, struct list_head *rdata_list, struct cifs_aio_ctx *ctx) { - int wait_retry = 0; unsigned int rsize, credits; int rc; struct TCP_Server_Info *server = tlink_tcon(rdata->cfile->tlink)->ses->server; /* - * Try to resend this rdata, waiting for credits up to 3 seconds. + * Wait for credits to resend this rdata. * Note: we are attempting to resend the whole rdata not in segments */ do { @@ -3249,24 +3241,13 @@ static int cifs_resend_rdata(struct cifs_readdata *rdata, &rsize, &credits); if (rc) - break; + goto out; if (rsize < rdata->bytes) { add_credits_and_wake_if(server, credits, 0); msleep(1000); - wait_retry++; } - } while (rsize < rdata->bytes && wait_retry < 3); - - /* - * If we can't find enough credits to send this rdata - * release the rdata and return failure, this will pass - * whatever I/O amount we have finished to VFS. - */ - if (rsize < rdata->bytes) { - rc = -EBUSY; - goto out; - } + } while (rsize < rdata->bytes); rc = -EAGAIN; while (rc == -EAGAIN) { -- 2.7.4