+static void forcibly_detach_exports(struct obd_device *obd)
+{
+ int rc;
+ struct list_head *tmp, *n;
+ struct lustre_handle fake_conn;
+
+ CDEBUG(D_IOCTL, "OBD device %d (%p) has exports, "
+ "disconnecting them", obd->obd_minor, obd);
+ list_for_each_safe(tmp, n, &obd->obd_exports) {
+ struct obd_export *exp = list_entry(tmp, struct obd_export,
+ exp_obd_chain);
+ fake_conn.addr = (__u64)(unsigned long)exp;
+ fake_conn.cookie = exp->exp_cookie;
+ rc = obd_disconnect(&fake_conn);
+ if (rc) {
+ CDEBUG(D_IOCTL, "disconnecting export %p failed: %d\n",
+ exp, rc);
+ } else {
+ CDEBUG(D_IOCTL, "export %p disconnected\n", exp);
+ }
+ }
+}