Whamcloud - gitweb
use special macro for print time_t, cleanup in includes.
[fs/lustre-release.git] / lustre / include / lustre_import.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  */
4
5 #ifndef __IMPORT_H
6 #define __IMPORT_H
7
8 #include <lustre_handles.h>
9 #include <lustre/lustre_idl.h>
10
11 enum lustre_imp_state {
12         LUSTRE_IMP_CLOSED     = 1,
13         LUSTRE_IMP_NEW        = 2,
14         LUSTRE_IMP_DISCON     = 3,
15         LUSTRE_IMP_CONNECTING = 4,
16         LUSTRE_IMP_REPLAY     = 5,
17         LUSTRE_IMP_REPLAY_LOCKS = 6,
18         LUSTRE_IMP_REPLAY_WAIT  = 7,
19         LUSTRE_IMP_RECOVER    = 8,
20         LUSTRE_IMP_FULL       = 9,
21         LUSTRE_IMP_EVICTED    = 10,
22 };
23
24 static inline char * ptlrpc_import_state_name(enum lustre_imp_state state)
25 {
26         static char* import_state_names[] = {
27                 "<UNKNOWN>", "CLOSED",  "NEW", "DISCONN",
28                 "CONNECTING", "REPLAY", "REPLAY_LOCKS", "REPLAY_WAIT",
29                 "RECOVER", "FULL", "EVICTED",
30         };
31
32         LASSERT (state <= LUSTRE_IMP_EVICTED);
33         return import_state_names[state];
34 }
35
36 enum obd_import_event {
37         IMP_EVENT_DISCON     = 0x808001,
38         IMP_EVENT_INACTIVE   = 0x808002,
39         IMP_EVENT_INVALIDATE = 0x808003,
40         IMP_EVENT_ACTIVE     = 0x808004,
41         IMP_EVENT_OCD        = 0x808005,
42 };
43
44 struct obd_import_conn {
45         struct list_head          oic_item;
46         struct ptlrpc_connection *oic_conn;
47         struct obd_uuid           oic_uuid;
48         __u64                     oic_last_attempt; /* jiffies, 64-bit */
49 };
50
51 struct obd_import {
52         struct portals_handle     imp_handle;
53         atomic_t                  imp_refcount;
54         struct lustre_handle      imp_dlm_handle; /* client's ldlm export */
55         struct ptlrpc_connection *imp_connection;
56         struct ptlrpc_client     *imp_client;
57         struct list_head          imp_pinger_chain;
58         struct list_head          imp_zombie_chain; /* queue for destruction */
59
60         /* Lists of requests that are retained for replay, waiting for a reply,
61          * or waiting for recovery to complete, respectively.
62          */
63         struct list_head          imp_replay_list;
64         struct list_head          imp_sending_list;
65         struct list_head          imp_delayed_list;
66
67         struct obd_device        *imp_obd;
68         struct ptlrpc_sec        *imp_sec;
69         struct semaphore          imp_sec_mutex;
70         cfs_time_t                imp_sec_expire;
71         cfs_waitq_t               imp_recovery_waitq;
72
73         atomic_t                  imp_inflight;
74         atomic_t                  imp_replay_inflight;
75         atomic_t                  imp_inval_count;
76         enum lustre_imp_state     imp_state;
77         int                       imp_generation;
78         __u32                     imp_conn_cnt;
79         int                       imp_last_generation_checked;
80         __u64                     imp_last_replay_transno;
81         __u64                     imp_peer_committed_transno;
82         __u64                     imp_last_transno_checked;
83         struct lustre_handle      imp_remote_handle;
84         cfs_time_t                imp_next_ping;   /* jiffies */
85         __u64                     imp_last_success_conn;   /* jiffies, 64-bit */
86
87         /* all available obd_import_conn linked here */
88         struct list_head          imp_conn_list;
89         struct obd_import_conn   *imp_conn_current;
90
91         /* Protects flags, level, generation, conn_cnt, *_list */
92         spinlock_t                imp_lock;
93
94         /* flags */
95         unsigned long             imp_no_timeout:1,       /* timeouts are disabled */
96                                   imp_invalid:1,          /* evicted */
97                                   imp_deactive:1,         /* administratively disabled */
98                                   imp_replayable:1,       /* try to recover the import */
99                                   imp_dlm_fake:1,         /* don't run recovery (timeout instead) */
100                                   imp_server_timeout:1,   /* use 1/2 timeout on MDS' OSCs */
101                                   imp_initial_recov:1,    /* retry the initial connection */  
102                                   imp_initial_recov_bk:1, /* turn off init_recov after trying all failover nids */
103                                   imp_force_verify:1,     /* force an immidiate ping */
104                                   imp_pingable:1,         /* pingable */
105                                   imp_resend_replay:1,    /* resend for replay */
106                                   imp_recon_bk:1,         /* turn off reconnect if all failovers fail */
107                                   imp_last_recon:1;       /* internally used by above */
108         __u32                     imp_connect_op;
109         struct obd_connect_data   imp_connect_data;
110         __u64                     imp_connect_flags_orig;
111         int                       imp_connect_error;
112
113         __u32                     imp_msg_magic;
114
115         struct ptlrpc_request_pool *imp_rq_pool; /* emergency request pool */
116 };
117
118 typedef void (*obd_import_callback)(struct obd_import *imp, void *closure,
119                                     int event, void *event_arg, void *cb_data);
120
121 struct obd_import_observer {
122         struct list_head     oio_chain;
123         obd_import_callback  oio_cb;
124         void                *oio_cb_data;
125 };
126
127 void class_observe_import(struct obd_import *imp, obd_import_callback cb,
128                           void *cb_data);
129 void class_unobserve_import(struct obd_import *imp, obd_import_callback cb,
130                             void *cb_data);
131 void class_notify_import_observers(struct obd_import *imp, int event,
132                                    void *event_arg);
133
134 /* genops.c */
135 struct obd_export;
136 extern struct obd_import *class_exp2cliimp(struct obd_export *);
137 extern struct obd_import *class_conn2cliimp(struct lustre_handle *);
138
139 #endif /* __IMPORT_H */