Commit d53e292f authored by Long Li's avatar Long Li Committed by Steve French

CIFS: Fix an issue with re-sending wdata when transport returning -EAGAIN

When sending a wdata, transport may return -EAGAIN. In this case
we should re-obtain credits because the session may have been
reconnected.

Change in v2: adjust_credits before re-sending
Signed-off-by: default avatarLong Li <longli@microsoft.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
Reviewed-by: default avatarPavel Shilovsky <pshilov@microsoft.com>
parent a5ed1e96
...@@ -2632,43 +2632,56 @@ cifs_resend_wdata(struct cifs_writedata *wdata, struct list_head *wdata_list, ...@@ -2632,43 +2632,56 @@ cifs_resend_wdata(struct cifs_writedata *wdata, struct list_head *wdata_list,
struct TCP_Server_Info *server = struct TCP_Server_Info *server =
tlink_tcon(wdata->cfile->tlink)->ses->server; tlink_tcon(wdata->cfile->tlink)->ses->server;
do {
if (wdata->cfile->invalidHandle) {
rc = cifs_reopen_file(wdata->cfile, false);
if (rc == -EAGAIN)
continue;
else if (rc)
break;
}
/* /*
* Wait for credits to resend this wdata. * Wait for credits to resend this wdata.
* Note: we are attempting to resend the whole wdata not in segments * Note: we are attempting to resend the whole wdata not in
* segments
*/ */
do { do {
rc = server->ops->wait_mtu_credits(server, wdata->bytes, &wsize, rc = server->ops->wait_mtu_credits(server, wdata->bytes,
&credits); &wsize, &credits);
if (rc) if (rc)
goto out; goto fail;
if (wsize < wdata->bytes) { if (wsize < wdata->bytes) {
add_credits_and_wake_if(server, &credits, 0); add_credits_and_wake_if(server, &credits, 0);
msleep(1000); msleep(1000);
} }
} while (wsize < wdata->bytes); } while (wsize < wdata->bytes);
wdata->credits = credits; wdata->credits = credits;
rc = -EAGAIN;
while (rc == -EAGAIN) { rc = adjust_credits(server, &wdata->credits, wdata->bytes);
rc = 0;
if (!rc) {
if (wdata->cfile->invalidHandle) if (wdata->cfile->invalidHandle)
rc = cifs_reopen_file(wdata->cfile, false); rc = -EAGAIN;
if (!rc) else
rc = server->ops->async_writev(wdata, rc = server->ops->async_writev(wdata,
cifs_uncached_writedata_release); cifs_uncached_writedata_release);
} }
/* If the write was successfully sent, we are done */
if (!rc) { if (!rc) {
list_add_tail(&wdata->list, wdata_list); list_add_tail(&wdata->list, wdata_list);
return 0; return 0;
} }
/* Roll back credits and retry if needed */
add_credits_and_wake_if(server, &wdata->credits, 0); add_credits_and_wake_if(server, &wdata->credits, 0);
out: } while (rc == -EAGAIN);
kref_put(&wdata->refcount, cifs_uncached_writedata_release);
fail:
kref_put(&wdata->refcount, cifs_uncached_writedata_release);
return rc; return rc;
} }
...@@ -2896,12 +2909,12 @@ static void collect_uncached_write_data(struct cifs_aio_ctx *ctx) ...@@ -2896,12 +2909,12 @@ static void collect_uncached_write_data(struct cifs_aio_ctx *ctx)
wdata->bytes, &tmp_from, wdata->bytes, &tmp_from,
ctx->cfile, cifs_sb, &tmp_list, ctx->cfile, cifs_sb, &tmp_list,
ctx); ctx);
}
list_splice(&tmp_list, &ctx->list);
kref_put(&wdata->refcount, kref_put(&wdata->refcount,
cifs_uncached_writedata_release); cifs_uncached_writedata_release);
}
list_splice(&tmp_list, &ctx->list);
goto restart_loop; goto restart_loop;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment