Whamcloud - gitweb
land b1_5 onto HEAD
[fs/lustre-release.git] / lustre / ptlrpc / ptlrpc_module.c
index 6aac960..7eb5a5d 100644 (file)
@@ -3,20 +3,23 @@
  *
  *  Copyright (c) 2002, 2003 Cluster File Systems, Inc.
  *
- *   This file is part of Lustre, http://www.lustre.org.
+ *   This file is part of the Lustre file system, http://www.lustre.org
+ *   Lustre is a trademark of Cluster File Systems, Inc.
  *
- *   Lustre is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
+ *   You may have signed or agreed to another license before downloading
+ *   this software.  If so, you are bound by the terms and conditions
+ *   of that agreement, and the following does not apply to you.  See the
+ *   LICENSE file included with this distribution for more information.
  *
- *   Lustre is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
+ *   If you did not agree to a different license, then this copy of Lustre
+ *   is open source software; you can redistribute it and/or modify it
+ *   under the terms of version 2 of the GNU General Public License as
+ *   published by the Free Software Foundation.
  *
- *   You should have received a copy of the GNU General Public License
- *   along with Lustre; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *   In either case, Lustre is distributed in the hope that it will be
+ *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   license text for more details.
  *
  */
 
 #endif
 #define DEBUG_SUBSYSTEM S_RPC
 
-#ifdef __KERNEL__
-# include <linux/module.h>
-# include <linux/init.h>
-#else
+#ifndef __KERNEL__
 # include <liblustre.h>
 #endif
 
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_net.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <lustre_net.h>
 
 #include "ptlrpc_internal.h"
 
+extern spinlock_t ptlrpc_last_xid_lock;
+extern spinlock_t ptlrpc_rs_debug_lock;
+extern spinlock_t ptlrpc_all_services_lock;
+extern struct semaphore pinger_sem;
+extern struct semaphore ptlrpcd_sem;
 extern int ptlrpc_init_portals(void);
 extern void ptlrpc_exit_portals(void);
 
 __init int ptlrpc_init(void)
 {
-        int rc;
+        int rc, cleanup_phase = 0;
         ENTRY;
 
         lustre_assert_wire_constants();
+        spin_lock_init(&ptlrpc_last_xid_lock);
+        spin_lock_init(&ptlrpc_rs_debug_lock);
+        spin_lock_init(&ptlrpc_all_services_lock);
+        init_mutex(&pinger_sem);
+        init_mutex(&ptlrpcd_sem);
 
         rc = ptlrpc_init_portals();
         if (rc)
                 RETURN(rc);
+        cleanup_phase = 1;
 
         ptlrpc_init_connection();
-        llog_init_commit_master();
+        rc = llog_init_commit_master();
+        if (rc)
+                GOTO(cleanup, rc);
+        cleanup_phase = 2;
 
         ptlrpc_put_connection_superhack = ptlrpc_put_connection;
-        ptlrpc_abort_inflight_superhack = ptlrpc_abort_inflight;
 
-        ptlrpc_start_pinger();
-        ldlm_init();
+        rc = ptlrpc_start_pinger();
+        if (rc)
+                GOTO(cleanup, rc);
+        cleanup_phase = 3;
+
+        rc = ldlm_init();
+        if (rc)
+                GOTO(cleanup, rc);
         RETURN(0);
+
+cleanup:
+        switch(cleanup_phase) {
+        case 3:
+                ptlrpc_stop_pinger();
+        case 2:
+                llog_cleanup_commit_master(1);
+                ptlrpc_cleanup_connection();
+        case 1:
+                ptlrpc_exit_portals();
+        default: ;
+        }
+
+        return rc;
 }
 
 #ifdef __KERNEL__
@@ -92,9 +125,6 @@ EXPORT_SYMBOL(ptlrpc_reply);
 EXPORT_SYMBOL(ptlrpc_error);
 EXPORT_SYMBOL(ptlrpc_resend_req);
 EXPORT_SYMBOL(ptl_send_rpc);
