Whamcloud - gitweb
6393388580603c19c6dcba1f1b2ea236fc7ae2e1
[doc/protocol.git] / export.txt
1
2 Export
3 ^^^^^^
4
5 An 'obd_export' structure for a given target is created on a server
6 for each client that connects to that target. The exports for all the
7 clients for a given target are managed together. The export represents
8 the connection state between the client and target as well as the
9 current state of any ongoing activity. Thus each pending request will
10 have a reference to the export. The export is discarded if the
11 connection goes away, but only after all the references to it have
12 been cleaned up. The state information for each export is also
13 maintained on disk. In the event of a server failure, that or another
14 server can read the export date from disk to enable recovery.
15
16 ----
17 struct obd_export {
18     struct portals_handle     exp_handle;
19     atomic_t   exp_refcount;
20     atomic_t   exp_rpc_count;
21     atomic_t   exp_cb_count;
22     atomic_t   exp_replay_count;
23     atomic_t   exp_locks_count;
24 #if LUSTRE_TRACKS_LOCK_EXP_REFS
25     cfs_list_t exp_locks_list;
26     spinlock_t      exp_locks_list_guard;
27 #endif
28     struct obd_uuid       exp_client_uuid;
29     cfs_list_t exp_obd_chain;
30     cfs_hlist_node_t      exp_uuid_hash;
31     cfs_hlist_node_t      exp_nid_hash;
32     cfs_list_t            exp_obd_chain_timed;
33     struct obd_device    *exp_obd;
34     struct obd_import    *exp_imp_reverse;
35     struct nid_stat      *exp_nid_stats;
36     struct ptlrpc_connection *exp_connection;
37     __u32       exp_conn_cnt;
38     cfs_hash_t *exp_lock_hash;
39     cfs_hash_t *exp_flock_hash;
40     cfs_list_t  exp_outstanding_replies;
41     cfs_list_t  exp_uncommitted_replies;
42     spinlock_t  exp_uncommitted_replies_lock;
43     __u64       exp_last_committed;
44     cfs_time_t  exp_last_request_time;
45     cfs_list_t  exp_req_replay_queue;
46     spinlock_t  exp_lock;
47     struct obd_connect_data   exp_connect_data;
48     enum obd_option       exp_flags;
49     unsigned long
50       exp_failed:1,
51       exp_in_recovery:1,
52       exp_disconnected:1,
53       exp_connecting:1,
54       exp_delayed:1,
55       exp_vbr_failed:1,
56       exp_req_replay_needed:1,
57       exp_lock_replay_needed:1,
58       exp_need_sync:1,
59       exp_flvr_changed:1,
60       exp_flvr_adapt:1,
61       exp_libclient:1,
62       exp_need_mne_swab:1;
63     enum lustre_sec_part      exp_sp_peer;
64     struct sptlrpc_flavor     exp_flvr;
65     struct sptlrpc_flavor     exp_flvr_old[2];
66     cfs_time_t exp_flvr_expire[2];
67     spinlock_t exp_rpc_lock;
68     cfs_list_t exp_hp_rpcs;
69     cfs_list_t exp_reg_rpcs;
70     cfs_list_t exp_bl_list;
71     spinlock_t exp_bl_list_lock;
72     union {
73         struct tg_export_data     eu_target_data;
74         struct mdt_export_data    eu_mdt_data;
75         struct filter_export_data eu_filter_data;
76         struct ec_export_data     eu_ec_data;
77         struct mgs_export_data    eu_mgs_data;
78     } u;
79     struct nodemap      *exp_nodemap;
80 };
81 ----
82
83 The 'exp_handle' is a little extra information as compared with a
84 'struct lustre_handle', which is just the cookie. The cookie that the
85 server generates to uniquely identify this connection gets put into
86 this structure along with their information about the device in
87 question. This is the cookie the *_CONNECT reply sends back to the
88 client and is then stored int he client's import.
89
90 The 'exp_refcount' gets incremented whenever some aspect of the export
91 is "in use". The arrival of an otherwise unprocessed message for this
92 target will increment the refcount. A reference by an LDLM lock that
93 gets taken will increment the refcount. Callback invocations and
94 replay also lead to incrementing the 'ref_count'. The next four fields
95 - 'exp_rpc_count', exp_cb_count', and 'exp_replay_count', and
96 'exp_locks_count' - all subcategorize the 'exp_refcount'. The
97 reference counter keeps the export alive while there are any users of
98 that export. The reference counter is also used for debug
99 purposes. Similarly, the 'exp_locks_list' and 'exp_locks_list_guard'
100 are further debug info that list the actual locks accounted for in
101 'exp_locks_count'.
102
103 The 'exp_client_uuid' gives the UUID of the client connected to this
104 export. Fixme: when and how does the UUID get generated?
105
106 The server maintains all the exports for a given target on a circular
107 list. Each export's place on that list is maintained in the
108 'exp_obd_chain'. A common activity is to look up the export based on
109 the UUID or the nid of the client, and the 'exp_uuid_hash' and
110 'exp_nid_hash' fields maintain this export's place in hashes
111 constructed for that purpose.
112
113 Exports are also maintained on a list sorted by the last time the
114 corresponding client was heard from. The 'exp_obd_chain_timed' field
115 maintains the export's place on that list. When a message arrives from
116 the client the time is "now" so the export gets put at the end of the
117 list. Since it is circular, the next export is then the oldest. If it
118 has not been heard of within its timeout interval that export is
119 marked for later eviction.
120
121 The 'exp_obd' points to the 'obd_device' structure for the device that
122 is the target of this export.
123
124 In the event of an LDLM call-back the export needs to have a the ability to
125 initiate messages back to the client. The 'exp_imp_reverse' provides a
126 "reverse" import that manages this capability.
127
128 The '/proc' stats for the export (and the target) get updated via the
129 'exp_nid_stats'.
130
131 The 'exp_connection' points to the connection information for this
132 export. This is the information about the actual networking pathway(s)
133 that get used for communication.
134
135
136 The 'exp_conn_cnt' notes the connection count value from the client at
137 the time of the connection. In the event that more than one connection
138 request is issued before the connection is established then the
139 'exp_conn_cnt' will list the highest value. If a previous connection
140 attempt (with a lower value) arrives later it may be safely
141 discarded. Every request lists its connection count, so non-connection
142 requests with lower connection count values can also be discarded.
143 Note that this does not count how many times the client has connected
144 to the target. If a client is evicted the export is deleted once it
145 has been cleaned up and its 'exp_ref_count' reduced to zero. A new
146 connection from the client will get a new export.
147
148 The 'exp_lock_hash' provides access to the locks granted to the
149 corresponding client for this target. If a lock cannot be granted it
150 is discarded. A file system lock ("flock") is also implemented through
151 the LDLM lock system, but not all LDLM locks are flocks. The ones that
152 are flocks are gathered in a hash 'exp_flock_hash'. This supports
153 deadlock detection.
154
155 For those requests that initiate file system modifying transactions
156 the request and its attendant locks need to be preserved until either
157 a) the client acknowleges recieving the reply, or b) the transaction
158 has been committed locally. This ensures a request can be replayed in
159 the event of a failure. The LDLM lock is being kept until one of these
160 event occurs to prevent any other modifications of the same object.
161 The reply is kept on the 'exp_outstanding_replies' list until the LNet
162 layer notifies the server that the reply has been acknowledged. A reply
163 is kept on the 'exp_uncommitted_replies' list until the transaction
164 (if any) has been committed.
165
166 The 'exp_last_committed' value keeps the transaction number of the
167 last committed transaction. Every reply to a client includes this
168 value as a means of early-as-possible notification of transactions that
169 have been committed.
170
171 The 'exp_last_request_time' is self explanatory.
172
173 During reply a request that is waiting for reply is maintained on the
174 list 'exp_req_replay_queue'.
175
176 The 'exp_lock' spin-lock is used for access control to the exports
177 flags, as well as the 'exp_outstanding_replies' list and the revers
178 import, if any.
179
180 The 'exp_connect_data' refers to an 'obd_connect_data' structure for
181 the connection established between this target and the client this
182 export refers to. See also the corresponding entry in the import and
183 in the connect messages passed between the hosts.
184
185 The 'exp_flags' field encodes three directives as follows:
186 ----
187 enum obd_option {
188         OBD_OPT_FORCE =         0x0001,
189         OBD_OPT_FAILOVER =      0x0002,
190         OBD_OPT_ABORT_RECOV =   0x0004,
191 };
192 ----
193 fixme: Are the set for some exports and a condition of their
194 existence? or do they reflect a transient state the export is passing
195 through?
196
197 The 'exp_failed' flag gets set whenever the target has failed for any
198 reason or the export is otherwise due to be cleaned up. Once set it
199 will not be unset in this export. Any subsequent connection between
200 the client and the target would be governed by a new export.
201
202 After a failure export data is retrieved from disk and the exports
203 recreated. Exports created in this way will have their
204 'exp_in_recovery' flag set. Once any outstanding requests and locks
205 have been recovered for the client, then the export is recovered and
206 'exp_in_recovery' can be cleared. When all the client exports for a
207 given target have been recovered then the target is considered
208 recovered, and when all targets have been recovered the server is
209 considered recovered.
210
211 A *_DISCONNECT message from the client will set the 'exp_disconnected'
212 flag, as will any sort of failure of the target. Once set the export
213 will be cleaned up and deleted.
214
215 When a *_CONNECT message arrives the 'exp_connecting' flag is set. If
216 for some reason a second *_CONNECT request arrives from the client it can
217 be discarded when this flag is set.
218
219 The 'exp_delayed' flag is no longer used. In older code it indicated
220 that recovery had not completed in a timely fashion, but that a tardy
221 recovery would still be possible, since there were no dependencies on
222 the export.
223
224 The 'exp_vbr_failed' flag indicates a failure during the recovery
225 process. See <<recovery>> for a more detailed discussion of recovery
226 and transaction replay. For a file system modifying request, the
227 server composes its reply including the 'pb_pre_versions' entries in
228 'ptlrpc_body', which indicate the most recent updates to the
229 object. The client updates the request with the 'pb_transno' and
230 'pb_pre_versions' from the reply, and keeps that request until the
231 target signals that the transaction has been committed to disk. If the
232 client times-out without that confirmation then it will 'replay' the
233 request, which now includes the 'pb_pre_versions' information. During
234 a replay the target checks that the object has the same version as
235 'pb_pre_versions' in replay. If this check fails then the object can't
236 be restored in the same state as it was in before failure. Usually that
237 happens if the recovery process fails for the connection between some
238 other client and this target, so part of change needed for this client
239 wasn't restored. At that point the 'exp_vbr_failed' flag is set
240 to indicate version based recovery failed. This will lead to the client
241 being evicted and this export being cleaned up and deleted.
242
243 At the start of recovery both the 'exp_req_replay_needed' and
244 'exp_lock_replay_needed' flags are set. As request replay is completed
245 the 'exp_req_replay_needed' flag is cleared. As lock replay is
246 completed the 'exp_lock_replay_needed' flag is cleared. Once both are
247 cleared the 'exp_in_recovery' flag can be cleared.
248
249 The 'exp_need_sync' supports an optimization. At mount time it is
250 likely that every client (potentially thousands) will create an export
251 and that export will need to be saved to disk synchronously. This can
252 lead to an unusually high and poorly performing interaction with the
253 disk. When the export is created the 'exp_need_sync' flag is set and
254 the actual writing to disk is delayed. As transactions arrive from
255 clients (in a much less coordinated fashion) the 'exp_need_sync' flag
256 indicates a need to have the export data on disk before proceeding
257 with a new transaction, so as it is next updated the transaction is
258 done synchronously to commit all changes on disk. At that point the
259 flag is cleared (except see below).
260
261 In DNE (phase I) the export for an MDT managing the connection from
262 another MDT will want to always keep the 'exp_need_sync' flag set. For
263 that special case such an export sets the 'exp_keep_sync', which then
264 prevents the 'exp_need_sync' flag from ever being cleared. This will
265 no longer be needed in DNE Phase II.
266
267 The 'exp_flvr_changed' and 'exp_flvr_adapt' flags along with
268 'exp_sp_peer', 'exp_flvr', 'exp_flvr_old', and 'exp_flvr_expire'
269 fields are all used to manage the security settings for the
270 connection. Security is discussed in the <<security>> section. (fixme:
271 or will be.)
272
273 The 'exp_libclient' flag indicates that the export is for a client
274 based on "liblustre". This allows for simplified handling on the
275 server. (fixme: how is processing simplified? It sounds like I may
276 need a whole special section on liblustre.)
277
278 The 'exp_need_mne_swab' flag indicates the presence of an old bug that
279 affected one special case of failed swabbing. It is not part of
280 current processing.
281
282 As RPCs arrive they are first subjected to triage. Each request is
283 placed on the 'exp_hp_rpcs' list and examined to see if it is high
284 priority (PING, truncate, bulk I/O). If it is not high priority then
285 it is moved to the 'exp_reg_prcs' list. The 'exp_rpc_lock' protects
286 both lists from concurrent access.
287
288 All arriving LDLM requests get put on the 'exp_bl_list' and access to
289 that list is controlled via the 'exp_bl_list_lock'.
290
291 The union provides for target specific data. The 'eu_target_data' is
292 for a common core of fields for a generic target. The others are
293 specific to particular target types: 'eu_mdt_data' for MDTs,
294 'eu_filter_data' for OSTs, 'eu_ec_data' for an "echo client" (fixme:
295 describe what an echo client is somewhere), and 'eu_mgs_data' is for
296 an MGS.
297
298 The 'exp_bl_lock_at' field supports adaptive timeouts which will be
299 discussed separately. (fixme: so discuss it somewhere.)
300