Whamcloud - gitweb
Defensive check to avoid re-freeing export during force cleanup.
[fs/lustre-release.git] / lustre / obdclass / genops.c
index 52091d4..3bac4a3 100644 (file)
@@ -438,6 +438,11 @@ void __class_export_put(struct obd_export *exp)
                 if (obd->obd_set_up) {
                         atomic_dec(&obd->obd_refcount);
                         wake_up(&obd->obd_refcount_waitq);
+                } else {
+                        CERROR("removing export %p from obd %s (%p) -- OBD "
+                               "not set up (refcount = %d)\n", exp,
+                               obd->obd_name, obd,
+                               atomic_read(&obd->obd_refcount));
                 }
         }
 }
@@ -457,6 +462,7 @@ struct obd_export *class_new_export(struct obd_device *obd)
 
         export->exp_conn_cnt = 0;
         atomic_set(&export->exp_refcount, 2);
+        atomic_set(&export->exp_rpc_count, 0);
         export->exp_obd = obd;
         INIT_LIST_HEAD(&export->exp_outstanding_replies);
         /* XXX this should be in LDLM init */
@@ -619,8 +625,12 @@ int class_disconnect(struct obd_export *export, int flags)
         CDEBUG(D_IOCTL, "disconnect: cookie "LPX64"\n",
                export->exp_handle.h_cookie);
 
-        class_unlink_export(export);
-        class_export_put(export);
+        if (export->exp_handle.h_cookie == 0x5a5a5a5a5a5a5a5a) {
+                CERROR("disconnecting freed export %p, ignoring\n", export);
+        } else {
+                class_unlink_export(export);
+                class_export_put(export);
+        }
         RETURN(0);
 }