From bc91b0a3c27b61536503d239f4b38116d03f69bd Mon Sep 17 00:00:00 2001
From: johann <johann>
Date: Mon, 6 Oct 2008 13:57:32 +0000
Subject: [PATCH] Branch HEAD b=17261 i=shadow i=umka

prevent ptlrpc_queue_wait() from looping indefinitely because of ENOMEM.
---
 lustre/ptlrpc/client.c | 6 +++---
 lustre/ptlrpc/niobuf.c | 8 +++++++-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c
index 565661abce..42a456f770 100644
--- a/lustre/ptlrpc/client.c
+++ b/lustre/ptlrpc/client.c
@@ -2083,8 +2083,8 @@ repeat:
                   "-- sleeping for "CFS_DURATION_T" ticks", timeout);
         lwi = LWI_TIMEOUT_INTR(timeout, expired_request, interrupted_request,
                                req);
-        rc = l_wait_event(req->rq_reply_waitq, ptlrpc_check_reply(req), &lwi);
-        if (rc == -ETIMEDOUT && ((req->rq_deadline > cfs_time_current_sec()) ||
+        brc = l_wait_event(req->rq_reply_waitq, ptlrpc_check_reply(req), &lwi);
+        if (brc == -ETIMEDOUT && ((req->rq_deadline > cfs_time_current_sec()) ||
                                  ptlrpc_check_and_wait_suspend(req)))
                 goto repeat;
 
@@ -2109,7 +2109,7 @@ after_send:
         if (req->rq_err) {
                 DEBUG_REQ(D_RPCTRACE, req, "err rc=%d status=%d",
                           rc, req->rq_status);
-                GOTO(out, rc = -EIO);
+                GOTO(out, rc = rc ? rc : -EIO);
         }
 
         if (req->rq_intr) {
diff --git a/lustre/ptlrpc/niobuf.c b/lustre/ptlrpc/niobuf.c
index 6d4226ddf0..c83c8772a7 100644
--- a/lustre/ptlrpc/niobuf.c
+++ b/lustre/ptlrpc/niobuf.c
@@ -490,6 +490,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
                        request->rq_import->imp_obd->obd_name);
                 /* this prevents us from waiting in ptlrpc_queue_wait */
                 request->rq_err = 1;
+                request->rq_status = -ENODEV;
                 RETURN(-ENODEV);
         }
 
@@ -521,8 +522,13 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
                         LASSERT(request->rq_repmsg == NULL);
                         rc = sptlrpc_cli_alloc_repbuf(request,
                                                       request->rq_replen);
-                        if (rc)
+                        if (rc) {
+                                /* this prevents us from looping in
+                                 * ptlrpc_queue_wait */
+                                request->rq_err = 1;
+                                request->rq_status = rc;
                                 GOTO(cleanup_bulk, rc);
+                        }
                 } else {
                         request->rq_repdata = NULL;
                         request->rq_repmsg = NULL;
-- 
GitLab