Whamcloud - gitweb
b=21776 Use atomic memory allocation when VM is flushing to free memory.
[fs/lustre-release.git] / lustre / ptlrpc / niobuf.c
index 508f0e2..537be4f 100644 (file)
@@ -529,6 +529,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
 {
         int rc;
         int rc2;
+        int mpflag = 0;
         struct ptlrpc_connection *connection;
         lnet_handle_me_t  reply_me_h;
         lnet_md_t         reply_md;
@@ -568,15 +569,18 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
         if (request->rq_resend)
                 lustre_msg_add_flags(request->rq_reqmsg, MSG_RESENT);
 
+        if (request->rq_memalloc)
+                mpflag = cfs_memory_pressure_get_and_set();
+
         rc = sptlrpc_cli_wrap_request(request);
         if (rc)
-                RETURN(rc);
+                GOTO(out, rc);
 
         /* bulk register should be done after wrap_request() */
         if (request->rq_bulk != NULL) {
                 rc = ptlrpc_register_bulk (request);
                 if (rc != 0)
-                        RETURN(rc);
+                        GOTO(out, rc);
         }
 
         if (!noreply) {
@@ -681,11 +685,11 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
                           request->rq_request_portal,
                           request->rq_xid, 0);
         if (rc == 0)
-                RETURN(rc);
+                GOTO(out, rc);
 
         ptlrpc_req_finished(request);
         if (noreply)
-                RETURN(rc);
+                GOTO(out, rc);
 
  cleanup_me:
         /* MEUnlink is safe; the PUT didn't even get off the ground, and
@@ -700,6 +704,9 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
         /* We do sync unlink here as there was no real transfer here so
          * the chance to have long unlink to sluggish net is smaller here. */
         ptlrpc_unregister_bulk(request, 0);
+ out:
+        if (request->rq_memalloc)
+                cfs_memory_pressure_restore(mpflag);
         return rc;
 }