]>
Commit | Line | Data |
---|---|---|
d7e09d03 PT |
1 | /* |
2 | * GPL HEADER START | |
3 | * | |
4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 only, | |
8 | * as published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * General Public License version 2 for more details (a copy is included | |
14 | * in the LICENSE file that accompanied this code). | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * version 2 along with this program; If not, see | |
18 | * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf | |
19 | * | |
20 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
21 | * CA 95054 USA or visit www.sun.com if you need additional information or | |
22 | * have any questions. | |
23 | * | |
24 | * GPL HEADER END | |
25 | */ | |
26 | /* | |
27 | * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. | |
28 | * Use is subject to license terms. | |
29 | * | |
56f4c5a8 | 30 | * Copyright (c) 2011, 2013, Intel Corporation. |
d7e09d03 PT |
31 | */ |
32 | /* | |
33 | * This file is part of Lustre, http://www.lustre.org/ | |
34 | * Lustre is a trademark of Sun Microsystems, Inc. | |
35 | * | |
36 | * lustre/fid/fid_request.c | |
37 | * | |
38 | * Lustre Sequence Manager | |
39 | * | |
40 | * Author: Yury Umanets <umka@clusterfs.com> | |
41 | */ | |
42 | ||
43 | #define DEBUG_SUBSYSTEM S_FID | |
44 | ||
9fdaf8c0 | 45 | #include "../../include/linux/libcfs/libcfs.h" |
56f4c5a8 | 46 | #include <linux/module.h> |
d7e09d03 | 47 | |
61566391 GKH |
48 | #include "../include/obd.h" |
49 | #include "../include/obd_class.h" | |
50 | #include "../include/obd_support.h" | |
51 | #include "../include/lustre_fid.h" | |
d7e09d03 | 52 | /* mdc RPC locks */ |
61566391 | 53 | #include "../include/lustre_mdc.h" |
d7e09d03 PT |
54 | #include "fid_internal.h" |
55 | ||
f3aa79fb DE |
56 | static struct dentry *seq_debugfs_dir; |
57 | ||
d7e09d03 PT |
58 | static int seq_client_rpc(struct lu_client_seq *seq, |
59 | struct lu_seq_range *output, __u32 opc, | |
60 | const char *opcname) | |
61 | { | |
62 | struct obd_export *exp = seq->lcs_exp; | |
63 | struct ptlrpc_request *req; | |
64 | struct lu_seq_range *out, *in; | |
56f4c5a8 LX |
65 | __u32 *op; |
66 | unsigned int debug_mask; | |
67 | int rc; | |
d7e09d03 PT |
68 | |
69 | req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_SEQ_QUERY, | |
70 | LUSTRE_MDS_VERSION, SEQ_QUERY); | |
71 | if (req == NULL) | |
0a3bdb00 | 72 | return -ENOMEM; |
d7e09d03 PT |
73 | |
74 | /* Init operation code */ | |
75 | op = req_capsule_client_get(&req->rq_pill, &RMF_SEQ_OPC); | |
76 | *op = opc; | |
77 | ||
78 | /* Zero out input range, this is not recovery yet. */ | |
79 | in = req_capsule_client_get(&req->rq_pill, &RMF_SEQ_RANGE); | |
80 | range_init(in); | |
81 | ||
82 | ptlrpc_request_set_replen(req); | |
83 | ||
84 | in->lsr_index = seq->lcs_space.lsr_index; | |
85 | if (seq->lcs_type == LUSTRE_SEQ_METADATA) | |
86 | fld_range_set_mdt(in); | |
87 | else | |
88 | fld_range_set_ost(in); | |
89 | ||
90 | if (opc == SEQ_ALLOC_SUPER) { | |
91 | req->rq_request_portal = SEQ_CONTROLLER_PORTAL; | |
92 | req->rq_reply_portal = MDC_REPLY_PORTAL; | |
93 | /* During allocating super sequence for data object, | |
94 | * the current thread might hold the export of MDT0(MDT0 | |
95 | * precreating objects on this OST), and it will send the | |
96 | * request to MDT0 here, so we can not keep resending the | |
97 | * request here, otherwise if MDT0 is failed(umounted), | |
98 | * it can not release the export of MDT0 */ | |
99 | if (seq->lcs_type == LUSTRE_SEQ_DATA) | |
100 | req->rq_no_delay = req->rq_no_resend = 1; | |
101 | debug_mask = D_CONSOLE; | |
102 | } else { | |
103 | if (seq->lcs_type == LUSTRE_SEQ_METADATA) | |
104 | req->rq_request_portal = SEQ_METADATA_PORTAL; | |
105 | else | |
106 | req->rq_request_portal = SEQ_DATA_PORTAL; | |
107 | debug_mask = D_INFO; | |
108 | } | |
109 | ||
110 | ptlrpc_at_set_req_timeout(req); | |
111 | ||
112 | if (seq->lcs_type == LUSTRE_SEQ_METADATA) | |
113 | mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL); | |
114 | rc = ptlrpc_queue_wait(req); | |
115 | if (seq->lcs_type == LUSTRE_SEQ_METADATA) | |
116 | mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL); | |
117 | if (rc) | |
89180ca7 | 118 | goto out_req; |
d7e09d03 PT |
119 | |
120 | out = req_capsule_server_get(&req->rq_pill, &RMF_SEQ_RANGE); | |
121 | *output = *out; | |
122 | ||
123 | if (!range_is_sane(output)) { | |
124 | CERROR("%s: Invalid range received from server: " | |
125 | DRANGE"\n", seq->lcs_name, PRANGE(output)); | |
89180ca7 JL |
126 | rc = -EINVAL; |
127 | goto out_req; | |
d7e09d03 PT |
128 | } |
129 | ||
130 | if (range_is_exhausted(output)) { | |
131 | CERROR("%s: Range received from server is exhausted: " | |
132 | DRANGE"]\n", seq->lcs_name, PRANGE(output)); | |
89180ca7 JL |
133 | rc = -EINVAL; |
134 | goto out_req; | |
d7e09d03 PT |
135 | } |
136 | ||
137 | CDEBUG_LIMIT(debug_mask, "%s: Allocated %s-sequence "DRANGE"]\n", | |
138 | seq->lcs_name, opcname, PRANGE(output)); | |
139 | ||
d7e09d03 PT |
140 | out_req: |
141 | ptlrpc_req_finished(req); | |
142 | return rc; | |
143 | } | |
144 | ||
145 | /* Request sequence-controller node to allocate new super-sequence. */ | |
146 | int seq_client_alloc_super(struct lu_client_seq *seq, | |
147 | const struct lu_env *env) | |
148 | { | |
149 | int rc; | |
d7e09d03 PT |
150 | |
151 | mutex_lock(&seq->lcs_mutex); | |
152 | ||
153 | if (seq->lcs_srv) { | |
56f4c5a8 | 154 | rc = 0; |
d7e09d03 PT |
155 | } else { |
156 | /* Check whether the connection to seq controller has been | |
157 | * setup (lcs_exp != NULL) */ | |
158 | if (seq->lcs_exp == NULL) { | |
159 | mutex_unlock(&seq->lcs_mutex); | |
0a3bdb00 | 160 | return -EINPROGRESS; |
d7e09d03 PT |
161 | } |
162 | ||
163 | rc = seq_client_rpc(seq, &seq->lcs_space, | |
164 | SEQ_ALLOC_SUPER, "super"); | |
165 | } | |
166 | mutex_unlock(&seq->lcs_mutex); | |
0a3bdb00 | 167 | return rc; |
d7e09d03 PT |
168 | } |
169 | ||
170 | /* Request sequence-controller node to allocate new meta-sequence. */ | |
171 | static int seq_client_alloc_meta(const struct lu_env *env, | |
172 | struct lu_client_seq *seq) | |
173 | { | |
174 | int rc; | |
d7e09d03 PT |
175 | |
176 | if (seq->lcs_srv) { | |
56f4c5a8 | 177 | rc = 0; |
d7e09d03 PT |
178 | } else { |
179 | do { | |
180 | /* If meta server return -EINPROGRESS or EAGAIN, | |
181 | * it means meta server might not be ready to | |
182 | * allocate super sequence from sequence controller | |
183 | * (MDT0)yet */ | |
184 | rc = seq_client_rpc(seq, &seq->lcs_space, | |
185 | SEQ_ALLOC_META, "meta"); | |
186 | } while (rc == -EINPROGRESS || rc == -EAGAIN); | |
187 | } | |
56f4c5a8 | 188 | |
0a3bdb00 | 189 | return rc; |
d7e09d03 PT |
190 | } |
191 | ||
192 | /* Allocate new sequence for client. */ | |
193 | static int seq_client_alloc_seq(const struct lu_env *env, | |
114acca8 | 194 | struct lu_client_seq *seq, u64 *seqnr) |
d7e09d03 PT |
195 | { |
196 | int rc; | |
d7e09d03 PT |
197 | |
198 | LASSERT(range_is_sane(&seq->lcs_space)); | |
199 | ||
200 | if (range_is_exhausted(&seq->lcs_space)) { | |
201 | rc = seq_client_alloc_meta(env, seq); | |
202 | if (rc) { | |
5cbcd111 | 203 | CERROR("%s: Can't allocate new meta-sequence, rc %d\n", |
913827ee | 204 | seq->lcs_name, rc); |
0a3bdb00 | 205 | return rc; |
d7e09d03 | 206 | } |
71e8dd9a AM |
207 | CDEBUG(D_INFO, "%s: New range - "DRANGE"\n", |
208 | seq->lcs_name, PRANGE(&seq->lcs_space)); | |
d7e09d03 PT |
209 | } else { |
210 | rc = 0; | |
211 | } | |
212 | ||
213 | LASSERT(!range_is_exhausted(&seq->lcs_space)); | |
214 | *seqnr = seq->lcs_space.lsr_start; | |
215 | seq->lcs_space.lsr_start += 1; | |
216 | ||
55f5a824 | 217 | CDEBUG(D_INFO, "%s: Allocated sequence [%#llx]\n", seq->lcs_name, |
d7e09d03 PT |
218 | *seqnr); |
219 | ||
0a3bdb00 | 220 | return rc; |
d7e09d03 PT |
221 | } |
222 | ||
223 | static int seq_fid_alloc_prep(struct lu_client_seq *seq, | |
224 | wait_queue_t *link) | |
225 | { | |
226 | if (seq->lcs_update) { | |
227 | add_wait_queue(&seq->lcs_waitq, link); | |
228 | set_current_state(TASK_UNINTERRUPTIBLE); | |
229 | mutex_unlock(&seq->lcs_mutex); | |
230 | ||
b3669a7f | 231 | schedule(); |
d7e09d03 PT |
232 | |
233 | mutex_lock(&seq->lcs_mutex); | |
234 | remove_wait_queue(&seq->lcs_waitq, link); | |
235 | set_current_state(TASK_RUNNING); | |
236 | return -EAGAIN; | |
237 | } | |
238 | ++seq->lcs_update; | |
239 | mutex_unlock(&seq->lcs_mutex); | |
240 | return 0; | |
241 | } | |
242 | ||
243 | static void seq_fid_alloc_fini(struct lu_client_seq *seq) | |
244 | { | |
245 | LASSERT(seq->lcs_update == 1); | |
246 | mutex_lock(&seq->lcs_mutex); | |
247 | --seq->lcs_update; | |
248 | wake_up(&seq->lcs_waitq); | |
249 | } | |
250 | ||
251 | /** | |
252 | * Allocate the whole seq to the caller. | |
253 | **/ | |
254 | int seq_client_get_seq(const struct lu_env *env, | |
114acca8 | 255 | struct lu_client_seq *seq, u64 *seqnr) |
d7e09d03 PT |
256 | { |
257 | wait_queue_t link; | |
258 | int rc; | |
259 | ||
260 | LASSERT(seqnr != NULL); | |
261 | mutex_lock(&seq->lcs_mutex); | |
9e795d35 | 262 | init_waitqueue_entry(&link, current); |
d7e09d03 PT |
263 | |
264 | while (1) { | |
265 | rc = seq_fid_alloc_prep(seq, &link); | |
266 | if (rc == 0) | |
267 | break; | |
268 | } | |
269 | ||
270 | rc = seq_client_alloc_seq(env, seq, seqnr); | |
271 | if (rc) { | |
5cbcd111 | 272 | CERROR("%s: Can't allocate new sequence, rc %d\n", |
913827ee | 273 | seq->lcs_name, rc); |
d7e09d03 PT |
274 | seq_fid_alloc_fini(seq); |
275 | mutex_unlock(&seq->lcs_mutex); | |
276 | return rc; | |
277 | } | |
278 | ||
143f378c | 279 | CDEBUG(D_INFO, "%s: allocate sequence [0x%16.16Lx]\n", |
913827ee | 280 | seq->lcs_name, *seqnr); |
d7e09d03 PT |
281 | |
282 | /* Since the caller require the whole seq, | |
283 | * so marked this seq to be used */ | |
284 | if (seq->lcs_type == LUSTRE_SEQ_METADATA) | |
285 | seq->lcs_fid.f_oid = LUSTRE_METADATA_SEQ_MAX_WIDTH; | |
286 | else | |
287 | seq->lcs_fid.f_oid = LUSTRE_DATA_SEQ_MAX_WIDTH; | |
288 | ||
289 | seq->lcs_fid.f_seq = *seqnr; | |
290 | seq->lcs_fid.f_ver = 0; | |
291 | /* | |
292 | * Inform caller that sequence switch is performed to allow it | |
293 | * to setup FLD for it. | |
294 | */ | |
295 | seq_fid_alloc_fini(seq); | |
296 | mutex_unlock(&seq->lcs_mutex); | |
297 | ||
298 | return rc; | |
299 | } | |
300 | EXPORT_SYMBOL(seq_client_get_seq); | |
301 | ||
302 | /* Allocate new fid on passed client @seq and save it to @fid. */ | |
303 | int seq_client_alloc_fid(const struct lu_env *env, | |
304 | struct lu_client_seq *seq, struct lu_fid *fid) | |
305 | { | |
306 | wait_queue_t link; | |
307 | int rc; | |
d7e09d03 PT |
308 | |
309 | LASSERT(seq != NULL); | |
310 | LASSERT(fid != NULL); | |
311 | ||
9e795d35 | 312 | init_waitqueue_entry(&link, current); |
d7e09d03 PT |
313 | mutex_lock(&seq->lcs_mutex); |
314 | ||
315 | if (OBD_FAIL_CHECK(OBD_FAIL_SEQ_EXHAUST)) | |
316 | seq->lcs_fid.f_oid = seq->lcs_width; | |
317 | ||
318 | while (1) { | |
114acca8 | 319 | u64 seqnr; |
d7e09d03 PT |
320 | |
321 | if (!fid_is_zero(&seq->lcs_fid) && | |
322 | fid_oid(&seq->lcs_fid) < seq->lcs_width) { | |
323 | /* Just bump last allocated fid and return to caller. */ | |
324 | seq->lcs_fid.f_oid += 1; | |
325 | rc = 0; | |
326 | break; | |
327 | } | |
328 | ||
329 | rc = seq_fid_alloc_prep(seq, &link); | |
330 | if (rc) | |
331 | continue; | |
332 | ||
333 | rc = seq_client_alloc_seq(env, seq, &seqnr); | |
334 | if (rc) { | |
5cbcd111 | 335 | CERROR("%s: Can't allocate new sequence, rc %d\n", |
913827ee | 336 | seq->lcs_name, rc); |
d7e09d03 PT |
337 | seq_fid_alloc_fini(seq); |
338 | mutex_unlock(&seq->lcs_mutex); | |
0a3bdb00 | 339 | return rc; |
d7e09d03 PT |
340 | } |
341 | ||
143f378c | 342 | CDEBUG(D_INFO, "%s: Switch to sequence [0x%16.16Lx]\n", |
913827ee | 343 | seq->lcs_name, seqnr); |
d7e09d03 PT |
344 | |
345 | seq->lcs_fid.f_oid = LUSTRE_FID_INIT_OID; | |
346 | seq->lcs_fid.f_seq = seqnr; | |
347 | seq->lcs_fid.f_ver = 0; | |
348 | ||
349 | /* | |
350 | * Inform caller that sequence switch is performed to allow it | |
351 | * to setup FLD for it. | |
352 | */ | |
353 | rc = 1; | |
354 | ||
355 | seq_fid_alloc_fini(seq); | |
356 | break; | |
357 | } | |
358 | ||
359 | *fid = seq->lcs_fid; | |
360 | mutex_unlock(&seq->lcs_mutex); | |
361 | ||
362 | CDEBUG(D_INFO, "%s: Allocated FID "DFID"\n", seq->lcs_name, PFID(fid)); | |
0a3bdb00 | 363 | return rc; |
d7e09d03 PT |
364 | } |
365 | EXPORT_SYMBOL(seq_client_alloc_fid); | |
366 | ||
367 | /* | |
368 | * Finish the current sequence due to disconnect. | |
369 | * See mdc_import_event() | |
370 | */ | |
371 | void seq_client_flush(struct lu_client_seq *seq) | |
372 | { | |
373 | wait_queue_t link; | |
374 | ||
375 | LASSERT(seq != NULL); | |
9e795d35 | 376 | init_waitqueue_entry(&link, current); |
d7e09d03 PT |
377 | mutex_lock(&seq->lcs_mutex); |
378 | ||
379 | while (seq->lcs_update) { | |
380 | add_wait_queue(&seq->lcs_waitq, &link); | |
381 | set_current_state(TASK_UNINTERRUPTIBLE); | |
382 | mutex_unlock(&seq->lcs_mutex); | |
383 | ||
b3669a7f | 384 | schedule(); |
d7e09d03 PT |
385 | |
386 | mutex_lock(&seq->lcs_mutex); | |
387 | remove_wait_queue(&seq->lcs_waitq, &link); | |
388 | set_current_state(TASK_RUNNING); | |
389 | } | |
390 | ||
391 | fid_zero(&seq->lcs_fid); | |
392 | /** | |
393 | * this id shld not be used for seq range allocation. | |
394 | * set to -1 for dgb check. | |
395 | */ | |
396 | ||
397 | seq->lcs_space.lsr_index = -1; | |
398 | ||
399 | range_init(&seq->lcs_space); | |
400 | mutex_unlock(&seq->lcs_mutex); | |
401 | } | |
402 | EXPORT_SYMBOL(seq_client_flush); | |
403 | ||
f3aa79fb | 404 | static void seq_client_debugfs_fini(struct lu_client_seq *seq) |
56f4c5a8 | 405 | { |
f3aa79fb DE |
406 | if (!IS_ERR_OR_NULL(seq->lcs_debugfs_entry)) |
407 | ldebugfs_remove(&seq->lcs_debugfs_entry); | |
56f4c5a8 LX |
408 | } |
409 | ||
f3aa79fb | 410 | static int seq_client_debugfs_init(struct lu_client_seq *seq) |
d7e09d03 PT |
411 | { |
412 | int rc; | |
d7e09d03 | 413 | |
f3aa79fb DE |
414 | seq->lcs_debugfs_entry = ldebugfs_register(seq->lcs_name, |
415 | seq_debugfs_dir, | |
416 | NULL, NULL); | |
d7e09d03 | 417 | |
f3aa79fb DE |
418 | if (IS_ERR_OR_NULL(seq->lcs_debugfs_entry)) { |
419 | CERROR("%s: LdebugFS failed in seq-init\n", seq->lcs_name); | |
420 | rc = seq->lcs_debugfs_entry ? PTR_ERR(seq->lcs_debugfs_entry) | |
421 | : -ENOMEM; | |
422 | seq->lcs_debugfs_entry = NULL; | |
0a3bdb00 | 423 | return rc; |
d7e09d03 PT |
424 | } |
425 | ||
f3aa79fb DE |
426 | rc = ldebugfs_add_vars(seq->lcs_debugfs_entry, |
427 | seq_client_debugfs_list, seq); | |
d7e09d03 | 428 | if (rc) { |
f3aa79fb | 429 | CERROR("%s: Can't init sequence manager debugfs, rc %d\n", |
913827ee | 430 | seq->lcs_name, rc); |
89180ca7 | 431 | goto out_cleanup; |
d7e09d03 PT |
432 | } |
433 | ||
0a3bdb00 | 434 | return 0; |
d7e09d03 PT |
435 | |
436 | out_cleanup: | |
f3aa79fb | 437 | seq_client_debugfs_fini(seq); |
d7e09d03 | 438 | return rc; |
56f4c5a8 | 439 | } |
d7e09d03 PT |
440 | |
441 | int seq_client_init(struct lu_client_seq *seq, | |
442 | struct obd_export *exp, | |
443 | enum lu_cli_type type, | |
444 | const char *prefix, | |
445 | struct lu_server_seq *srv) | |
446 | { | |
447 | int rc; | |
d7e09d03 PT |
448 | |
449 | LASSERT(seq != NULL); | |
450 | LASSERT(prefix != NULL); | |
451 | ||
452 | seq->lcs_srv = srv; | |
453 | seq->lcs_type = type; | |
454 | ||
455 | mutex_init(&seq->lcs_mutex); | |
456 | if (type == LUSTRE_SEQ_METADATA) | |
457 | seq->lcs_width = LUSTRE_METADATA_SEQ_MAX_WIDTH; | |
458 | else | |
459 | seq->lcs_width = LUSTRE_DATA_SEQ_MAX_WIDTH; | |
460 | ||
461 | init_waitqueue_head(&seq->lcs_waitq); | |
462 | /* Make sure that things are clear before work is started. */ | |
463 | seq_client_flush(seq); | |
464 | ||
465 | if (exp != NULL) | |
466 | seq->lcs_exp = class_export_get(exp); | |
467 | else if (type == LUSTRE_SEQ_METADATA) | |
468 | LASSERT(seq->lcs_srv != NULL); | |
469 | ||
470 | snprintf(seq->lcs_name, sizeof(seq->lcs_name), | |
471 | "cli-%s", prefix); | |
472 | ||
f3aa79fb | 473 | rc = seq_client_debugfs_init(seq); |
d7e09d03 PT |
474 | if (rc) |
475 | seq_client_fini(seq); | |
0a3bdb00 | 476 | return rc; |
d7e09d03 PT |
477 | } |
478 | EXPORT_SYMBOL(seq_client_init); | |
479 | ||
480 | void seq_client_fini(struct lu_client_seq *seq) | |
481 | { | |
f3aa79fb | 482 | seq_client_debugfs_fini(seq); |
d7e09d03 PT |
483 | |
484 | if (seq->lcs_exp != NULL) { | |
485 | class_export_put(seq->lcs_exp); | |
486 | seq->lcs_exp = NULL; | |
487 | } | |
488 | ||
489 | seq->lcs_srv = NULL; | |
d7e09d03 PT |
490 | } |
491 | EXPORT_SYMBOL(seq_client_fini); | |
56f4c5a8 LX |
492 | |
493 | int client_fid_init(struct obd_device *obd, | |
494 | struct obd_export *exp, enum lu_cli_type type) | |
495 | { | |
496 | struct client_obd *cli = &obd->u.cli; | |
497 | char *prefix; | |
498 | int rc; | |
56f4c5a8 | 499 | |
5a56474a | 500 | cli->cl_seq = kzalloc(sizeof(*cli->cl_seq), GFP_NOFS); |
6c7c6553 | 501 | if (!cli->cl_seq) |
0a3bdb00 | 502 | return -ENOMEM; |
56f4c5a8 | 503 | |
5a56474a | 504 | prefix = kzalloc(MAX_OBD_NAME + 5, GFP_NOFS); |
6c7c6553 | 505 | if (!prefix) { |
89180ca7 JL |
506 | rc = -ENOMEM; |
507 | goto out_free_seq; | |
508 | } | |
56f4c5a8 LX |
509 | |
510 | snprintf(prefix, MAX_OBD_NAME + 5, "cli-%s", obd->obd_name); | |
511 | ||
512 | /* Init client side sequence-manager */ | |
513 | rc = seq_client_init(cli->cl_seq, exp, type, prefix, NULL); | |
5a56474a | 514 | kfree(prefix); |
56f4c5a8 | 515 | if (rc) |
89180ca7 | 516 | goto out_free_seq; |
56f4c5a8 | 517 | |
0a3bdb00 | 518 | return rc; |
56f4c5a8 | 519 | out_free_seq: |
5a56474a | 520 | kfree(cli->cl_seq); |
56f4c5a8 LX |
521 | cli->cl_seq = NULL; |
522 | return rc; | |
523 | } | |
524 | EXPORT_SYMBOL(client_fid_init); | |
525 | ||
526 | int client_fid_fini(struct obd_device *obd) | |
527 | { | |
528 | struct client_obd *cli = &obd->u.cli; | |
56f4c5a8 LX |
529 | |
530 | if (cli->cl_seq != NULL) { | |
531 | seq_client_fini(cli->cl_seq); | |
5a56474a | 532 | kfree(cli->cl_seq); |
56f4c5a8 LX |
533 | cli->cl_seq = NULL; |
534 | } | |
535 | ||
0a3bdb00 | 536 | return 0; |
56f4c5a8 LX |
537 | } |
538 | EXPORT_SYMBOL(client_fid_fini); | |
539 | ||
56f4c5a8 LX |
540 | static int __init fid_mod_init(void) |
541 | { | |
f3aa79fb DE |
542 | seq_debugfs_dir = ldebugfs_register(LUSTRE_SEQ_NAME, |
543 | debugfs_lustre_root, | |
544 | NULL, NULL); | |
545 | return PTR_ERR_OR_ZERO(seq_debugfs_dir); | |
56f4c5a8 LX |
546 | } |
547 | ||
548 | static void __exit fid_mod_exit(void) | |
549 | { | |
f3aa79fb DE |
550 | if (!IS_ERR_OR_NULL(seq_debugfs_dir)) |
551 | ldebugfs_remove(&seq_debugfs_dir); | |
56f4c5a8 LX |
552 | } |
553 | ||
554 | MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); | |
555 | MODULE_DESCRIPTION("Lustre FID Module"); | |
556 | MODULE_LICENSE("GPL"); | |
6960736c | 557 | MODULE_VERSION("0.1.0"); |
56f4c5a8 | 558 | |
6960736c GKH |
559 | module_init(fid_mod_init); |
560 | module_exit(fid_mod_exit); |