aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/cifs/file.c31
1 files changed, 6 insertions, 25 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 74c33d5fafc8..c9bc56b1baac 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2541,14 +2541,13 @@ static int
2541cifs_resend_wdata(struct cifs_writedata *wdata, struct list_head *wdata_list, 2541cifs_resend_wdata(struct cifs_writedata *wdata, struct list_head *wdata_list,
2542 struct cifs_aio_ctx *ctx) 2542 struct cifs_aio_ctx *ctx)
2543{ 2543{
2544 int wait_retry = 0;
2545 unsigned int wsize, credits; 2544 unsigned int wsize, credits;
2546 int rc; 2545 int rc;
2547 struct TCP_Server_Info *server = 2546 struct TCP_Server_Info *server =
2548 tlink_tcon(wdata->cfile->tlink)->ses->server; 2547 tlink_tcon(wdata->cfile->tlink)->ses->server;
2549 2548
2550 /* 2549 /*
2551 * Try to resend this wdata, waiting for credits up to 3 seconds. 2550 * Wait for credits to resend this wdata.
2552 * Note: we are attempting to resend the whole wdata not in segments 2551 * Note: we are attempting to resend the whole wdata not in segments
2553 */ 2552 */
2554 do { 2553 do {
@@ -2556,19 +2555,13 @@ cifs_resend_wdata(struct cifs_writedata *wdata, struct list_head *wdata_list,
2556 server, wdata->bytes, &wsize, &credits); 2555 server, wdata->bytes, &wsize, &credits);
2557 2556
2558 if (rc) 2557 if (rc)
2559 break; 2558 goto out;
2560 2559
2561 if (wsize < wdata->bytes) { 2560 if (wsize < wdata->bytes) {
2562 add_credits_and_wake_if(server, credits, 0); 2561 add_credits_and_wake_if(server, credits, 0);
2563 msleep(1000); 2562 msleep(1000);
2564 wait_retry++;
2565 } 2563 }
2566 } while (wsize < wdata->bytes && wait_retry < 3); 2564 } while (wsize < wdata->bytes);
2567
2568 if (wsize < wdata->bytes) {
2569 rc = -EBUSY;
2570 goto out;
2571 }
2572 2565
2573 rc = -EAGAIN; 2566 rc = -EAGAIN;
2574 while (rc == -EAGAIN) { 2567 while (rc == -EAGAIN) {
@@ -3234,14 +3227,13 @@ static int cifs_resend_rdata(struct cifs_readdata *rdata,
3234 struct list_head *rdata_list, 3227 struct list_head *rdata_list,
3235 struct cifs_aio_ctx *ctx) 3228 struct cifs_aio_ctx *ctx)
3236{ 3229{
3237 int wait_retry = 0;
3238 unsigned int rsize, credits; 3230 unsigned int rsize, credits;
3239 int rc; 3231 int rc;
3240 struct TCP_Server_Info *server = 3232 struct TCP_Server_Info *server =
3241 tlink_tcon(rdata->cfile->tlink)->ses->server; 3233 tlink_tcon(rdata->cfile->tlink)->ses->server;
3242 3234
3243 /* 3235 /*
3244 * Try to resend this rdata, waiting for credits up to 3 seconds. 3236 * Wait for credits to resend this rdata.
3245 * Note: we are attempting to resend the whole rdata not in segments 3237 * Note: we are attempting to resend the whole rdata not in segments
3246 */ 3238 */
3247 do { 3239 do {
@@ -3249,24 +3241,13 @@ static int cifs_resend_rdata(struct cifs_readdata *rdata,
3249 &rsize, &credits); 3241 &rsize, &credits);
3250 3242
3251 if (rc) 3243 if (rc)
3252 break; 3244 goto out;
3253 3245
3254 if (rsize < rdata->bytes) { 3246 if (rsize < rdata->bytes) {
3255 add_credits_and_wake_if(server, credits, 0); 3247 add_credits_and_wake_if(server, credits, 0);
3256 msleep(1000); 3248 msleep(1000);
3257 wait_retry++;
3258 } 3249 }
3259 } while (rsize < rdata->bytes && wait_retry < 3); 3250 } while (rsize < rdata->bytes);
3260
3261 /*
3262 * If we can't find enough credits to send this rdata
3263 * release the rdata and return failure, this will pass
3264 * whatever I/O amount we have finished to VFS.
3265 */
3266 if (rsize < rdata->bytes) {
3267 rc = -EBUSY;
3268 goto out;
3269 }
3270 3251
3271 rc = -EAGAIN; 3252 rc = -EAGAIN;
3272 while (rc == -EAGAIN) { 3253 while (rc == -EAGAIN) {