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