Whamcloud - gitweb
b=5765
[fs/lustre-release.git] / lustre / cobd / cache_obd.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (c) 2002 Cluster File Systems, Inc. <info@clusterfs.com>
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21
22 #define DEBUG_SUBSYSTEM S_COBD
23
24 #include <linux/version.h>
25 #include <linux/init.h>
26 #include <linux/obd_support.h>
27 #include <linux/lustre_lib.h>
28 #include <linux/lustre_net.h>
29 #include <linux/lustre_idl.h>
30 #include <linux/lustre_log.h>
31 #include <linux/lustre_mds.h>
32 #include <linux/obd_class.h>
33 #include <linux/obd_cache.h>
34 #include <linux/obd_lmv.h>
35
36 static int cobd_attach(struct obd_device *obd,
37                        obd_count len, void *buf)
38 {
39         struct lprocfs_static_vars lvars;
40         
41         lprocfs_init_vars(cobd, &lvars);
42         return lprocfs_obd_attach(obd, lvars.obd_vars);
43 }
44
45 static int cobd_detach(struct obd_device *obd)
46 {
47         return lprocfs_obd_detach(obd);
48 }
49
50 static int cobd_setup(struct obd_device *obd, obd_count len, void *buf)
51 {
52         struct lustre_cfg *lcfg = (struct lustre_cfg *)buf;
53         struct cache_obd  *cobd = &obd->u.cobd;
54         struct obd_device *master;
55         int rc = 0;
56         ENTRY;
57
58         if (lcfg->lcfg_inllen1 == 0 || lcfg->lcfg_inlbuf1 == NULL) {
59                 CERROR("%s: setup requires master device name\n", 
60                        obd->obd_name);
61                 RETURN(-EINVAL);
62         }
63
64         if (lcfg->lcfg_inllen2 == 0 || lcfg->lcfg_inlbuf2 == NULL) {
65                 CERROR("%s: setup requires cache device name\n",
66                        obd->obd_name);
67                 RETURN(-EINVAL);
68         }
69
70         master = class_name2obd(lcfg->lcfg_inlbuf1);
71         if (!master) {
72                 CERROR("%s: unable to find master: %s\n",
73                        obd->obd_name, lcfg->lcfg_inlbuf1);
74                 RETURN(-EINVAL);
75         }
76
77         sema_init(&cobd->sem, 1);
78
79         OBD_ALLOC(cobd->master_name, lcfg->lcfg_inllen1);
80         if (!cobd->master_name) 
81                 RETURN(-ENOMEM);
82         memcpy(cobd->master_name, lcfg->lcfg_inlbuf1, 
83                lcfg->lcfg_inllen1);
84         
85         OBD_ALLOC(cobd->cache_name, lcfg->lcfg_inllen2);
86         if (!cobd->cache_name) 
87                 GOTO(put_names, rc = -ENOMEM);
88         memcpy(cobd->cache_name, lcfg->lcfg_inlbuf2, 
89                lcfg->lcfg_inllen2);
90
91         EXIT;
92 put_names:
93         if (rc) {
94                 OBD_FREE(cobd->master_name, lcfg->lcfg_inllen1);
95                 cobd->master_name = NULL;
96         }
97         return rc;
98 }
99
100 static int cobd_cleanup(struct obd_device *obd, int flags)
101 {
102         struct cache_obd  *cobd = &obd->u.cobd;
103         ENTRY;
104
105         if (!list_empty(&obd->obd_exports))
106                 RETURN(-EBUSY);
107
108         if (cobd->cache_name)
109                 OBD_FREE(cobd->cache_name, 
110                          strlen(cobd->cache_name) + 1);
111         if (cobd->master_name)
112                 OBD_FREE(cobd->master_name, 
113                          strlen(cobd->master_name) + 1);
114         
115         RETURN(0);
116 }
117
118 static inline struct obd_export *
119 cobd_get_exp(struct obd_device *obd)
120 {
121         struct cache_obd *cobd = &obd->u.cobd;
122         if (cobd->cache_on)  
123                 return cobd->cache_exp;
124         return cobd->master_exp;
125 }
126
127 static int client_obd_connect(struct obd_device *obd, char *name,
128                               struct lustre_handle *conn,
129                               unsigned long flags)
130
131         struct obd_device *cli_obd;
132         int rc = 0;
133         ENTRY;
134  
135         LASSERT(obd);
136         LASSERT(name);
137         LASSERT(conn);
138         
139         cli_obd = class_name2obd(name);
140         if (cli_obd == NULL) {
141                 CERROR("%s: unable to find a client for obd: %s\n",
142                        obd->obd_name, name);
143                 RETURN(-EINVAL);
144         }
145         rc = obd_connect(conn, cli_obd, &obd->obd_uuid, flags);
146         if (rc) {
147                 CERROR("error connecting to %s, err %d\n",
148                        name, rc);
149         }
150         RETURN(rc);
151 }
152
153 static int client_obd_disconnect(struct obd_device *obd,
154                                  struct obd_export *exp,
155                                  unsigned long flags)
156 {
157         struct obd_device *cli_obd;
158         int rc = 0;
159         ENTRY;
160
161         cli_obd = class_exp2obd(exp);
162         cli_obd->obd_no_recov = obd->obd_no_recov;
163         
164         rc = obd_disconnect(exp, flags);
165         if (rc) {
166                 CERROR("error disconnecting from %s, err %d\n",
167                        cli_obd->obd_name, rc);
168                 class_export_put(exp);
169         }
170         RETURN(rc);
171 }
172
173 static int
174 cobd_connect(struct lustre_handle *conn, struct obd_device *obd,
175              struct obd_uuid *cluuid, unsigned long flags)
176 {
177         struct lustre_handle cache_conn = { 0 };
178         struct cache_obd *cobd = &obd->u.cobd;
179         struct obd_export *exp;
180         int rc = 0;
181         ENTRY;
182
183         /* connecting class */
184         rc = class_connect(conn, obd, cluuid);
185         if (rc)
186                 RETURN(rc);
187         exp = class_conn2export(conn);
188
189         /* connecting cache */
190         rc = client_obd_connect(obd, cobd->cache_name,
191                                 &cache_conn, flags);
192         if (rc)
193                 GOTO(err_discon, rc);
194         cobd->cache_exp = class_conn2export(&cache_conn);
195         cobd->cache_on = 1;
196
197         EXIT;
198 err_discon:
199         if (rc)
200                 class_disconnect(exp, 0);
201         else
202                 class_export_put(exp);
203         return rc;
204 }
205
206 static int
207 cobd_disconnect(struct obd_export *exp, unsigned long flags)
208 {
209         struct obd_device *obd;
210         struct cache_obd *cobd;
211         int rc = 0;
212         ENTRY;
213         
214         LASSERT(exp != NULL);
215         obd = class_exp2obd(exp);
216         if (obd == NULL) {
217                 CDEBUG(D_IOCTL, "invalid client cookie "LPX64"\n",
218                        exp->exp_handle.h_cookie);
219                 RETURN(-EINVAL);
220         }
221
222         cobd = &obd->u.cobd;
223         
224         if (cobd->cache_on) {
225                 rc = client_obd_disconnect(obd, cobd->cache_exp,
226                                            flags);
227                 cobd->cache_exp = NULL;
228         } else {
229                 rc = client_obd_disconnect(obd, cobd->master_exp,
230                                            flags);
231                 cobd->master_exp = NULL;
232         }
233
234         rc = class_disconnect(exp, flags);
235         RETURN(rc);
236 }
237
238 static int cobd_get_info(struct obd_export *exp, obd_count keylen,
239                          void *key, __u32 *vallen, void *val)
240 {
241         struct obd_device *obd = class_exp2obd(exp);
242         struct obd_export *cobd_exp;
243         
244         if (obd == NULL) {
245                 CERROR("invalid client cookie "LPX64"\n", 
246                        exp->exp_handle.h_cookie);
247                 return -EINVAL;
248         }
249         cobd_exp = cobd_get_exp(obd);
250
251         /* intercept cache utilisation info? */
252         return obd_get_info(cobd_exp, keylen, key, vallen, val);
253 }
254
255 static int cobd_set_info(struct obd_export *exp, obd_count keylen,
256                          void *key, obd_count vallen, void *val)
257 {
258         struct obd_device *obd = class_exp2obd(exp);
259         struct obd_export *cobd_exp;
260
261         if (obd == NULL) {
262                 CERROR("invalid client cookie "LPX64"\n", 
263                        exp->exp_handle.h_cookie);
264                 return -EINVAL;
265         }
266         cobd_exp = cobd_get_exp(obd);
267         
268         /* intercept cache utilisation info? */
269         return obd_set_info(cobd_exp, keylen, key, vallen, val);
270 }
271
272 static int cobd_statfs(struct obd_device *obd, struct obd_statfs *osfs,
273                        unsigned long max_age)
274 {
275         struct obd_export *cobd_exp;
276
277         cobd_exp = cobd_get_exp(obd);
278
279         return obd_statfs(class_exp2obd(cobd_exp), osfs, max_age);
280 }
281
282 static int cobd_packmd(struct obd_export *exp,
283                        struct lov_mds_md **disk_tgt,
284                        struct lov_stripe_md *mem_src)
285 {
286         struct obd_device *obd = class_exp2obd(exp);
287         struct obd_export *cobd_exp;
288
289         if (obd == NULL) {
290                 CERROR("invalid client cookie "LPX64"\n", 
291                        exp->exp_handle.h_cookie);
292                 return -EINVAL;
293         }
294         cobd_exp = cobd_get_exp(obd);
295         return obd_packmd(cobd_exp, disk_tgt, mem_src);
296 }
297
298 static int cobd_unpackmd(struct obd_export *exp,
299                          struct lov_stripe_md **mem_tgt,
300                          struct lov_mds_md *disk_src,
301                          int disk_len)
302 {
303         struct obd_device *obd = class_exp2obd(exp);
304         struct obd_export *cobd_exp;
305
306         if (obd == NULL) {
307                 CERROR("invalid client cookie "LPX64"\n", 
308                        exp->exp_handle.h_cookie);
309                 return -EINVAL;
310         }
311         cobd_exp = cobd_get_exp(obd);
312         return obd_unpackmd(cobd_exp, mem_tgt, disk_src, disk_len);
313 }
314
315 static int cobd_create(struct obd_export *exp, struct obdo *obdo,
316                        struct lov_stripe_md **ea,
317                        struct obd_trans_info *oti)
318 {
319         struct obd_device *obd = class_exp2obd(exp);
320         struct obd_export *cobd_exp;
321
322         if (obd == NULL) {
323                 CERROR("invalid client cookie "LPX64"\n", 
324                        exp->exp_handle.h_cookie);
325                 return -EINVAL;
326         }
327         cobd_exp = cobd_get_exp(obd);
328         return obd_create(cobd_exp, obdo, ea, oti); 
329 }
330
331 static int cobd_destroy(struct obd_export *exp, struct obdo *obdo,
332                         struct lov_stripe_md *ea,
333                         struct obd_trans_info *oti)
334 {
335         struct obd_device *obd = class_exp2obd(exp);
336         struct obd_export *cobd_exp;
337
338         if (obd == NULL) {
339                 CERROR("invalid client cookie "LPX64"\n", 
340                        exp->exp_handle.h_cookie);
341                 return -EINVAL;
342         }
343         cobd_exp = cobd_get_exp(obd);
344         return obd_destroy(cobd_exp, obdo, ea, oti); 
345 }
346
347 static int cobd_precleanup(struct obd_device *obd, int flags)
348 {
349         /* FIXME-WANGDI: do we need some cleanup here? */
350         return 0;
351 }
352
353 static int cobd_getattr(struct obd_export *exp, struct obdo *oa,
354                         struct lov_stripe_md *lsm)
355 {
356         struct obd_device *obd = class_exp2obd(exp);
357         struct obd_export *cobd_exp;
358
359         if (obd == NULL) {
360                 CERROR("invalid client cookie "LPX64"\n", 
361                        exp->exp_handle.h_cookie);
362                 return -EINVAL;
363         }
364         cobd_exp = cobd_get_exp(obd);
365         return obd_getattr(cobd_exp, oa, lsm);
366 }
367
368 static int cobd_getattr_async(struct obd_export *exp,
369                               struct obdo *obdo, struct lov_stripe_md *ea,
370                               struct ptlrpc_request_set *set)
371 {
372         struct obd_device *obd = class_exp2obd(exp);
373         struct obd_export *cobd_exp;
374
375         if (obd == NULL) {
376                 CERROR("invalid client cookie "LPX64"\n", 
377                        exp->exp_handle.h_cookie);
378                 return -EINVAL;
379         }
380         cobd_exp = cobd_get_exp(obd);
381         return obd_getattr_async(cobd_exp, obdo, ea, set);
382 }
383
384 static int cobd_setattr(struct obd_export *exp, struct obdo *obdo,
385                         struct lov_stripe_md *ea,
386                         struct obd_trans_info *oti)
387 {
388         struct obd_device *obd = class_exp2obd(exp);
389         struct obd_export *cobd_exp;
390
391         if (obd == NULL) {
392                 CERROR("invalid client cookie "LPX64"\n", 
393                        exp->exp_handle.h_cookie);
394                 return -EINVAL;
395         }
396         cobd_exp = cobd_get_exp(obd);
397         return obd_setattr(cobd_exp, obdo, ea, oti);
398 }
399
400 static int cobd_md_getstatus(struct obd_export *exp,
401                              struct lustre_id *rootid)
402 {
403         struct obd_device *obd = class_exp2obd(exp);
404         struct obd_export *cobd_exp;
405
406         if (obd == NULL) {
407                 CERROR("invalid client cookie "LPX64"\n", 
408                        exp->exp_handle.h_cookie);
409                 return -EINVAL;
410         }
411         cobd_exp = cobd_get_exp(obd);
412         return md_getstatus(cobd_exp, rootid);
413 }
414
415 static int cobd_brw(int cmd, struct obd_export *exp, struct obdo *oa,
416                     struct lov_stripe_md *ea, obd_count oa_bufs,
417                     struct brw_page *pg, struct obd_trans_info *oti)
418 {
419         struct obd_device *obd = class_exp2obd(exp);
420         struct obd_export *cobd_exp;
421
422         if (obd == NULL) {
423                 CERROR("invalid client cookie "LPX64"\n", 
424                        exp->exp_handle.h_cookie);
425                 return -EINVAL;
426         }
427         cobd_exp = cobd_get_exp(obd);
428         return obd_brw(cmd, cobd_exp, oa, ea, oa_bufs, pg, oti);
429 }
430
431 static int cobd_brw_async(int cmd, struct obd_export *exp,
432                           struct obdo *oa, struct lov_stripe_md *ea,
433                           obd_count oa_bufs, struct brw_page *pg,
434                           struct ptlrpc_request_set *set,
435                           struct obd_trans_info *oti)
436 {
437         struct obd_device *obd = class_exp2obd(exp);
438         struct obd_export *cobd_exp;
439
440         if (obd == NULL) {
441                 CERROR("invalid client cookie "LPX64"\n", 
442                        exp->exp_handle.h_cookie);
443                 return -EINVAL;
444         }
445         cobd_exp = cobd_get_exp(obd);
446         return obd_brw_async(cmd, cobd_exp, oa, ea, oa_bufs, 
447                              pg, set, oti);
448 }
449
450 static int cobd_prep_async_page(struct obd_export *exp, 
451                                 struct lov_stripe_md *lsm,
452                                 struct lov_oinfo *loi, 
453                                 struct page *page, obd_off offset, 
454                                 struct obd_async_page_ops *ops, 
455                                 void *data, void **res)
456 {
457         struct obd_device *obd = class_exp2obd(exp);
458         struct obd_export *cobd_exp;
459
460         if (obd == NULL) {
461                 CERROR("invalid client cookie "LPX64"\n", 
462                        exp->exp_handle.h_cookie);
463                 return -EINVAL;
464         }
465         cobd_exp = cobd_get_exp(obd);
466         return obd_prep_async_page(cobd_exp, lsm, loi, page, offset,
467                                    ops, data, res);
468 }
469
470 static int cobd_queue_async_io(struct obd_export *exp,
471                                struct lov_stripe_md *lsm,
472                                struct lov_oinfo *loi, void *cookie,
473                                int cmd, obd_off off, int count,
474                                obd_flags brw_flags, obd_flags async_flags)
475 {
476         struct obd_device *obd = class_exp2obd(exp);
477         struct obd_export *cobd_exp;
478
479         if (obd == NULL) {
480                 CERROR("invalid client cookie "LPX64"\n", 
481                        exp->exp_handle.h_cookie);
482                 return -EINVAL;
483         }
484         cobd_exp = cobd_get_exp(obd);
485         return obd_queue_async_io(cobd_exp, lsm, loi, cookie, cmd, off, count,
486                                   brw_flags, async_flags);
487 }
488
489 static int cobd_set_async_flags(struct obd_export *exp,
490                                struct lov_stripe_md *lsm,
491                                struct lov_oinfo *loi, void *cookie,
492                                obd_flags async_flags)
493 {
494         struct obd_device *obd = class_exp2obd(exp);
495         struct obd_export *cobd_exp;
496
497         if (obd == NULL) {
498                 CERROR("invalid client cookie "LPX64"\n", 
499                        exp->exp_handle.h_cookie);
500                 return -EINVAL;
501         }
502         cobd_exp = cobd_get_exp(obd);
503         return obd_set_async_flags(cobd_exp, lsm, loi, cookie, async_flags);
504 }
505
506 static int cobd_queue_group_io(struct obd_export *exp, 
507                                struct lov_stripe_md *lsm, 
508                                struct lov_oinfo *loi, 
509                                struct obd_io_group *oig, 
510                                void *cookie, int cmd, obd_off off, 
511                                int count, obd_flags brw_flags,
512                                obd_flags async_flags)
513 {
514         struct obd_device *obd = class_exp2obd(exp);
515         struct obd_export *cobd_exp;
516
517         if (obd == NULL) {
518                 CERROR("invalid client cookie "LPX64"\n", 
519                        exp->exp_handle.h_cookie);
520                 return -EINVAL;
521         }
522         cobd_exp = cobd_get_exp(obd);
523         return obd_queue_group_io(cobd_exp, lsm, loi, oig, cookie,
524                                   cmd, off, count, brw_flags, async_flags);
525 }
526
527 static int cobd_trigger_group_io(struct obd_export *exp, 
528                                  struct lov_stripe_md *lsm, 
529                                  struct lov_oinfo *loi,
530                                  struct obd_io_group *oig)
531 {
532         struct obd_device *obd = class_exp2obd(exp);
533         struct obd_export *cobd_exp;
534
535         if (obd == NULL) {
536                 CERROR("invalid client cookie "LPX64"\n", 
537                        exp->exp_handle.h_cookie);
538                 return -EINVAL;
539         }
540         cobd_exp = cobd_get_exp(obd);
541         return obd_trigger_group_io(cobd_exp, lsm, loi, oig); 
542 }
543
544 static int cobd_teardown_async_page(struct obd_export *exp,
545                                     struct lov_stripe_md *lsm,
546                                     struct lov_oinfo *loi, void *cookie)
547 {
548         struct obd_device *obd = class_exp2obd(exp);
549         struct obd_export *cobd_exp;
550
551         if (obd == NULL) {
552                 CERROR("invalid client cookie "LPX64"\n", 
553                        exp->exp_handle.h_cookie);
554                 return -EINVAL;
555         }
556         cobd_exp = cobd_get_exp(obd);
557         return obd_teardown_async_page(cobd_exp, lsm, loi, cookie);
558 }
559
560 static int cobd_punch(struct obd_export *exp, struct obdo *oa,
561                       struct lov_stripe_md *ea, obd_size start,
562                       obd_size end, struct obd_trans_info *oti)
563 {
564         struct obd_device *obd = class_exp2obd(exp);
565         struct obd_export *cobd_exp;
566
567         if (obd == NULL) {
568                 CERROR("invalid client cookie "LPX64"\n", 
569                        exp->exp_handle.h_cookie);
570                 return -EINVAL;
571         }
572         cobd_exp = cobd_get_exp(obd);
573         return obd_punch(cobd_exp, oa, ea, start, end, oti);
574 }
575
576 static int cobd_sync(struct obd_export *exp, struct obdo *oa,
577                      struct lov_stripe_md *ea, obd_size start, 
578                      obd_size end)
579 {
580         struct obd_device *obd = class_exp2obd(exp);
581         struct obd_export *cobd_exp;
582
583         if (obd == NULL) {
584                 CERROR("invalid client cookie "LPX64"\n", 
585                        exp->exp_handle.h_cookie);
586                 return -EINVAL;
587         }
588         cobd_exp = cobd_get_exp(obd);
589         return obd_sync(cobd_exp, oa, ea, start, end);
590 }
591
592 static int cobd_enqueue(struct obd_export *exp, struct lov_stripe_md *ea,
593                         __u32 type, ldlm_policy_data_t *policy,
594                         __u32 mode, int *flags, void *bl_cb, void *cp_cb,
595                         void *gl_cb, void *data, __u32 lvb_len,
596                         void *lvb_swabber, struct lustre_handle *lockh)
597 {
598         struct obd_device *obd = class_exp2obd(exp);
599         struct obd_export *cobd_exp;
600
601         if (obd == NULL) {
602                 CERROR("invalid client cookie "LPX64"\n", 
603                        exp->exp_handle.h_cookie);
604                 return -EINVAL;
605         }
606         cobd_exp = cobd_get_exp(obd);
607         return obd_enqueue(cobd_exp, ea, type, policy, mode, flags, 
608                            bl_cb, cp_cb, gl_cb, data, lvb_len,
609                            lvb_swabber, lockh);
610 }
611
612 static int cobd_match(struct obd_export *exp, struct lov_stripe_md *ea,
613                       __u32 type, ldlm_policy_data_t *policy, __u32 mode,
614                       int *flags, void *data, struct lustre_handle *lockh)
615 {
616         struct obd_device *obd = class_exp2obd(exp);
617         struct obd_export *cobd_exp;
618
619         if (obd == NULL) {
620                 CERROR("invalid client cookie "LPX64"\n", 
621                        exp->exp_handle.h_cookie);
622                 return -EINVAL;
623         }
624         cobd_exp = cobd_get_exp(obd);
625         return obd_match(cobd_exp, ea, type, policy, mode, flags, data,
626                          lockh); 
627 }
628 static int cobd_change_cbdata(struct obd_export *exp,
629                               struct lov_stripe_md *lsm, 
630                               ldlm_iterator_t it, void *data)
631 {
632         struct obd_device *obd = class_exp2obd(exp);
633         struct obd_export *cobd_exp;
634
635         if (obd == NULL) {
636                 CERROR("invalid client cookie "LPX64"\n", 
637                        exp->exp_handle.h_cookie);
638                 return -EINVAL;
639         }
640         cobd_exp = cobd_get_exp(obd);
641         return obd_change_cbdata(cobd_exp, lsm, it, data);
642 }
643
644 static int cobd_cancel(struct obd_export *exp,
645                        struct lov_stripe_md *ea, __u32 mode,
646                        struct lustre_handle *lockh)
647 {
648         struct obd_device *obd = class_exp2obd(exp);
649         struct obd_export *cobd_exp;
650
651         if (obd == NULL) {
652                 CERROR("invalid client cookie "LPX64"\n", 
653                        exp->exp_handle.h_cookie);
654                 return -EINVAL;
655         }
656         cobd_exp = cobd_get_exp(obd);
657         return obd_cancel(cobd_exp, ea, mode, lockh);
658 }
659
660 static int cobd_cancel_unused(struct obd_export *exp,
661                               struct lov_stripe_md *ea, int flags,
662                               void *opaque)
663 {
664         struct obd_device *obd = class_exp2obd(exp);
665         struct obd_export *cobd_exp;
666
667         if (obd == NULL) {
668                 CERROR("invalid client cookie "LPX64"\n", 
669                        exp->exp_handle.h_cookie);
670                 return -EINVAL;
671         }
672         cobd_exp = cobd_get_exp(obd);
673         return obd_cancel_unused(cobd_exp, ea, flags, opaque);
674 }
675
676 static int cobd_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
677                        int objcount, struct obd_ioobj *obj,
678                        int niocount, struct niobuf_remote *nb,
679                        struct niobuf_local *res, struct obd_trans_info *oti)
680 {
681         struct obd_device *obd = class_exp2obd(exp);
682         struct obd_export *cobd_exp;
683
684         if (obd == NULL) {
685                 CERROR("invalid client cookie "LPX64"\n", 
686                        exp->exp_handle.h_cookie);
687                 return -EINVAL;
688         }
689         cobd_exp = cobd_get_exp(obd);
690         return obd_preprw(cmd, cobd_exp, oa, objcount, obj, niocount, nb, 
691                           res, oti);
692 }
693
694 static int cobd_commitrw(int cmd, struct obd_export *exp, struct obdo *oa,
695                          int objcount, struct obd_ioobj *obj,
696                          int niocount, struct niobuf_local *local,
697                          struct obd_trans_info *oti, int rc)
698 {
699         struct obd_device *obd = class_exp2obd(exp);
700         struct obd_export *cobd_exp;
701
702         if (obd == NULL) {
703                 CERROR("invalid client cookie "LPX64"\n", 
704                        exp->exp_handle.h_cookie);
705                 return -EINVAL;
706         }
707         cobd_exp = cobd_get_exp(obd);
708         return obd_commitrw(cmd, cobd_exp, oa, objcount, obj, niocount, 
709                             local, oti, rc);
710 }
711
712 static int cobd_flush(struct obd_device *obd)
713 {
714         return 0; 
715 }
716
717 static int cobd_iocontrol(unsigned int cmd, struct obd_export *exp,
718                           int len, void *karg, void *uarg)
719 {
720         struct obd_device *obd = class_exp2obd(exp);
721         struct cache_obd  *cobd = &obd->u.cobd;
722         struct obd_export *cobd_exp;
723         int rc = 0;
724         ENTRY;
725
726         down(&cobd->sem);
727         
728         switch (cmd) {
729         case OBD_IOC_COBD_CON:
730                 if (!cobd->cache_on) {
731                         struct lustre_handle conn = {0};
732
733                         rc = client_obd_disconnect(obd, cobd->master_exp, 0);
734                         rc = client_obd_connect(obd, cobd->cache_name, &conn, 0);
735                         if (rc)
736                                 GOTO(out, rc);
737                         cobd->cache_exp = class_conn2export(&conn);
738                         cobd->cache_on = 1;
739                 }
740                 break;
741         case OBD_IOC_COBD_COFF: 
742                 if (cobd->cache_on) {
743                         struct lustre_handle conn = {0,};
744                         struct obd_device *master = NULL;
745                         struct obd_device *cache = NULL;
746                         int easize, cooksize;
747
748                         cache = class_exp2obd(cobd->cache_exp); 
749                         easize = cache->u.cli.cl_max_mds_easize; 
750                         cooksize = cache->u.cli.cl_max_mds_cookiesize;
751                         
752                         rc = client_obd_disconnect(obd, cobd->cache_exp, 0);
753                         rc = client_obd_connect(obd, cobd->master_name, &conn, 0);
754                         if (rc)
755                                 GOTO(out, rc);
756                         cobd->master_exp = class_conn2export(&conn);
757
758                         master = class_exp2obd(cobd->master_exp);
759                         master->u.cli.cl_max_mds_easize = easize;
760                         master->u.cli.cl_max_mds_cookiesize = cooksize;
761                         cobd->cache_on = 0;
762                 }
763                 break;
764         case OBD_IOC_COBD_CFLUSH:
765                 if (cobd->cache_on) {
766                         cobd->cache_on = 0;
767                         cobd_flush(obd);
768                 } else {
769                         CERROR("%s: cache is turned off\n", obd->obd_name);
770                 }
771                 break;
772         default:
773                 cobd_exp = cobd_get_exp(obd);
774                 rc = obd_iocontrol(cmd, cobd_exp, len, karg, uarg);
775         }
776
777         EXIT;
778 out:
779         up(&cobd->sem);
780         return rc;
781 }
782
783 static int cobd_llog_init(struct obd_device *obd, struct obd_llogs *llogs, 
784                           struct obd_device *disk_obd, int count, 
785                           struct llog_catid *logid)
786 {
787         struct obd_export *cobd_exp;
788         struct obd_device *cobd_obd;
789
790         cobd_exp = cobd_get_exp(obd);
791         cobd_obd = class_exp2obd(cobd_exp);
792         
793         return obd_llog_init(cobd_obd, &cobd_obd->obd_llogs, 
794                              disk_obd, count, logid);
795 }
796
797 static int cobd_llog_finish(struct obd_device *obd, struct obd_llogs *llogs, 
798                             int count)
799 {
800         struct obd_export *cobd_exp;
801         struct obd_device *cobd_obd;
802
803         cobd_exp = cobd_get_exp(obd);
804         cobd_obd = class_exp2obd(cobd_exp);
805
806         return obd_llog_finish(cobd_obd, &cobd_obd->obd_llogs, count);
807 }
808
809 static int cobd_notify(struct obd_device *obd, struct obd_device *watched,
810                        int active, void *data)
811 {
812         struct obd_export *cobd_exp;
813
814         cobd_exp = cobd_get_exp(obd);
815
816         return obd_notify(class_exp2obd(cobd_exp), watched, active, data);
817 }
818
819 static int cobd_pin(struct obd_export *exp, obd_id ino, __u32 gen,
820                     int type, struct obd_client_handle *handle, int flag)
821 {
822         struct obd_device *obd = class_exp2obd(exp);
823         struct obd_export *cobd_exp;
824
825         if (obd == NULL) {
826                 CERROR("invalid client cookie "LPX64"\n", 
827                        exp->exp_handle.h_cookie);
828                 return -EINVAL;
829         }
830         cobd_exp = cobd_get_exp(obd);
831
832         return obd_pin(cobd_exp, ino, gen, type, handle, flag);
833 }
834
835 static int cobd_unpin(struct obd_export *exp,
836                       struct obd_client_handle *handle, int flag)
837 {
838         struct obd_device *obd = class_exp2obd(exp);
839         struct obd_export *cobd_exp;
840
841         if (obd == NULL) {
842                 CERROR("invalid client cookie "LPX64"\n", 
843                        exp->exp_handle.h_cookie);
844                 return -EINVAL;
845         }
846         cobd_exp = cobd_get_exp(obd);
847
848         return obd_unpin(cobd_exp, handle, flag);
849 }
850
851 static int cobd_init_ea_size(struct obd_export *exp, int easize, int cookiesize)
852 {
853         struct obd_export *cobd_exp;
854
855         cobd_exp = cobd_get_exp(exp->exp_obd);
856         return obd_init_ea_size(cobd_exp, easize, cookiesize);
857 }
858
859 static int  cobd_import_event(struct obd_device *obd,
860                               struct obd_import *imp,
861                               enum obd_import_event event)
862 {
863         struct obd_export *cobd_exp;
864
865         cobd_exp = cobd_get_exp(obd);
866
867         obd_import_event(class_exp2obd(cobd_exp), imp, event);
868         
869         return 0; 
870 }
871
872 static int cobd_md_getattr(struct obd_export *exp, struct lustre_id *id,
873                            __u64 valid, unsigned int ea_size,
874                            struct ptlrpc_request **request)
875 {
876         struct obd_device *obd = class_exp2obd(exp);
877         struct obd_export *cobd_exp;
878
879         if (obd == NULL) {
880                 CERROR("invalid client cookie "LPX64"\n", 
881                        exp->exp_handle.h_cookie);
882                 return -EINVAL;
883         }
884         cobd_exp = cobd_get_exp(obd);
885         return md_getattr(cobd_exp, id, valid, ea_size, request);
886 }
887
888 static int cobd_md_req2lustre_md (struct obd_export *mdc_exp, 
889                                   struct ptlrpc_request *req, unsigned int offset,
890                                   struct obd_export *osc_exp, struct lustre_md *md)
891 {
892         struct obd_device *obd = class_exp2obd(mdc_exp);
893         struct obd_export *cobd_exp;
894
895         if (obd == NULL) {
896                 CERROR("invalid client cookie "LPX64"\n", 
897                        mdc_exp->exp_handle.h_cookie);
898                 return -EINVAL;
899         }
900         cobd_exp = cobd_get_exp(obd);
901         return md_req2lustre_md(cobd_exp, req, offset, osc_exp, md);
902 }
903
904 static int cobd_md_change_cbdata(struct obd_export *exp, struct lustre_id *id, 
905                                  ldlm_iterator_t it, void *data)
906 {
907         struct obd_device *obd = class_exp2obd(exp);
908         struct obd_export *cobd_exp;
909
910         if (obd == NULL) {
911                 CERROR("invalid client cookie "LPX64"\n", 
912                        exp->exp_handle.h_cookie);
913                 return -EINVAL;
914         }
915         cobd_exp = cobd_get_exp(obd);
916         return md_change_cbdata(cobd_exp, id, it, data);
917 }
918
919 static int cobd_md_getattr_lock(struct obd_export *exp, struct lustre_id *id,
920                                 char *filename, int namelen, __u64 valid,
921                                 unsigned int ea_size, struct ptlrpc_request **request)
922 {
923         struct obd_device *obd = class_exp2obd(exp);
924         struct obd_export *cobd_exp;
925
926         if (obd == NULL) {
927                 CERROR("invalid client cookie "LPX64"\n", 
928                        exp->exp_handle.h_cookie);
929                 return -EINVAL;
930         }
931         cobd_exp = cobd_get_exp(obd);
932         return md_getattr_lock(cobd_exp, id, filename, namelen, valid,
933                                ea_size, request);
934 }
935
936 static int cobd_md_create(struct obd_export *exp, struct mdc_op_data *op_data,
937                           const void *data, int datalen, int mode, 
938                           __u32 uid, __u32 gid, __u64 rdev, 
939                           struct ptlrpc_request **request)
940 {
941         struct obd_device *obd = class_exp2obd(exp);
942         struct obd_export *cobd_exp;
943
944         if (obd == NULL) {
945                 CERROR("invalid client cookie "LPX64"\n", 
946                        exp->exp_handle.h_cookie);
947                 return -EINVAL;
948         }
949         cobd_exp = cobd_get_exp(obd);
950         return md_create(cobd_exp, op_data, data, datalen, mode,
951                          uid, gid, rdev, request);
952 }
953
954 static int cobd_md_unlink(struct obd_export *exp, struct mdc_op_data *data,
955                           struct ptlrpc_request **request)
956 {
957         struct obd_device *obd = class_exp2obd(exp);
958         struct obd_export *cobd_exp;
959
960         if (obd == NULL) {
961                 CERROR("invalid client cookie "LPX64"\n", 
962                        exp->exp_handle.h_cookie);
963                 return -EINVAL;
964         }
965         cobd_exp = cobd_get_exp(obd);
966         return md_unlink(cobd_exp, data, request);
967 }
968
969 static int cobd_md_valid_attrs(struct obd_export *exp,
970                                struct lustre_id *id)
971 {
972         struct obd_device *obd = class_exp2obd(exp);
973         struct obd_export *cobd_exp;
974
975         if (obd == NULL) {
976                 CERROR("invalid client cookie "LPX64"\n", 
977                        exp->exp_handle.h_cookie);
978                 return -EINVAL;
979         }
980         cobd_exp = cobd_get_exp(obd);
981         return md_valid_attrs(cobd_exp, id);
982 }
983
984 static int cobd_md_rename(struct obd_export *exp, struct mdc_op_data *data,
985                           const char *old, int oldlen, const char *new, 
986                           int newlen, struct ptlrpc_request **request)
987 {
988         struct obd_device *obd = class_exp2obd(exp);
989         struct obd_export *cobd_exp;
990
991         if (obd == NULL) {
992                 CERROR("invalid client cookie "LPX64"\n", 
993                        exp->exp_handle.h_cookie);
994                 return -EINVAL;
995         }
996         cobd_exp = cobd_get_exp(obd);
997         return md_rename(cobd_exp, data, old, oldlen, new, newlen, request);
998 }
999
1000 static int cobd_md_link(struct obd_export *exp, struct mdc_op_data *data,
1001                         struct ptlrpc_request **request)
1002 {
1003         struct obd_device *obd = class_exp2obd(exp);
1004         struct obd_export *cobd_exp;
1005
1006         if (obd == NULL) {
1007                 CERROR("invalid client cookie "LPX64"\n", 
1008                        exp->exp_handle.h_cookie);
1009                 return -EINVAL;
1010         }
1011         cobd_exp = cobd_get_exp(obd);
1012         return md_link(cobd_exp, data, request);
1013 }
1014
1015 static int cobd_md_setattr(struct obd_export *exp, struct mdc_op_data *data,
1016                            struct iattr *iattr, void *ea, int ealen, void *ea2, 
1017                            int ea2len, struct ptlrpc_request **request)
1018 {
1019         struct obd_device *obd = class_exp2obd(exp);
1020         struct obd_export *cobd_exp;
1021
1022         if (obd == NULL) {
1023                 CERROR("invalid client cookie "LPX64"\n", 
1024                        exp->exp_handle.h_cookie);
1025                 return -EINVAL;
1026         }
1027         cobd_exp = cobd_get_exp(obd);
1028         return md_setattr(cobd_exp, data, iattr, ea, ealen, ea2, ea2len, request);
1029 }
1030
1031 static int cobd_md_readpage(struct obd_export *exp,
1032                             struct lustre_id *mdc_id,
1033                             __u64 offset, struct page *page, 
1034                             struct ptlrpc_request **request)
1035 {
1036         struct obd_device *obd = class_exp2obd(exp);
1037         struct obd_export *cobd_exp;
1038
1039         if (obd == NULL) {
1040                 CERROR("invalid client cookie "LPX64"\n", 
1041                        exp->exp_handle.h_cookie);
1042                 return -EINVAL;
1043         }
1044         cobd_exp = cobd_get_exp(obd);
1045         return md_readpage(cobd_exp, mdc_id, offset, page, request);
1046 }
1047
1048 static int cobd_md_close(struct obd_export *exp, struct obdo *obdo,
1049                          struct obd_client_handle *och, 
1050                          struct ptlrpc_request **request)
1051 {
1052         struct obd_device *obd = class_exp2obd(exp);
1053         struct obd_export *cobd_exp;
1054
1055         if (obd == NULL) {
1056                 CERROR("invalid client cookie "LPX64"\n", 
1057                        exp->exp_handle.h_cookie);
1058                 return -EINVAL;
1059         }
1060         cobd_exp = cobd_get_exp(obd);
1061         return md_close(cobd_exp, obdo, och, request);
1062 }
1063
1064 static int cobd_md_done_writing(struct obd_export *exp, struct obdo *obdo)
1065 {
1066         struct obd_device *obd = class_exp2obd(exp);
1067         struct obd_export *cobd_exp;
1068
1069         if (obd == NULL) {
1070                 CERROR("invalid client cookie "LPX64"\n", 
1071                        exp->exp_handle.h_cookie);
1072                 return -EINVAL;
1073         }
1074         cobd_exp = cobd_get_exp(obd);
1075         return md_done_writing(cobd_exp, obdo);
1076 }
1077
1078 static int cobd_md_sync(struct obd_export *exp, struct lustre_id *id,
1079                         struct ptlrpc_request **request)
1080 {
1081         struct obd_device *obd = class_exp2obd(exp);
1082         struct obd_export *cobd_exp;
1083
1084         if (obd == NULL) {
1085                 CERROR("invalid client cookie "LPX64"\n", 
1086                        exp->exp_handle.h_cookie);
1087                 return -EINVAL;
1088         }
1089         cobd_exp = cobd_get_exp(obd);
1090         
1091         return md_sync(cobd_exp, id, request);
1092 }
1093
1094 static int cobd_md_set_open_replay_data(struct obd_export *exp,
1095                                         struct obd_client_handle *och,
1096                                         struct ptlrpc_request *open_req)
1097 {
1098         struct obd_device *obd = class_exp2obd(exp);
1099         struct obd_export *cobd_exp;
1100
1101         if (obd == NULL) {
1102                 CERROR("invalid client cookie "LPX64"\n", 
1103                        exp->exp_handle.h_cookie);
1104                 return -EINVAL;
1105         }
1106         cobd_exp = cobd_get_exp(obd);
1107         
1108         return md_set_open_replay_data(cobd_exp, och, open_req);
1109 }
1110
1111 static int cobd_md_clear_open_replay_data(struct obd_export *exp,
1112                                           struct obd_client_handle *och)
1113 {
1114         struct obd_device *obd = class_exp2obd(exp);
1115         struct obd_export *cobd_exp;
1116
1117         if (obd == NULL) {
1118                 CERROR("invalid client cookie "LPX64"\n", 
1119                        exp->exp_handle.h_cookie);
1120                 return -EINVAL;
1121         }
1122         cobd_exp = cobd_get_exp(obd);
1123  
1124         return md_clear_open_replay_data(cobd_exp, och);
1125 }
1126
1127 static int cobd_md_store_inode_generation(struct obd_export *exp,
1128                                           struct ptlrpc_request *req, 
1129                                           int reqoff, int repoff)
1130 {
1131         struct obd_device *obd = class_exp2obd(exp);
1132         struct obd_export *cobd_exp;
1133
1134         if (obd == NULL) {
1135                 CERROR("invalid client cookie "LPX64"\n", 
1136                        exp->exp_handle.h_cookie);
1137                 return -EINVAL;
1138         }
1139         cobd_exp = cobd_get_exp(obd);
1140
1141         return md_store_inode_generation(cobd_exp, req, reqoff, repoff);
1142 }
1143
1144 static int cobd_md_set_lock_data(struct obd_export *exp, __u64 *l, void *data)
1145 {
1146         struct obd_device *obd = class_exp2obd(exp);
1147         struct obd_export *cobd_exp;
1148
1149         if (obd == NULL) {
1150                 CERROR("invalid client cookie "LPX64"\n", 
1151                        exp->exp_handle.h_cookie);
1152                 return -EINVAL;
1153         }
1154         cobd_exp = cobd_get_exp(obd);
1155
1156         return md_set_lock_data(cobd_exp, l, data);
1157 }
1158
1159 static int cobd_md_enqueue(struct obd_export *exp, int lock_type,
1160                            struct lookup_intent *it, int lock_mode,
1161                            struct mdc_op_data *data, struct lustre_handle *lockh,
1162                            void *lmm, int lmmsize, 
1163                            ldlm_completion_callback cb_completion,
1164                            ldlm_blocking_callback cb_blocking, void *cb_data)
1165 {
1166         struct obd_device *obd = class_exp2obd(exp);
1167         struct obd_export *cobd_exp;
1168
1169         if (obd == NULL) {
1170                 CERROR("invalid client cookie "LPX64"\n", 
1171                        exp->exp_handle.h_cookie);
1172                 return -EINVAL;
1173         }
1174         cobd_exp = cobd_get_exp(obd);
1175         return md_enqueue(cobd_exp, lock_type, it, lock_mode, data,
1176                           lockh, lmm, lmmsize, cb_completion, cb_blocking,
1177                           cb_data);
1178 }
1179
1180 static int cobd_md_intent_lock(struct obd_export *exp, struct lustre_id *pid, 
1181                                const char *name, int len, void *lmm, int lmmsize,
1182                                struct lustre_id *cid, struct lookup_intent *it,
1183                                int lookup_flags, struct ptlrpc_request **reqp,
1184                                ldlm_blocking_callback cb_blocking)
1185 {
1186         struct obd_device *obd = class_exp2obd(exp);
1187         struct obd_export *cobd_exp;
1188
1189         if (obd == NULL) {
1190                 CERROR("invalid client cookie "LPX64"\n", 
1191                        exp->exp_handle.h_cookie);
1192                 return -EINVAL;
1193         }
1194         cobd_exp = cobd_get_exp(obd);
1195         return md_intent_lock(cobd_exp, pid, name, len, lmm, lmmsize,
1196                               cid, it, lookup_flags, reqp, cb_blocking);
1197 }
1198
1199 static struct obd_device *cobd_md_get_real_obd(struct obd_export *exp,
1200                                                struct lustre_id *id)
1201 {
1202         struct obd_device *obd = class_exp2obd(exp);
1203         struct obd_export *cobd_exp;
1204
1205         if (obd == NULL) {
1206                 CERROR("invalid client cookie "LPX64"\n", 
1207                        exp->exp_handle.h_cookie);
1208                 return NULL;
1209         }
1210         cobd_exp = cobd_get_exp(obd);
1211         return md_get_real_obd(cobd_exp, id);
1212 }
1213
1214 static int cobd_md_change_cbdata_name(struct obd_export *exp,
1215                                       struct lustre_id *id, char *name,
1216                                       int namelen, struct lustre_id *id2,
1217                                       ldlm_iterator_t it, void *data)
1218 {
1219         struct obd_device *obd = class_exp2obd(exp);
1220         struct obd_export *cobd_exp;
1221
1222         if (obd == NULL) {
1223                 CERROR("invalid client cookie "LPX64"\n", 
1224                        exp->exp_handle.h_cookie);
1225                 return -EINVAL;
1226         }
1227         cobd_exp = cobd_get_exp(obd);
1228         return md_change_cbdata_name(cobd_exp, id, name, namelen,
1229                                      id2, it, data);
1230 }
1231 static struct obd_ops cobd_obd_ops = {
1232         .o_owner                = THIS_MODULE,
1233         .o_attach               = cobd_attach,
1234         .o_detach               = cobd_detach,
1235         .o_setup                = cobd_setup,
1236         .o_cleanup              = cobd_cleanup,
1237         .o_connect              = cobd_connect,
1238         .o_disconnect           = cobd_disconnect,
1239         .o_set_info             = cobd_set_info,
1240         .o_get_info             = cobd_get_info,
1241         .o_statfs               = cobd_statfs,
1242
1243         .o_packmd               = cobd_packmd,
1244         .o_unpackmd             = cobd_unpackmd,
1245         .o_create               = cobd_create,
1246         .o_destroy              = cobd_destroy,
1247         .o_precleanup           = cobd_precleanup,
1248         .o_getattr              = cobd_getattr,
1249         .o_getattr_async        = cobd_getattr_async,
1250         .o_setattr              = cobd_setattr,
1251
1252         .o_brw                  = cobd_brw,
1253         .o_brw_async            = cobd_brw_async,
1254         .o_prep_async_page      = cobd_prep_async_page,
1255         .o_queue_async_io       = cobd_queue_async_io,
1256         .o_set_async_flags      = cobd_set_async_flags,
1257         .o_queue_group_io       = cobd_queue_group_io,
1258         .o_trigger_group_io     = cobd_trigger_group_io,
1259         .o_teardown_async_page  = cobd_teardown_async_page,
1260         .o_preprw               = cobd_preprw,
1261         .o_punch                = cobd_punch,
1262         .o_sync                 = cobd_sync,
1263         .o_enqueue              = cobd_enqueue,
1264         .o_match                = cobd_match,
1265         .o_change_cbdata        = cobd_change_cbdata,
1266         .o_cancel               = cobd_cancel,
1267         .o_cancel_unused        = cobd_cancel_unused,
1268         .o_iocontrol            = cobd_iocontrol,
1269         .o_commitrw             = cobd_commitrw,
1270         .o_llog_init            = cobd_llog_init,
1271         .o_llog_finish          = cobd_llog_finish,
1272         .o_notify               = cobd_notify,
1273         .o_pin                  = cobd_pin,
1274         .o_unpin                = cobd_unpin,
1275         .o_import_event         = cobd_import_event,
1276         .o_init_ea_size         = cobd_init_ea_size,
1277 };
1278
1279 struct md_ops cobd_md_ops = {
1280         .m_getstatus            = cobd_md_getstatus,
1281         .m_getattr              = cobd_md_getattr,
1282         .m_req2lustre_md        = cobd_md_req2lustre_md,
1283         .m_change_cbdata        = cobd_md_change_cbdata,
1284         .m_getattr_lock         = cobd_md_getattr_lock,
1285         .m_create               = cobd_md_create,
1286         .m_unlink               = cobd_md_unlink,
1287         .m_valid_attrs          = cobd_md_valid_attrs,
1288         .m_rename               = cobd_md_rename,
1289         .m_link                 = cobd_md_link,
1290         .m_setattr              = cobd_md_setattr,
1291         .m_readpage             = cobd_md_readpage,
1292         .m_close                = cobd_md_close,
1293         .m_done_writing         = cobd_md_done_writing,
1294         .m_sync                 = cobd_md_sync,
1295         .m_set_open_replay_data = cobd_md_set_open_replay_data,
1296         .m_clear_open_replay_data = cobd_md_clear_open_replay_data,
1297         .m_store_inode_generation = cobd_md_store_inode_generation,
1298         .m_set_lock_data        = cobd_md_set_lock_data,
1299         .m_enqueue              = cobd_md_enqueue,
1300         .m_get_real_obd         = cobd_md_get_real_obd,
1301         .m_intent_lock          = cobd_md_intent_lock,
1302         .m_change_cbdata_name   = cobd_md_change_cbdata_name,
1303 };
1304
1305 static int __init cobd_init(void)
1306 {
1307         struct lprocfs_static_vars lvars;
1308         ENTRY;
1309
1310         printk(KERN_INFO "Lustre: Caching OBD driver; info@clusterfs.com\n");
1311
1312         lprocfs_init_vars(cobd, &lvars);
1313         RETURN(class_register_type(&cobd_obd_ops, &cobd_md_ops,
1314                                    lvars.module_vars, OBD_CACHE_DEVICENAME));
1315 }
1316
1317 static void /*__exit*/ cobd_exit(void)
1318 {
1319         class_unregister_type(OBD_CACHE_DEVICENAME);
1320 }
1321
1322 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
1323 MODULE_DESCRIPTION("Lustre Caching OBD driver");
1324 MODULE_LICENSE("GPL");
1325
1326 module_init(cobd_init);
1327 module_exit(cobd_exit);