-EXPORT_SYMBOL(ptl_do_rawrpc);
-EXPORT_SYMBOL(ptl_do_rawrpc_simple);
-EXPORT_SYMBOL(rawrpc_req_finished);
 
 /* client.c */
 EXPORT_SYMBOL(ptlrpc_init_client);
@@ -103,6 +133,10 @@ EXPORT_SYMBOL(ptlrpc_uuid_to_connection);
 EXPORT_SYMBOL(ptlrpc_queue_wait);
 EXPORT_SYMBOL(ptlrpc_replay_req);
 EXPORT_SYMBOL(ptlrpc_restart_req);
+EXPORT_SYMBOL(ptlrpc_add_rqs_to_pool);
+EXPORT_SYMBOL(ptlrpc_init_rq_pool);
+EXPORT_SYMBOL(ptlrpc_free_rq_pool);
+EXPORT_SYMBOL(ptlrpc_prep_req_pool);
 EXPORT_SYMBOL(ptlrpc_prep_req);
 EXPORT_SYMBOL(ptlrpc_free_req);
 EXPORT_SYMBOL(ptlrpc_unregister_reply);
@@ -128,37 +162,26 @@ EXPORT_SYMBOL(ptlrpc_expired_set);
 EXPORT_SYMBOL(ptlrpc_interrupted_set);
 EXPORT_SYMBOL(ptlrpc_mark_interrupted);
 
-/* import.c */
-EXPORT_SYMBOL(ptlrpc_deactivate_import);
-EXPORT_SYMBOL(ptlrpc_invalidate_import);
-EXPORT_SYMBOL(ptlrpc_activate_import);
-EXPORT_SYMBOL(ptlrpc_fail_import);
-EXPORT_SYMBOL(ptlrpc_disconnect_import);
-EXPORT_SYMBOL(ptlrpc_import_control_recovery);
-
 /* service.c */
-EXPORT_SYMBOL(ptlrpc_require_repack);
 EXPORT_SYMBOL(ptlrpc_save_lock);
-EXPORT_SYMBOL(ptlrpc_save_llog_lock);
 EXPORT_SYMBOL(ptlrpc_schedule_difficult_reply);
 EXPORT_SYMBOL(ptlrpc_commit_replies);
 EXPORT_SYMBOL(ptlrpc_init_svc);
 EXPORT_SYMBOL(ptlrpc_stop_all_threads);
-EXPORT_SYMBOL(ptlrpc_start_n_threads);
+EXPORT_SYMBOL(ptlrpc_start_threads);
 EXPORT_SYMBOL(ptlrpc_start_thread);
 EXPORT_SYMBOL(ptlrpc_unregister_service);
 EXPORT_SYMBOL(ptlrpc_daemonize);
+EXPORT_SYMBOL(ptlrpc_service_health_check);
 
 /* pack_generic.c */
 EXPORT_SYMBOL(lustre_msg_swabbed);
 EXPORT_SYMBOL(lustre_msg_check_version);
-EXPORT_SYMBOL(lustre_secdesc_size);
-EXPORT_SYMBOL(lustre_pack_secdesc);
 EXPORT_SYMBOL(lustre_pack_request);
 EXPORT_SYMBOL(lustre_pack_reply);
+EXPORT_SYMBOL(lustre_shrink_reply);
 EXPORT_SYMBOL(lustre_free_reply_state);
 EXPORT_SYMBOL(lustre_msg_size);
-EXPORT_SYMBOL(lustre_init_msg);
 EXPORT_SYMBOL(lustre_unpack_msg);
 EXPORT_SYMBOL(lustre_msg_buf);
 EXPORT_SYMBOL(lustre_msg_string);
