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