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