Whamcloud - gitweb
Fix the connection refcount leaks. There were actually 3 separate bugs.
authorpschwan <pschwan>
Sat, 19 Oct 2002 09:12:24 +0000 (09:12 +0000)
committerpschwan <pschwan>
Sat, 19 Oct 2002 09:12:24 +0000 (09:12 +0000)
lustre/include/linux/obd_class.h
lustre/ldlm/ldlm_lock.c
lustre/ldlm/ldlm_lockd.c
lustre/lib/client.c
lustre/obdclass/class_obd.c
lustre/obdclass/genops.c
lustre/ptlrpc/rpc.c

index 9e0e60b..f83acf7 100644 (file)
@@ -753,6 +753,12 @@ static inline int obdo_cmp_md(struct obdo *dst, struct obdo *src,
 
 
 #ifdef __KERNEL__
+/* I'm as embarrassed about this as you are.
+ *
+ * <shaver> // XXX do not look into _superhack with remaining eye
+ * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */ 
+extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
+
 int class_register_type(struct obd_ops *ops, char *nm);
 int class_unregister_type(char *nm);
 int class_name2dev(char *name);
index 8673d6a..b6df7fe 100644 (file)
@@ -211,6 +211,8 @@ void ldlm_lock_destroy(struct ldlm_lock *lock)
         lock->l_flags |= LDLM_FL_DESTROYED;
 
         /* Wake anyone waiting for this lock */
+        /* FIXME: I should probably add yet another flag, instead of using
+         * l_export to only call this on clients */
         if (lock->l_export && lock->l_completion_ast)
                 lock->l_completion_ast(lock, 0);
 
index 9873e0e..1f7b0dd 100644 (file)
@@ -273,7 +273,6 @@ int ldlm_handle_enqueue(struct ptlrpc_request *req)
                 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
         }
 
-        ptlrpc_connection_addref(req->rq_connection);
         EXIT;
  out:
         if (lock)
index 59116eb..1f596e8 100644 (file)
@@ -103,10 +103,10 @@ int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf)
 
 int client_obd_cleanup(struct obd_device * obddev)
 {
-        struct client_obd *mdc = &obddev->u.cli;
+        struct client_obd *obd = &obddev->u.cli;
 
-        ptlrpc_cleanup_client(&mdc->cl_import);
-        ptlrpc_put_connection(mdc->cl_import.imp_connection);
+        ptlrpc_cleanup_client(&obd->cl_import);
+        ptlrpc_put_connection(obd->cl_import.imp_connection);
 
         MOD_DEC_USE_COUNT;
         return 0;
@@ -149,7 +149,8 @@ int client_obd_connect(struct lustre_handle *conn, struct obd_device *obd,
         request->rq_replen = lustre_msg_size(0, NULL);
         request->rq_reqmsg->addr = conn->addr;
         request->rq_reqmsg->cookie = conn->cookie;
-        c = class_conn2export(conn)->exp_connection = request->rq_connection;
+        c = class_conn2export(conn)->exp_connection =
+                ptlrpc_connection_addref(request->rq_connection);
         recovd_conn_manage(c, recovd, recover);
 
         rc = ptlrpc_queue_wait(request);
index be7f50b..95a8f79 100644 (file)
@@ -1041,6 +1041,7 @@ EXPORT_SYMBOL(obd_memory);
 EXPORT_SYMBOL(obd_fail_loc);
 EXPORT_SYMBOL(obd_timeout);
 EXPORT_SYMBOL(obd_recovery_upcall);
+EXPORT_SYMBOL(ptlrpc_put_connection_superhack);
 
 EXPORT_SYMBOL(class_register_type);
 EXPORT_SYMBOL(class_unregister_type);
index 7bb7945..487c932 100644 (file)
@@ -25,6 +25,8 @@ kmem_cache_t *import_cachep = NULL;
 kmem_cache_t *export_cachep = NULL;
 kmem_cache_t *handle_cachep = NULL;
 
+int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
+
 /* I would prefer if these next four functions were in ptlrpc, to be honest,
  * but obdclass uses them for the netregression ioctls. -phil */
 static int sync_io_timeout(void *data)
@@ -390,6 +392,8 @@ void class_destroy_export(struct obd_export *exp)
 {
         ENTRY;
 
+        LASSERT(exp->exp_cookie != DEAD_HANDLE_MAGIC);
+
         spin_lock(&exp->exp_obd->obd_dev_lock);
         list_del(&exp->exp_obd_chain);
         spin_unlock(&exp->exp_obd->obd_dev_lock);
@@ -400,7 +404,7 @@ void class_destroy_export(struct obd_export *exp)
         list_del(&exp->exp_conn_chain);
         if (exp->exp_connection) {
                 spin_unlock(&exp->exp_connection->c_lock);
-                //ptlrpc_put_connection(exp->exp_connection);
+                ptlrpc_put_connection_superhack(exp->exp_connection);
         }
 
         exp->exp_cookie = DEAD_HANDLE_MAGIC;
index 25d6449..98be8ca 100644 (file)
@@ -178,6 +178,7 @@ static int __init ptlrpc_init(void)
                 RETURN(rc);
         ptlrpc_init_connection();
         class_register_type(&recovd_obd_ops, LUSTRE_HA_NAME);
+        ptlrpc_put_connection_superhack = ptlrpc_put_connection;
         return 0;
 }