@@ -172,24 +195,19 @@ EXPORT_SYMBOL(lustre_swab_niobuf_remote);
 EXPORT_SYMBOL(lustre_swab_ost_body);
 EXPORT_SYMBOL(lustre_swab_ost_last_id);
 EXPORT_SYMBOL(lustre_swab_ost_lvb);
-EXPORT_SYMBOL(lustre_swab_generic_32s);
-EXPORT_SYMBOL(lustre_swab_lustre_id);
-EXPORT_SYMBOL(lustre_swab_lustre_stc);
-EXPORT_SYMBOL(lustre_swab_lustre_fid);
-EXPORT_SYMBOL(lustre_swab_parseid_pkg);
-EXPORT_SYMBOL(lustre_swab_audit_msg);
-EXPORT_SYMBOL(lustre_swab_audit_attr);
 EXPORT_SYMBOL(lustre_swab_mds_status_req);
-EXPORT_SYMBOL(lustre_swab_mds_secdesc);
-EXPORT_SYMBOL(lustre_swab_remote_perm);
 EXPORT_SYMBOL(lustre_swab_mds_body);
+EXPORT_SYMBOL(lustre_swab_obd_quotactl);
 EXPORT_SYMBOL(lustre_swab_mds_rec_setattr);
 EXPORT_SYMBOL(lustre_swab_mds_rec_create);
+EXPORT_SYMBOL(lustre_swab_mds_rec_join);
 EXPORT_SYMBOL(lustre_swab_mds_rec_link);
 EXPORT_SYMBOL(lustre_swab_mds_rec_unlink);
 EXPORT_SYMBOL(lustre_swab_mds_rec_rename);
 EXPORT_SYMBOL(lustre_swab_lov_desc);
-EXPORT_SYMBOL(lustre_swab_fid_extent);
+EXPORT_SYMBOL(lustre_swab_lov_user_md);
+EXPORT_SYMBOL(lustre_swab_lov_user_md_objects);
+EXPORT_SYMBOL(lustre_swab_lov_user_md_join);
 EXPORT_SYMBOL(lustre_swab_ldlm_res_id);
 EXPORT_SYMBOL(lustre_swab_ldlm_policy_data);
 EXPORT_SYMBOL(lustre_swab_ldlm_intent);
@@ -197,27 +215,45 @@ EXPORT_SYMBOL(lustre_swab_ldlm_resource_desc);
 EXPORT_SYMBOL(lustre_swab_ldlm_lock_desc);
 EXPORT_SYMBOL(lustre_swab_ldlm_request);
 EXPORT_SYMBOL(lustre_swab_ldlm_reply);
