1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
8 #include <lustre_handles.h>
9 #include <lustre/lustre_idl.h>
12 /* Adaptive Timeout stuff */
13 #define D_ADAPTTO D_OTHER
14 #define AT_BINS 4 /* "bin" means "N seconds of history" */
15 #define AT_FLG_NOHIST 0x1 /* use last reported value only */
16 #define AT_FLG_MIN 0x2 /* use a minimum limit */
18 struct adaptive_timeout {
19 time_t at_binstart; /* bin start time */
20 unsigned int at_hist[AT_BINS]; /* timeout history bins */
21 unsigned int at_flags;
22 unsigned int at_current; /* current timeout value */
23 unsigned int at_worst_ever; /* worst-ever timeout value */
24 time_t at_worst_time; /* worst-ever timeout timestamp */
28 enum lustre_imp_state {
29 LUSTRE_IMP_CLOSED = 1,
31 LUSTRE_IMP_DISCON = 3,
32 LUSTRE_IMP_CONNECTING = 4,
33 LUSTRE_IMP_REPLAY = 5,
34 LUSTRE_IMP_REPLAY_LOCKS = 6,
35 LUSTRE_IMP_REPLAY_WAIT = 7,
36 LUSTRE_IMP_RECOVER = 8,
38 LUSTRE_IMP_EVICTED = 10,
41 static inline char * ptlrpc_import_state_name(enum lustre_imp_state state)
43 static char* import_state_names[] = {
44 "<UNKNOWN>", "CLOSED", "NEW", "DISCONN",
45 "CONNECTING", "REPLAY", "REPLAY_LOCKS", "REPLAY_WAIT",
46 "RECOVER", "FULL", "EVICTED",
49 LASSERT (state <= LUSTRE_IMP_EVICTED);
50 return import_state_names[state];
53 enum obd_import_event {
54 IMP_EVENT_DISCON = 0x808001,
55 IMP_EVENT_INACTIVE = 0x808002,
56 IMP_EVENT_INVALIDATE = 0x808003,
57 IMP_EVENT_ACTIVE = 0x808004,
58 IMP_EVENT_OCD = 0x808005,
61 struct obd_import_conn {
62 struct list_head oic_item;
63 struct ptlrpc_connection *oic_conn;
64 struct obd_uuid oic_uuid;
65 __u64 oic_last_attempt; /* jiffies, 64-bit */
68 #define IMP_AT_MAX_PORTALS 4
70 int iat_portal[IMP_AT_MAX_PORTALS];
71 struct adaptive_timeout iat_net_latency;
72 struct adaptive_timeout iat_service_estimate[IMP_AT_MAX_PORTALS];
73 time_t iat_drain; /* hack to slow reconnect reqs */
77 struct portals_handle imp_handle;
78 atomic_t imp_refcount;
79 struct lustre_handle imp_dlm_handle; /* client's ldlm export */
80 struct ptlrpc_connection *imp_connection;
81 struct ptlrpc_client *imp_client;
82 struct list_head imp_pinger_chain;
83 struct list_head imp_zombie_chain; /* queue for destruction */
85 /* Lists of requests that are retained for replay, waiting for a reply,
86 * or waiting for recovery to complete, respectively.
88 struct list_head imp_replay_list;
89 struct list_head imp_sending_list;
90 struct list_head imp_delayed_list;
92 struct obd_device *imp_obd;
93 cfs_waitq_t imp_recovery_waitq;
95 atomic_t imp_inflight;
96 atomic_t imp_replay_inflight;
97 atomic_t imp_inval_count;
98 enum lustre_imp_state imp_state;
101 int imp_last_generation_checked;
102 __u64 imp_last_replay_transno;
103 __u64 imp_peer_committed_transno;
104 __u64 imp_last_transno_checked;
105 struct lustre_handle imp_remote_handle;
106 cfs_time_t imp_next_ping; /* jiffies */
107 __u64 imp_last_success_conn; /* jiffies, 64-bit */
109 /* all available obd_import_conn linked here */
110 struct list_head imp_conn_list;
111 struct obd_import_conn *imp_conn_current;
113 /* Protects flags, level, generation, conn_cnt, *_list */
117 unsigned int imp_invalid:1, /* evicted */
118 imp_deactive:1, /* administratively disabled */
119 imp_replayable:1, /* try to recover the import */
120 imp_dlm_fake:1, /* don't run recovery (timeout instead) */
121 imp_server_timeout:1, /* use 1/2 timeout on MDS' OSCs */
122 imp_initial_recov:1, /* retry the initial connection */
123 imp_initial_recov_bk:1, /* turn off init_recov after trying all failover nids */
124 imp_force_verify:1, /* force an immidiate ping */
125 imp_pingable:1, /* pingable */
126 imp_resend_replay:1, /* resend for replay */
127 imp_recon_bk:1, /* turn off reconnect if all failovers fail */
128 imp_last_recon:1; /* internally used by above */
129 __u32 imp_connect_op;
130 struct obd_connect_data imp_connect_data;
131 __u64 imp_connect_flags_orig;
134 __u32 imp_msg_flags; /* adjusted based on server capability */
136 struct ptlrpc_request_pool *imp_rq_pool; /* emergency request pool */
138 struct imp_at imp_at; /* adaptive timeout data */
139 time_t imp_last_reply_time; /* for health check */
143 static inline void at_init(struct adaptive_timeout *at, int val, int flags) {
144 memset(at, 0, sizeof(*at));
145 at->at_current = val;
146 at->at_worst_ever = val;
147 at->at_worst_time = cfs_time_current_sec();
148 at->at_flags = flags;
149 spin_lock_init(&at->at_lock);
151 static inline int at_get(struct adaptive_timeout *at) {
152 extern unsigned int adaptive_timeout_max;
153 if (adaptive_timeout_max)
154 return min(at->at_current, adaptive_timeout_max);
155 return at->at_current;
157 int at_add(struct adaptive_timeout *at, unsigned int val);
158 int import_at_get_index(struct obd_import *imp, int portal);
159 int import_at_get_ldlm(struct obd_import *imp);
160 #define AT_OFF (adaptive_timeout_max == 0)
164 extern struct obd_import *class_exp2cliimp(struct obd_export *);
165 extern struct obd_import *class_conn2cliimp(struct lustre_handle *);
167 #endif /* __IMPORT_H */