}
EXPORT_SYMBOL(class_connected_export);
-static void class_disconnect_export_list(struct list_head *list,
- enum obd_option flags)
-{
- int rc;
- struct obd_export *exp;
-
- /* It's possible that an export may disconnect itself, but
- * nothing else will be added to this list. */
- while (!list_empty(list)) {
- exp = list_entry(list->next, struct obd_export,
- exp_obd_chain);
- /* need for safe call CDEBUG after obd_disconnect */
- class_export_get(exp);
-
- spin_lock(&exp->exp_lock);
- exp->exp_flags = flags;
- spin_unlock(&exp->exp_lock);
-
- if (obd_uuid_equals(&exp->exp_client_uuid,
- &exp->exp_obd->obd_uuid)) {
- CDEBUG(D_HA,
- "exp %p export uuid == obd uuid, don't discon\n",
- exp);
- /* Need to delete this now so we don't end up pointing
- * to work_list later when this export is cleaned up. */
- list_del_init(&exp->exp_obd_chain);
- class_export_put(exp);
- continue;
- }
-
- class_export_get(exp);
- CDEBUG(D_HA, "%s: disconnecting export at %s (%p), last request at " CFS_TIME_T "\n",
- exp->exp_obd->obd_name, obd_export_nid2str(exp),
- exp, exp->exp_last_request_time);
- /* release one export reference anyway */
- rc = obd_disconnect(exp);
-
- CDEBUG(D_HA, "disconnected export at %s (%p): rc %d\n",
- obd_export_nid2str(exp), exp, rc);
- class_export_put(exp);
- }
-}
-
-void class_disconnect_exports(struct obd_device *obd)
-{
- struct list_head work_list;
-
- /* Move all of the exports from obd_exports to a work list, en masse. */
- INIT_LIST_HEAD(&work_list);
- spin_lock(&obd->obd_dev_lock);
- list_splice_init(&obd->obd_exports, &work_list);
- list_splice_init(&obd->obd_delayed_exports, &work_list);
- spin_unlock(&obd->obd_dev_lock);
-
- if (!list_empty(&work_list)) {
- CDEBUG(D_HA, "OBD device %d (%p) has exports, disconnecting them\n",
- obd->obd_minor, obd);
- class_disconnect_export_list(&work_list,
- exp_flags_from_obd(obd));
- } else
- CDEBUG(D_HA, "OBD device %d (%p) has no exports\n",
- obd->obd_minor, obd);
-}
-EXPORT_SYMBOL(class_disconnect_exports);
-
-/* Remove exports that have not completed recovery.
- */
-void class_disconnect_stale_exports(struct obd_device *obd,
- int (*test_export)(struct obd_export *))
-{
- struct list_head work_list;
- struct obd_export *exp, *n;
- int evicted = 0;
-
- INIT_LIST_HEAD(&work_list);
- spin_lock(&obd->obd_dev_lock);
- list_for_each_entry_safe(exp, n, &obd->obd_exports,
- exp_obd_chain) {
- /* don't count self-export as client */
- if (obd_uuid_equals(&exp->exp_client_uuid,
- &exp->exp_obd->obd_uuid))
- continue;
-
- /* don't evict clients which have no slot in last_rcvd
- * (e.g. lightweight connection) */
- if (exp->exp_target_data.ted_lr_idx == -1)
- continue;
-
- spin_lock(&exp->exp_lock);
- if (exp->exp_failed || test_export(exp)) {
- spin_unlock(&exp->exp_lock);
- continue;
- }
- exp->exp_failed = 1;
- spin_unlock(&exp->exp_lock);
-
- list_move(&exp->exp_obd_chain, &work_list);
- evicted++;
- CDEBUG(D_HA, "%s: disconnect stale client %s@%s\n",
- obd->obd_name, exp->exp_client_uuid.uuid,
- !exp->exp_connection ? "<unknown>" :
- libcfs_nid2str(exp->exp_connection->c_peer.nid));
- print_export_data(exp, "EVICTING", 0);
- }
- spin_unlock(&obd->obd_dev_lock);
-
- if (evicted)
- LCONSOLE_WARN("%s: disconnecting %d stale clients\n",
- obd->obd_name, evicted);
-
- class_disconnect_export_list(&work_list, exp_flags_from_obd(obd) |
- OBD_OPT_ABORT_RECOV);
-}
-EXPORT_SYMBOL(class_disconnect_stale_exports);
-
void class_fail_export(struct obd_export *exp)
{
int rc, already_failed;