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