-EXPORT_SYMBOL(lustre_swab_ptlbd_op);
-EXPORT_SYMBOL(lustre_swab_ptlbd_niob);
-EXPORT_SYMBOL(lustre_swab_ptlbd_rsp);
-EXPORT_SYMBOL(lustre_swab_lustre_capa);
-EXPORT_SYMBOL(lustre_swab_lustre_capa_key);
-EXPORT_SYMBOL(lustre_swab_key_context);
-EXPORT_SYMBOL(lustre_swab_key_perms);
-EXPORT_SYMBOL(mdc_create_pack);
-EXPORT_SYMBOL(mdc_setattr_pack);
-EXPORT_SYMBOL(mdc_unlink_pack);
-EXPORT_SYMBOL(mdc_link_pack);
-EXPORT_SYMBOL(mdc_rename_pack);
-EXPORT_SYMBOL(mds_pack_open_flags);
+EXPORT_SYMBOL(lustre_swab_qdata);
+EXPORT_SYMBOL(lustre_swab_qdata_old);
+EXPORT_SYMBOL(lustre_msg_get_flags);
+EXPORT_SYMBOL(lustre_msg_add_flags);
+EXPORT_SYMBOL(lustre_msg_set_flags);
+EXPORT_SYMBOL(lustre_msg_clear_flags);
+EXPORT_SYMBOL(lustre_msg_get_op_flags);
+EXPORT_SYMBOL(lustre_msg_add_op_flags);
+EXPORT_SYMBOL(lustre_msg_set_op_flags);
+EXPORT_SYMBOL(lustre_msg_get_handle );
+EXPORT_SYMBOL(lustre_msg_get_type);
+EXPORT_SYMBOL(lustre_msg_get_version);
+EXPORT_SYMBOL(lustre_msg_add_version);
+EXPORT_SYMBOL(lustre_msg_get_opc);
+EXPORT_SYMBOL(lustre_msg_get_last_xid);
+EXPORT_SYMBOL(lustre_msg_get_last_committed);
+EXPORT_SYMBOL(lustre_msg_get_transno);
+EXPORT_SYMBOL(lustre_msg_get_status);
+EXPORT_SYMBOL(lustre_msg_get_conn_cnt);
+EXPORT_SYMBOL(lustre_msg_get_magic);
+EXPORT_SYMBOL(lustre_msg_set_handle);
+EXPORT_SYMBOL(lustre_msg_set_type);
+EXPORT_SYMBOL(lustre_msg_set_opc);
+EXPORT_SYMBOL(lustre_msg_set_last_xid);
+EXPORT_SYMBOL(lustre_msg_set_last_committed);
+EXPORT_SYMBOL(lustre_msg_set_transno);
+EXPORT_SYMBOL(lustre_msg_set_status);
+EXPORT_SYMBOL(lustre_msg_set_conn_cnt);
+EXPORT_SYMBOL(lustre_swab_mgs_target_info);
 
 /* recover.c */
-EXPORT_SYMBOL(ptlrpc_run_recovery_over_upcall);
-EXPORT_SYMBOL(ptlrpc_run_failed_import_upcall);
+EXPORT_SYMBOL(ptlrpc_disconnect_import);
 EXPORT_SYMBOL(ptlrpc_resend);
 EXPORT_SYMBOL(ptlrpc_wake_delayed);
 EXPORT_SYMBOL(ptlrpc_set_import_active);
-EXPORT_SYMBOL(ptlrpc_fail_export);
+EXPORT_SYMBOL(ptlrpc_activate_import);
+EXPORT_SYMBOL(ptlrpc_deactivate_import);
+EXPORT_SYMBOL(ptlrpc_invalidate_import);
+EXPORT_SYMBOL(ptlrpc_fail_import);
 EXPORT_SYMBOL(ptlrpc_recover_import);
 
 /* pinger.c */
@@ -231,14 +267,11 @@ EXPORT_SYMBOL(ptlrpcd_decref);
 EXPORT_SYMBOL(ptlrpcd_add_req);
 EXPORT_SYMBOL(ptlrpcd_wake);
 
-/* lproc_ptlrpc.c */
-EXPORT_SYMBOL(ptlrpc_lprocfs_register_obd);
-EXPORT_SYMBOL(ptlrpc_lprocfs_unregister_obd);
-
 /* llogd.c */
-EXPORT_SYMBOL(llog_origin_handle_open);
-EXPORT_SYMBOL(llog_origin_handle_prev_block);
+EXPORT_SYMBOL(llog_origin_handle_create);
+EXPORT_SYMBOL(llog_origin_handle_destroy);
 EXPORT_SYMBOL(llog_origin_handle_next_block);
+EXPORT_SYMBOL(llog_origin_handle_prev_block);
 EXPORT_SYMBOL(llog_origin_handle_read_header);
 EXPORT_SYMBOL(llog_origin_handle_close);
 EXPORT_SYMBOL(llog_client_ops);
@@ -248,6 +281,5 @@ MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
 MODULE_DESCRIPTION("Lustre Request Processor and Lock Management");
 MODULE_LICENSE("GPL");
 
-module_init(ptlrpc_init);
-module_exit(ptlrpc_exit);
+cfs_module(ptlrpc, "1.0.0", ptlrpc_init, ptlrpc_exit);
 #endif