* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011 Whamcloud, Inc.
- *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
EXPORT_SYMBOL(class_conn2cliimp);
/* Export management functions */
+
+/* if export is involved in recovery then clean up related things */
+void class_export_recovery_cleanup(struct obd_export *exp)
+{
+ struct obd_device *obd = exp->exp_obd;
+
+ cfs_spin_lock(&obd->obd_recovery_task_lock);
+ if (exp->exp_delayed)
+ obd->obd_delayed_clients--;
+ if (obd->obd_recovering && exp->exp_in_recovery) {
+ cfs_spin_lock(&exp->exp_lock);
+ exp->exp_in_recovery = 0;
+ cfs_spin_unlock(&exp->exp_lock);
+ LASSERT_ATOMIC_POS(&obd->obd_connected_clients);
+ cfs_atomic_dec(&obd->obd_connected_clients);
+ }
+ cfs_spin_unlock(&obd->obd_recovery_task_lock);
+ /** Cleanup req replay fields */
+ if (exp->exp_req_replay_needed) {
+ cfs_spin_lock(&exp->exp_lock);
+ exp->exp_req_replay_needed = 0;
+ cfs_spin_unlock(&exp->exp_lock);
+ LASSERT(cfs_atomic_read(&obd->obd_req_replay_clients));
+ cfs_atomic_dec(&obd->obd_req_replay_clients);
+ }
+ /** Cleanup lock replay data */
+ if (exp->exp_lock_replay_needed) {
+ cfs_spin_lock(&exp->exp_lock);
+ exp->exp_lock_replay_needed = 0;
+ cfs_spin_unlock(&exp->exp_lock);
+ LASSERT(cfs_atomic_read(&obd->obd_lock_replay_clients));
+ cfs_atomic_dec(&obd->obd_lock_replay_clients);
+ }
+}
+
static void class_export_destroy(struct obd_export *exp)
{
struct obd_device *obd = exp->exp_obd;
ENTRY;
LASSERT_ATOMIC_ZERO(&exp->exp_refcount);
+ LASSERT(obd != NULL);
CDEBUG(D_IOCTL, "destroying export %p/%s for %s\n", exp,
exp->exp_client_uuid.uuid, obd->obd_name);
- LASSERT(obd != NULL);
/* "Local" exports (lctl, LOV->{mdc,osc}) have no connection. */
if (exp->exp_connection)
LASSERT(cfs_list_empty(&exp->exp_outstanding_replies));
LASSERT(cfs_list_empty(&exp->exp_uncommitted_replies));
LASSERT(cfs_list_empty(&exp->exp_req_replay_queue));
- LASSERT(cfs_list_empty(&exp->exp_queued_rpc));
+ LASSERT(cfs_list_empty(&exp->exp_hp_rpcs));
obd_destroy_export(exp);
class_decref(obd, "export", exp);
void class_export_put(struct obd_export *exp)
{
LASSERT(exp != NULL);
- LASSERT_ATOMIC_GT_LT(&exp->exp_refcount, 0, 0x5a5a5a);
+ LASSERT_ATOMIC_GT_LT(&exp->exp_refcount, 0, LI_POISON);
CDEBUG(D_INFO, "PUTting export %p : new refcount %d\n", exp,
cfs_atomic_read(&exp->exp_refcount) - 1);
/* release nid stat refererence */
lprocfs_exp_cleanup(exp);
+ class_export_recovery_cleanup(exp);
obd_zombie_export_add(exp);
}
CFS_INIT_LIST_HEAD(&export->exp_uncommitted_replies);
CFS_INIT_LIST_HEAD(&export->exp_req_replay_queue);
CFS_INIT_LIST_HEAD(&export->exp_handle.h_link);
- CFS_INIT_LIST_HEAD(&export->exp_queued_rpc);
+ CFS_INIT_LIST_HEAD(&export->exp_hp_rpcs);
class_handle_hash(&export->exp_handle, export_handle_addref);
export->exp_last_request_time = cfs_time_current_sec();
cfs_spin_lock_init(&export->exp_lock);
cfs_spin_lock_init(&export->exp_rpc_lock);
CFS_INIT_HLIST_NODE(&export->exp_uuid_hash);
CFS_INIT_HLIST_NODE(&export->exp_nid_hash);
+ cfs_spin_lock_init(&export->exp_bl_list_lock);
+ CFS_INIT_LIST_HEAD(&export->exp_bl_list);
export->exp_sp_peer = LUSTRE_SP_ANY;
export->exp_flvr.sf_rpc = SPTLRPC_FLVR_INVALID;
ENTRY;
LASSERT(cfs_list_empty(&imp->imp_zombie_chain));
- LASSERT_ATOMIC_GE_LT(&imp->imp_refcount, 0, 0x5a5a5a);
+ LASSERT_ATOMIC_GT_LT(&imp->imp_refcount, 0, LI_POISON);
CDEBUG(D_INFO, "import %p refcount=%d obd=%s\n", imp,
cfs_atomic_read(&imp->imp_refcount) - 1,
imp->imp_last_success_conn = 0;
imp->imp_state = LUSTRE_IMP_NEW;
imp->imp_obd = class_incref(obd, "import", imp);
- cfs_sema_init(&imp->imp_sec_mutex, 1);
+ cfs_mutex_init(&imp->imp_sec_mutex);
cfs_waitq_init(&imp->imp_recovery_waitq);
cfs_atomic_set(&imp->imp_refcount, 2);
}
EXPORT_SYMBOL(class_connect);
-/* if export is involved in recovery then clean up related things */
-void class_export_recovery_cleanup(struct obd_export *exp)
-{
- struct obd_device *obd = exp->exp_obd;
-
- cfs_spin_lock(&obd->obd_recovery_task_lock);
- if (exp->exp_delayed)
- obd->obd_delayed_clients--;
- if (obd->obd_recovering && exp->exp_in_recovery) {
- cfs_spin_lock(&exp->exp_lock);
- exp->exp_in_recovery = 0;
- cfs_spin_unlock(&exp->exp_lock);
- LASSERT_ATOMIC_POS(&obd->obd_connected_clients);
- cfs_atomic_dec(&obd->obd_connected_clients);
- }
- cfs_spin_unlock(&obd->obd_recovery_task_lock);
- /** Cleanup req replay fields */
- if (exp->exp_req_replay_needed) {
- cfs_spin_lock(&exp->exp_lock);
- exp->exp_req_replay_needed = 0;
- cfs_spin_unlock(&exp->exp_lock);
- LASSERT(cfs_atomic_read(&obd->obd_req_replay_clients));
- cfs_atomic_dec(&obd->obd_req_replay_clients);
- }
- /** Cleanup lock replay data */
- if (exp->exp_lock_replay_needed) {
- cfs_spin_lock(&exp->exp_lock);
- exp->exp_lock_replay_needed = 0;
- cfs_spin_unlock(&exp->exp_lock);
- LASSERT(cfs_atomic_read(&obd->obd_lock_replay_clients));
- cfs_atomic_dec(&obd->obd_lock_replay_clients);
- }
-}
/* This function removes 1-3 references from the export:
* 1 - for export pointer passed
&export->exp_connection->c_peer.nid,
&export->exp_nid_hash);
- class_export_recovery_cleanup(export);
class_unlink_export(export);
no_disconn:
class_export_put(export);
CFS_INIT_LIST_HEAD(&work_list);
cfs_spin_lock(&obd->obd_dev_lock);
cfs_list_for_each_safe(pos, n, &obd->obd_exports) {
+ int failed;
+
exp = cfs_list_entry(pos, struct obd_export, exp_obd_chain);
- if (test_export(exp))
- continue;
/* don't count self-export as client */
if (obd_uuid_equals(&exp->exp_client_uuid,
&exp->exp_obd->obd_uuid))
continue;
+ if (test_export(exp))
+ continue;
+
+ cfs_spin_lock(&exp->exp_lock);
+ failed = exp->exp_failed;
+ exp->exp_failed = 1;
+ cfs_spin_unlock(&exp->exp_lock);
+ if (failed)
+ continue;
+
cfs_list_move(&exp->exp_obd_chain, &work_list);
evicted++;
CDEBUG(D_ERROR, "%s: disconnect stale client %s@%s\n",
if (obd_dump_on_timeout)
libcfs_debug_dumplog();
+ /* need for safe call CDEBUG after obd_disconnect */
+ class_export_get(exp);
+
/* Most callers into obd_disconnect are removing their own reference
* (request, for example) in addition to the one from the hash table.
* We don't have such a reference here, so make one. */
else
CDEBUG(D_HA, "disconnected export %p/%s\n",
exp, exp->exp_client_uuid.uuid);
+ class_export_put(exp);
}
EXPORT_SYMBOL(class_fail_export);