Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10427280imu; Thu, 6 Dec 2018 00:30:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/W1gRPXHUa5zCH+6Ep3GOVtMRgsrW6ZnQ09+2t3mRGm5eitvQVbX0OH3Yzbvk7EXaYjoFuK X-Received: by 2002:a62:fc52:: with SMTP id e79mr27919008pfh.8.1544085026500; Thu, 06 Dec 2018 00:30:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544085026; cv=none; d=google.com; s=arc-20160816; b=PgKQebFDyDf3XFc3bEvVg4xdScSccj/M91WZmvTZhdQ8JTNzNV4d35LhfOq+9S+HXy gP1o2XAFskCBmMT9bEwTh4qxlyzPJ5xb20u6hRYfrxd5Rn2uJ+dB657HoPwuVaXLNo04 F9aRwqnNYbQxfMmP5UyLrhlq4TZYNLc//ZAcrmwhe4EjOhJ7otf8htTZgaKsJUX/0Oef Wr0YkNRLZPSTXSBpW3ZJUIRrorNsdTLKDsYM0TYKn3w9G6K5vbceJ6HYQgCh49DY98zj q4XAZQ9Bem/uts5TT3k0peVzcn+Bx+lITW1E2PY7Tlzy6o3usJWJrdRP4TzkyzaKgpMc x3NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=e/Ar76V5U0eoQHEha4TAqTfqZW7EvmtK6ivHZJBG9/8=; b=qOV+xXUpw9pEnQcqcq0WsPpc0I0EL4DEBxuJ/5pBLXPoNi6NLPs3lHMOPge1GMvWn2 1Q8hCYsEHmfg80F+NzqqFCkjEm2Kvez9WPjRKrg3Yg8NjBIWgbP/hd1QsB7pcGTG5xWd V1z5q1Tq2zdDFCWnCHTTthYmAmdMAYVJYtZ9cnD5mVhIpfVdzYexj4GgWNrkcjeXmch5 nC09errbaEOXa+HEcFVtvFFTA7rKNQPuEl/uCmX0+rJM6Ui8hbEqE+YBwiW0VbugQeNp tz1Sh9vV941jPWkA7aPnBM6MemJjx4ey29arSG64wadJBNhIqVnCOmK4jLybTF9n/Vri ywyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LYCereFX; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k64si20117153pge.7.2018.12.06.00.30.09; Thu, 06 Dec 2018 00:30:26 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LYCereFX; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729218AbeLFI3O (ORCPT + 99 others); Thu, 6 Dec 2018 03:29:14 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42881 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727575AbeLFI3N (ORCPT ); Thu, 6 Dec 2018 03:29:13 -0500 Received: by mail-pg1-f196.google.com with SMTP id d72so10309756pga.9; Thu, 06 Dec 2018 00:29:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=e/Ar76V5U0eoQHEha4TAqTfqZW7EvmtK6ivHZJBG9/8=; b=LYCereFXM0+qp/g4KRHsWnV3ECC+9vLIdjBJjdD74qJR0ihF/6x+1XldRJtxrhQIMd u7ckYUzYqc6yX8nicxrlPPyMXVT05wLXncpiQqzyItKmwMZGRrVkANC/av4gGWlxP/vc LRCwDkWF9peBt8c2jbkp6YVcBAPkTnLMIzHPjUfna9XQOIyBst7u/UUjgLKUu3QBi/Og 9QfGTlXyTFe+dKGMyXgeOPZbw76S3PSDxU+zRHz9qgNpiXOuU1HE9aiaebPn8V248ay1 a6+zrZoZiI/2f6+VtAsK2CSJxOAFB8qdsGe/0Ow8T0GIvAcZfoDn3SQINMGc6RGXbqod sm5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=e/Ar76V5U0eoQHEha4TAqTfqZW7EvmtK6ivHZJBG9/8=; b=OxCCyhAgtdvqw3f8rIDK4Kb37dR9f0ncB4aXEXN1Pv3AO082L5dzPQVCdxMEErHre1 BB37HaHggF9CG3H0kY+a2DzPV+YStXuX1gyKJsCBJT+CwIkzD7hiC+E7TR1S2E4WKwUA 7aA4xKtfi8xje9rA2o1V/nWKRH+W7nEAbRlwEA4Ho60OTNw01AopQwDwS6h2DCR2bt/D NTElr1jcCHqD7pGjYIAvLUL06um2IWBicXEd3h9FDI2EGdv/dML5RBGMs0XeCIgM3VoS +Ca76dZCKnI4cDOrDlVsm5dumiXLoqDD4Y2ERqkQQjZjBI1wonbbrIwhBepqvRp4tJme hJSg== X-Gm-Message-State: AA+aEWbqnJup9iL+Eer+JkkRUEYnuGRxF23+rdIpDo9vTW/OfKnaFvTG isJZte/ZUP9Tg4zSn6ffgEQ+rWiJZP/42QCs5VF9Mw== X-Received: by 2002:a63:61c8:: with SMTP id v191mr23568082pgb.242.1544084952852; Thu, 06 Dec 2018 00:29:12 -0800 (PST) MIME-Version: 1.0 References: <20181206045106.10307-1-longli@linuxonhyperv.com> In-Reply-To: <20181206045106.10307-1-longli@linuxonhyperv.com> From: Steve French Date: Thu, 6 Dec 2018 02:29:01 -0600 Message-ID: Subject: Re: [PATCH] CIFS: Avoid returning EBUSY to upper layer VFS To: Long Li Cc: Steve French , CIFS , samba-technical , LKML , linux-rdma@vger.kernel.org, Dan Carpenter Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tentatively pushed to cifs-2.6.git for-next On Wed, Dec 5, 2018 at 10:52 PM Long Li wrote: > > 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 > -- Thanks, Steve