LKML Archive on lore.kernel.org
 help / Atom feed
* [PATCH] CIFS: Avoid returning EBUSY to upper layer VFS
@ 2018-12-06  4:51 Long Li
  2018-12-06  8:29 ` Steve French
  0 siblings, 1 reply; 3+ messages in thread
From: Long Li @ 2018-12-06  4:51 UTC (permalink / raw)
  To: Steve French, linux-cifs, samba-technical, linux-kernel,
	linux-rdma, Dan Carpenter
  Cc: Long Li

From: Long Li <longli@microsoft.com>

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 <dan.carpenter@oracle.com>
Signed-off-by: Long Li <longli@microsoft.com>
---
 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] CIFS: Avoid returning EBUSY to upper layer VFS
  2018-12-06  4:51 [PATCH] CIFS: Avoid returning EBUSY to upper layer VFS Long Li
@ 2018-12-06  8:29 ` Steve French
  2018-12-07  1:47   ` Pavel Shilovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Steve French @ 2018-12-06  8:29 UTC (permalink / raw)
  To: Long Li
  Cc: Steve French, CIFS, samba-technical, LKML, linux-rdma, Dan Carpenter

Tentatively pushed to cifs-2.6.git for-next
On Wed, Dec 5, 2018 at 10:52 PM Long Li <longli@linuxonhyperv.com> wrote:
>
> From: Long Li <longli@microsoft.com>
>
> 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 <dan.carpenter@oracle.com>
> Signed-off-by: Long Li <longli@microsoft.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] CIFS: Avoid returning EBUSY to upper layer VFS
  2018-12-06  8:29 ` Steve French
@ 2018-12-07  1:47   ` Pavel Shilovsky
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Shilovsky @ 2018-12-07  1:47 UTC (permalink / raw)
  To: Steve French
  Cc: Long Li, linux-cifs, linux-rdma, samba-technical,
	Kernel Mailing List, Steve French, Dan Carpenter

чт, 6 дек. 2018 г. в 00:29, Steve French via samba-technical
<samba-technical@lists.samba.org>:
>
> Tentatively pushed to cifs-2.6.git for-next
> On Wed, Dec 5, 2018 at 10:52 PM Long Li <longli@linuxonhyperv.com> wrote:
> >
> > From: Long Li <longli@microsoft.com>
> >
> > 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 <dan.carpenter@oracle.com>
> > Signed-off-by: Long Li <longli@microsoft.com>
> > ---
> >  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
>

Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>

--
Best regards,
Pavel Shilovsky

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-06  4:51 [PATCH] CIFS: Avoid returning EBUSY to upper layer VFS Long Li
2018-12-06  8:29 ` Steve French
2018-12-07  1:47   ` Pavel Shilovsky

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox