1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001 Cluster File Systems, Inc.
6 * This code is issued under the GNU General Public License.
7 * See the file COPYING in this distribution
13 #include <linux/lustre_handles.h>
14 #include <linux/lustre_idl.h>
16 enum lustre_imp_state {
17 LUSTRE_IMP_CLOSED = 1,
19 LUSTRE_IMP_DISCON = 3,
20 LUSTRE_IMP_CONNECTING = 4,
21 LUSTRE_IMP_REPLAY = 5,
22 LUSTRE_IMP_REPLAY_LOCKS = 6,
23 LUSTRE_IMP_REPLAY_WAIT = 7,
24 LUSTRE_IMP_RECOVER = 8,
26 LUSTRE_IMP_EVICTED = 10,
29 static inline char * ptlrpc_import_state_name(enum lustre_imp_state state)
32 static char* import_state_names[] = {
33 "<UNKNOWN>", "CLOSED", "NEW", "DISCONN",
34 "CONNECTING", "REPLAY", "REPLAY_LOCKS", "REPLAY_WAIT",
35 "RECOVER", "FULL", "EVICTED",
38 LASSERT (state <= LUSTRE_IMP_EVICTED);
39 return import_state_names[state];
42 enum obd_import_event {
43 IMP_EVENT_DISCON = 0x808001,
44 IMP_EVENT_INACTIVE = 0x808002,
45 IMP_EVENT_INVALIDATE = 0x808003,
46 IMP_EVENT_ACTIVE = 0x808004,
49 struct obd_import_conn {
50 struct list_head oic_item;
51 struct ptlrpc_connection *oic_conn;
52 struct obd_uuid oic_uuid;
53 unsigned long oic_last_attempt; /* in jiffies */
58 struct portals_handle imp_handle;
59 atomic_t imp_refcount;
60 struct lustre_handle imp_dlm_handle; /* client's ldlm export */
61 struct ptlrpc_connection *imp_connection;
62 struct ptlrpc_client *imp_client;
63 struct list_head imp_observers;
64 struct list_head imp_pinger_chain;
66 /* Lists of requests that are retained for replay, waiting for a reply,
67 * or waiting for recovery to complete, respectively.
69 struct list_head imp_replay_list;
70 struct list_head imp_sending_list;
71 struct list_head imp_delayed_list;
73 struct obd_device *imp_obd;
74 wait_queue_head_t imp_recovery_waitq;
75 __u64 imp_last_replay_transno;
76 atomic_t imp_inflight;
77 atomic_t imp_replay_inflight;
78 enum lustre_imp_state imp_state;
81 __u64 imp_max_transno;
82 __u64 imp_peer_committed_transno;
83 struct obd_uuid imp_target_uuid; /* XXX -> lustre_name */
84 struct lustre_handle imp_remote_handle;
85 unsigned long imp_next_ping;
86 unsigned long imp_connect_start;
88 /* all available obd_import_conn linked here */
89 struct list_head imp_conn_list;
90 struct obd_import_conn *imp_conn_current;
92 /* Protects flags, level, generation, conn_cnt, *_list */
96 int imp_invalid:1, imp_replayable:1,
97 imp_dlm_fake:1, imp_server_timeout:1,
98 imp_initial_recov:1, imp_force_verify:1,
99 imp_pingable:1, imp_resend_replay:1;
100 __u32 imp_connect_op;
101 __u32 imp_connect_flags;
104 typedef void (*obd_import_callback)(struct obd_import *imp, void *closure,
105 int event, void *event_arg, void *cb_data);
107 struct obd_import_observer {
108 struct list_head oio_chain;
109 obd_import_callback oio_cb;
113 void class_observe_import(struct obd_import *imp, obd_import_callback cb,
115 void class_unobserve_import(struct obd_import *imp, obd_import_callback cb,
117 void class_notify_import_observers(struct obd_import *imp, int event,
120 #define IMP_EVENT_ACTIVE 1
121 #define IMP_EVENT_INACTIVE 2
125 extern struct obd_import *class_exp2cliimp(struct obd_export *);
126 extern struct obd_import *class_conn2cliimp(struct lustre_handle *);
128 #endif /* __IMPORT_H */