From d72e9f75b54675fc17674d259a63f5c917695e69 Mon Sep 17 00:00:00 2001
From: green <green>
Date: Fri, 3 Aug 2007 04:23:47 +0000
Subject: [PATCH] b=11706 r=adilger

Obtain necessary amount of peer credits for exery export per oss and for
every possible AST per MDS.
---
 lustre/ChangeLog              | 6 ++++++
 lustre/include/lustre_net.h   | 1 +
 lustre/mdc/mdc_request.c      | 2 ++
 lustre/osc/osc_request.c      | 2 ++
 lustre/ptlrpc/import.c        | 8 ++++++++
 lustre/ptlrpc/ptlrpc_module.c | 1 +
 6 files changed, 20 insertions(+)

diff --git a/lustre/ChangeLog b/lustre/ChangeLog
index ca9b9f88e9..5efd20e1e8 100644
--- a/lustre/ChangeLog
+++ b/lustre/ChangeLog
@@ -83,6 +83,12 @@ Details    : When running with O_DIRECT I/O, neither the client rpc_stats nor
 	     read_ahead_stats were updated. Copied stats section from 
 	     osc_send_oap_rpc() into async_internal().
 
+Severity   : minor
+Bugzilla   : 11706
+Frequency  : only for Cray XT3
+Description: peer credits not enough on many OST per OSS systems.
+Details    : Use new lnet way to add credits as we need those for pings and ASTs
+
 --------------------------------------------------------------------------------
 
 2007-07-30         Cluster File Systems, Inc. <info@clusterfs.com>
diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h
index 673cf5f45c..76a5eafda7 100644
--- a/lustre/include/lustre_net.h
+++ b/lustre/include/lustre_net.h
@@ -750,6 +750,7 @@ int ptlrpc_connect_import(struct obd_import *imp, char * new_uuid);
 int ptlrpc_init_import(struct obd_import *imp);
 int ptlrpc_disconnect_import(struct obd_import *imp, int noclose);
 int ptlrpc_import_recovery_state_machine(struct obd_import *imp);
+void ptlrpc_import_setasync(struct obd_import *imp, int count);
 
 /* ptlrpc/pack_generic.c */
 int lustre_msg_swabbed(struct lustre_msg *msg);
diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c
index aa55c18028..0846aca06e 100644
--- a/lustre/mdc/mdc_request.c
+++ b/lustre/mdc/mdc_request.c
@@ -1109,6 +1109,7 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp,
 
         switch (event) {
         case IMP_EVENT_DISCON: {
+                ptlrpc_import_setasync(imp, -obd->obd_namespace->ns_max_unused);
                 break;
         }
         case IMP_EVENT_INACTIVE: {
@@ -1127,6 +1128,7 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp,
                 break;
         }
         case IMP_EVENT_OCD:
+                ptlrpc_import_setasync(imp, obd->obd_namespace->ns_max_unused);
                 break;
 
         default:
diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c
index 3195948f9f..9caa9df9d0 100644
--- a/lustre/osc/osc_request.c
+++ b/lustre/osc/osc_request.c
@@ -3508,6 +3508,7 @@ static int osc_import_event(struct obd_device *obd,
                 cli->cl_avail_grant = 0;
                 cli->cl_lost_grant = 0;
                 client_obd_list_unlock(&cli->cl_loi_list_lock);
+                ptlrpc_import_setasync(imp, -1);
 
                 break;
         }
@@ -3551,6 +3552,7 @@ static int osc_import_event(struct obd_device *obd,
                 if (ocd->ocd_connect_flags & OBD_CONNECT_REQPORTAL)
                         imp->imp_client->cli_request_portal =OST_REQUEST_PORTAL;
 
+                ptlrpc_import_setasync(imp, 1);
                 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_OCD, NULL);
                 break;
         }
diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c
index afb3b09a6c..c585932a2e 100644
--- a/lustre/ptlrpc/import.c
+++ b/lustre/ptlrpc/import.c
@@ -1031,3 +1031,11 @@ out:
         RETURN(rc);
 }
 
+/* Sets maximal number of RPCs possible originating from other side of this
+   import (server) to us and number of async RPC replies that we are not waiting
+   for arriving */
+void ptlrpc_import_setasync(struct obd_import *imp, int count)
+{
+        LNetSetAsync(imp->imp_connection->c_peer, count);
+}
+
diff --git a/lustre/ptlrpc/ptlrpc_module.c b/lustre/ptlrpc/ptlrpc_module.c
index ebfd6cedef..2ecf093c61 100644
--- a/lustre/ptlrpc/ptlrpc_module.c
+++ b/lustre/ptlrpc/ptlrpc_module.c
@@ -252,6 +252,7 @@ EXPORT_SYMBOL(ptlrpc_deactivate_import);
 EXPORT_SYMBOL(ptlrpc_invalidate_import);
 EXPORT_SYMBOL(ptlrpc_fail_import);
 EXPORT_SYMBOL(ptlrpc_recover_import);
+EXPORT_SYMBOL(ptlrpc_import_setasync);
 
 /* pinger.c */
 EXPORT_SYMBOL(ptlrpc_pinger_add_import);
-- 
GitLab