Whamcloud - gitweb
- add obdfilter to our setup, cleanup and debug environment
[fs/lustre-release.git] / lustre / include / linux / obd_class.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2001, 2002 Cluster File Systems, Inc.
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
23 #ifndef __LINUX_CLASS_OBD_H
24 #define __LINUX_CLASS_OBD_H
25
26 #ifndef __KERNEL__
27 #include <stdint.h>
28 #define __KERNEL__
29 #include <linux/list.h>
30 #undef __KERNEL__
31 #else 
32 #include <asm/segment.h>
33 #include <asm/uaccess.h>
34 #include <linux/types.h>
35 #include <linux/fs.h>
36 #include <linux/time.h>
37
38 #include <linux/obd_support.h>
39 #include <linux/obd.h>
40 #include <linux/lustre_lib.h>
41 #include <linux/lustre_idl.h>
42 #endif
43
44 /*
45  *  ======== OBD Device Declarations ===========
46  */
47 #define MAX_OBD_DEVICES 8
48 extern struct obd_device obd_dev[MAX_OBD_DEVICES];
49
50 #define OBD_ATTACHED 0x1
51 #define OBD_SET_UP   0x2
52
53 extern struct proc_dir_entry *
54 proc_lustre_register_obd_device(struct obd_device *obd);
55 extern void proc_lustre_release_obd_device(struct obd_device *obd);
56 extern void proc_lustre_remove_obd_entry(const char* name,
57                                          struct obd_device *obd);
58
59 /*
60  *  ======== OBD Operations Declarations ===========
61  */
62
63 #define OBD_BRW_READ    1
64 #define OBD_BRW_WRITE   2
65 #define OBD_BRW_RWMASK  OBD_BRW_READ | OBD_BRW_WRITE
66 #define OBD_BRW_CREATE  4
67
68 #ifdef __KERNEL__
69 struct obd_request {
70         struct obdo *oa;
71         struct obd_conn *conn;
72         __u32 plen1;
73         char *pbuf1;
74 };
75
76 static inline int obd_check_conn(struct obd_conn *conn) 
77 {
78         struct obd_device *obd;
79         if (!conn) {
80                 printk("obd_check_conn: NULL conn\n");
81                 return -ENOTCONN;
82         }
83         obd = conn->oc_dev;
84         if (!obd) {
85                 printk("obd_check_conn: NULL obd\n");
86                 return -ENODEV;
87         }
88
89         if (!obd->obd_flags & OBD_ATTACHED ) {
90                 printk("obd_check_conn: obd %d not attached\n", obd->obd_minor);
91                 return -ENODEV;
92         }
93
94         if (!obd->obd_flags & OBD_SET_UP) {
95                 printk("obd_check_conn: obd %d not setup\n", obd->obd_minor); 
96                 return -ENODEV;
97         }
98
99         if (!obd->obd_type) {
100                 printk("obd_check_conn: obd %d not typed\n", obd->obd_minor);
101                 return -ENODEV;
102         }
103
104         if (!obd->obd_type->typ_ops) {
105                 printk("obd_check_conn: obd %d no operations\n",
106                        obd->obd_minor);
107                 return -EOPNOTSUPP;
108         }
109         return 0;
110 }
111
112 #define OBT(dev)        dev->obd_type
113 #define OBP(dev,op)     dev->obd_type->typ_ops->o_ ## op
114
115 #define OBD_CHECK_SETUP(conn)                                   \
116 do {                                                            \
117         if (!(conn)) {                                          \
118                 CERROR("NULL connection\n");                    \
119                 return -EINVAL;                                 \
120         }                                                       \
121                                                                 \
122         if (!((conn)->oc_dev)) {                                \
123                 CERROR("NULL device\n");                        \
124                 return -EINVAL;                                 \
125         }                                                       \
126                                                                 \
127         if ( !((conn)->oc_dev->obd_flags & OBD_SET_UP) ) {      \
128                 CERROR("Device %d not setup\n",                 \
129                        (conn)->oc_dev->obd_minor);              \
130                 return -EINVAL;                                 \
131         }                                                       \
132 } while (0)
133
134 #define OBD_CHECK_OP(conn,op)                                   \
135 do {                                                            \
136         int rc = obd_check_conn(conn);                          \
137         if (rc) {                                               \
138                 printk("obd: error in operation: " #op "\n");   \
139                 return rc;                                      \
140         }                                                       \
141         if (!OBP(conn->oc_dev,op)) {                            \
142                 printk("obd_" #op ": dev %d no operation\n",    \
143                        conn->oc_dev->obd_minor);                \
144                 return -EOPNOTSUPP;                             \
145         }                                                       \
146 } while (0)
147
148 static inline int obd_get_info(struct obd_conn *conn, obd_count keylen,
149                                void *key, obd_count *vallen, void **val)
150 {
151         int rc;
152         OBD_CHECK_SETUP(conn);
153         OBD_CHECK_OP(conn,get_info);
154         
155         rc = OBP(conn->oc_dev, get_info)(conn, keylen, key, vallen, val);
156         EXIT;
157         return rc;
158 }
159
160 static inline int obd_set_info(struct obd_conn *conn, obd_count keylen,
161                                void *key, obd_count vallen, void *val)
162 {
163         int rc;
164         OBD_CHECK_SETUP(conn);
165         OBD_CHECK_OP(conn,set_info);
166         
167         rc = OBP(conn->oc_dev, set_info)(conn, keylen, key, vallen, val);
168         EXIT;
169         return rc;
170 }
171
172 static inline int obd_setup(struct obd_device *obd, int datalen, void *data)
173 {
174         struct obd_conn conn;
175         int rc;
176         conn.oc_dev = obd;
177
178         OBD_CHECK_OP((&conn),setup);
179         
180         rc = OBP(conn.oc_dev, setup)(obd, datalen, data);
181         EXIT;
182         return rc;
183 }
184
185 static inline int obd_cleanup(struct obd_device *obd)
186 {
187         struct obd_conn conn;
188         int rc;
189         conn.oc_dev = obd;
190
191         OBD_CHECK_SETUP(&conn);
192         OBD_CHECK_OP((&conn),cleanup);
193         
194         rc = OBP(conn.oc_dev, cleanup)(obd);
195         EXIT;
196         return rc;
197 }
198
199 static inline int obd_create(struct obd_conn *conn, struct obdo *obdo) 
200 {
201         int rc;
202         OBD_CHECK_SETUP(conn);
203         OBD_CHECK_OP(conn,create);
204         
205         rc = OBP(conn->oc_dev, create)(conn, obdo);
206         EXIT;
207         return rc;
208 }
209
210 static inline int obd_destroy(struct obd_conn *conn, struct obdo *obdo) 
211 {
212         int rc;
213         OBD_CHECK_SETUP(conn);
214         OBD_CHECK_OP(conn,destroy);
215         
216         rc = OBP(conn->oc_dev, destroy)(conn, obdo);
217         EXIT;
218         return rc;
219 }
220
221 static inline int obd_getattr(struct obd_conn *conn, struct obdo *obdo) 
222 {
223         int rc;
224         OBD_CHECK_SETUP(conn);
225         OBD_CHECK_OP(conn,getattr);
226         
227         rc = OBP(conn->oc_dev, getattr)(conn, obdo);
228         EXIT;
229         return rc;
230 }
231
232 static inline int obd_close(struct obd_conn *conn, struct obdo *obdo) 
233 {
234         int rc;
235         OBD_CHECK_SETUP(conn);
236         OBD_CHECK_OP(conn,close);
237         
238         rc = OBP(conn->oc_dev, close)(conn, obdo);
239         EXIT;
240         return rc;
241 }
242 static inline int obd_open(struct obd_conn *conn, struct obdo *obdo) 
243 {
244         int rc;
245         OBD_CHECK_SETUP(conn);
246         OBD_CHECK_OP(conn,open);
247         
248         rc = OBP(conn->oc_dev, open) (conn, obdo);
249         EXIT;
250         return rc;
251 }
252
253 static inline int obd_setattr(struct obd_conn *conn, struct obdo *obdo) 
254 {
255         int rc;
256         OBD_CHECK_SETUP(conn);
257         OBD_CHECK_OP(conn,setattr);
258         
259         rc = OBP(conn->oc_dev, setattr)(conn, obdo);
260         EXIT;
261         return rc;
262 }
263
264 static inline int obd_connect(struct obd_conn *conn)
265 {
266         int rc;
267         OBD_CHECK_SETUP(conn);
268         OBD_CHECK_OP(conn,connect);
269         
270         rc = OBP(conn->oc_dev, connect)(conn);
271         EXIT;
272         return rc;
273 }
274
275 static inline int obd_disconnect(struct obd_conn *conn)
276 {
277         int rc;
278         OBD_CHECK_SETUP(conn);
279         OBD_CHECK_OP(conn,disconnect);
280         
281         rc = OBP(conn->oc_dev, disconnect)(conn);
282         EXIT;
283         return rc;
284 }
285
286 static inline int obd_statfs(struct obd_conn *conn, struct statfs *buf)
287 {
288         int rc;
289         OBD_CHECK_SETUP(conn);
290         OBD_CHECK_OP(conn,statfs);
291         
292         rc = OBP(conn->oc_dev, statfs)(conn, buf);
293         EXIT;
294         return rc;
295 }
296
297 static inline int obd_punch(struct obd_conn *conn, struct obdo *tgt,
298                             obd_size count, obd_off offset)
299 {
300         int rc;
301         OBD_CHECK_SETUP(conn);
302         OBD_CHECK_OP(conn,punch);
303         
304         rc = OBP(conn->oc_dev, punch)(conn, tgt, count, offset);
305         EXIT;
306         return rc;
307 }
308
309 static inline int obd_brw(int rw, struct obd_conn *conn, obd_count num_oa,
310                           struct obdo **oa, obd_count *oa_bufs,
311                           struct page **buf, obd_size *count, obd_off *offset,
312                           obd_flag *flags)
313 {
314         int rc;
315         OBD_CHECK_SETUP(conn);
316         OBD_CHECK_OP(conn,brw);
317         
318         rc = OBP(conn->oc_dev, brw)(rw, conn, num_oa, oa, oa_bufs, buf,
319                                     count, offset, flags);
320         EXIT;
321         return rc;
322 }
323
324 static inline int obd_preprw(int cmd, struct obd_conn *conn, 
325                              int objcount, struct obd_ioobj *obj, 
326                              int niocount, struct niobuf *nb, 
327                              struct niobuf *res)
328 {
329         int rc;
330         OBD_CHECK_SETUP(conn);
331         OBD_CHECK_OP(conn, preprw);
332         
333         rc = OBP(conn->oc_dev, preprw)(cmd, conn, objcount, obj, niocount, nb,
334                                        res);
335         EXIT;
336         return rc;
337 }
338
339 static inline int obd_commitrw(int cmd, struct obd_conn *conn, 
340                         int objcount, struct obd_ioobj *obj, 
341                         int niocount, struct niobuf *res)
342 {
343         int rc;
344         OBD_CHECK_SETUP(conn);
345         OBD_CHECK_OP(conn, commitrw);
346         
347         rc = OBP(conn->oc_dev, commitrw)(cmd, conn, objcount, obj, niocount,
348                                          res);
349         EXIT;
350         return rc;
351 }
352
353 static inline int obd_iocontrol(int cmd, struct obd_conn *conn, 
354                                 int len, void *karg, void *uarg)
355 {
356         int rc;
357         OBD_CHECK_SETUP(conn);
358         OBD_CHECK_OP(conn, iocontrol);
359         
360         rc = OBP(conn->oc_dev, iocontrol)(cmd, conn, len, karg, uarg);
361         EXIT;
362         return rc;
363 }
364
365 #endif 
366
367 /*
368  *  ======== OBD Metadata Support  ===========
369  */
370
371 extern int obd_init_obdo_cache(void);
372 extern void obd_cleanup_obdo_cache(void);
373
374
375 static inline int obdo_has_inline(struct obdo *obdo)
376 {
377         return (obdo->o_valid & OBD_MD_FLINLINE &&
378                 obdo->o_obdflags & OBD_FL_INLINEDATA);
379 };
380
381 static inline int obdo_has_obdmd(struct obdo *obdo)
382 {
383         return (obdo->o_valid & OBD_MD_FLOBDMD &&
384                 obdo->o_obdflags & OBD_FL_OBDMDEXISTS);
385 };
386
387 #ifdef __KERNEL__
388 /* support routines */
389 extern kmem_cache_t *obdo_cachep;
390
391 static __inline__ struct obdo *obdo_alloc(void)
392 {
393         struct obdo *oa = NULL;
394
395         oa = kmem_cache_alloc(obdo_cachep, SLAB_KERNEL);
396         memset(oa, 0, sizeof (*oa));
397
398         return oa;
399 }
400
401 static __inline__ void obdo_free(struct obdo *oa)
402 {
403         if ( !oa ) 
404                 return;
405         kmem_cache_free(obdo_cachep, oa);
406 }
407
408 static __inline__ struct obdo *obdo_fromid(struct obd_conn *conn, obd_id id,
409                                            obd_mode mode, obd_flag valid)
410 {
411         struct obdo *oa;
412         int err;
413
414         ENTRY;
415         oa = obdo_alloc();
416         if ( !oa ) {
417                 EXIT;
418                 return ERR_PTR(-ENOMEM);
419         }
420
421         oa->o_id = id;
422         oa->o_mode = mode;
423         oa->o_valid = valid;
424         if ((err = OBP(conn->oc_dev, getattr)(conn, oa))) {
425                 obdo_free(oa);
426                 EXIT;
427                 return ERR_PTR(err);
428         }
429         EXIT;
430         return oa;
431 }
432
433 static inline void obdo_from_iattr(struct obdo *oa, struct iattr *attr)
434 {
435         unsigned int ia_valid = attr->ia_valid;
436
437         if (ia_valid & ATTR_ATIME) {
438                 oa->o_atime = attr->ia_atime;
439                 oa->o_valid |= OBD_MD_FLATIME;
440         }
441         if (ia_valid & ATTR_MTIME) {
442                 oa->o_mtime = attr->ia_mtime;
443                 oa->o_valid |= OBD_MD_FLMTIME;
444         }
445         if (ia_valid & ATTR_CTIME) {
446                 oa->o_ctime = attr->ia_ctime;
447                 oa->o_valid |= OBD_MD_FLCTIME;
448         }
449         if (ia_valid & ATTR_SIZE) {
450                 oa->o_size = attr->ia_size;
451                 oa->o_valid |= OBD_MD_FLSIZE;
452         }
453         if (ia_valid & ATTR_MODE) {
454                 oa->o_mode = attr->ia_mode;
455                 oa->o_valid |= OBD_MD_FLMODE;
456                 if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID))
457                         oa->o_mode &= ~S_ISGID;
458         }
459         if (ia_valid & ATTR_UID)
460         {
461                 oa->o_uid = attr->ia_uid;
462                 oa->o_valid |= OBD_MD_FLUID;
463         }
464         if (ia_valid & ATTR_GID) {
465                 oa->o_gid = attr->ia_gid;
466                 oa->o_valid |= OBD_MD_FLGID;
467         }
468 }
469
470
471 static inline void iattr_from_obdo(struct iattr *attr, struct obdo *oa)
472 {
473         unsigned int ia_valid = oa->o_valid;
474         
475         memset(attr, 0, sizeof(*attr));
476         if (ia_valid & OBD_MD_FLATIME) {
477                 attr->ia_atime = oa->o_atime;
478                 attr->ia_valid |= ATTR_ATIME;
479         }
480         if (ia_valid & OBD_MD_FLMTIME) {
481                 attr->ia_mtime = oa->o_mtime;
482                 attr->ia_valid |= ATTR_MTIME;
483         }
484         if (ia_valid & OBD_MD_FLCTIME) {
485                 attr->ia_ctime = oa->o_ctime;
486                 attr->ia_valid |= ATTR_CTIME;
487         }
488         if (ia_valid & OBD_MD_FLSIZE) {
489                 attr->ia_size = oa->o_size;
490                 attr->ia_valid |= ATTR_SIZE;
491         }
492         if (ia_valid & OBD_MD_FLMODE) {
493                 attr->ia_mode = oa->o_mode;
494                 attr->ia_valid |= ATTR_MODE;
495                 if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID))
496                         attr->ia_mode &= ~S_ISGID;
497         }
498         if (ia_valid & OBD_MD_FLUID)
499         {
500                 attr->ia_uid = oa->o_uid;
501                 attr->ia_valid |= ATTR_UID;
502         }
503         if (ia_valid & OBD_MD_FLGID) {
504                 attr->ia_gid = oa->o_gid;
505                 attr->ia_valid |= ATTR_GID;
506         }
507 }
508
509
510 /* WARNING: the file systems must take care not to tinker with
511    attributes they don't manage (such as blocks). */
512
513 static __inline__ void obdo_from_inode(struct obdo *dst, struct inode *src)
514 {
515         if ( dst->o_valid & OBD_MD_FLID )
516                 dst->o_id = src->i_ino;
517         if ( dst->o_valid & OBD_MD_FLATIME )
518                 dst->o_atime = src->i_atime;
519         if ( dst->o_valid & OBD_MD_FLMTIME )
520                 dst->o_mtime = src->i_mtime;
521         if ( dst->o_valid & OBD_MD_FLCTIME )
522                 dst->o_ctime = src->i_ctime;
523         if ( dst->o_valid & OBD_MD_FLSIZE )
524                 dst->o_size = src->i_size;
525         if ( dst->o_valid & OBD_MD_FLBLOCKS )   /* allocation of space */
526                 dst->o_blocks = src->i_blocks;
527         if ( dst->o_valid & OBD_MD_FLBLKSZ )
528                 dst->o_blksize = src->i_blksize;
529         if ( dst->o_valid & OBD_MD_FLMODE )
530                 dst->o_mode = src->i_mode;
531         if ( dst->o_valid & OBD_MD_FLUID )
532                 dst->o_uid = src->i_uid;
533         if ( dst->o_valid & OBD_MD_FLGID )
534                 dst->o_gid = src->i_gid;
535         if ( dst->o_valid & OBD_MD_FLFLAGS )
536                 dst->o_flags = src->i_flags;
537         if ( dst->o_valid & OBD_MD_FLNLINK )
538                 dst->o_nlink = src->i_nlink;
539         if ( dst->o_valid & OBD_MD_FLGENER ) 
540                 dst->o_generation = src->i_generation;
541 }
542
543 static __inline__ void obdo_to_inode(struct inode *dst, struct obdo *src)
544 {
545
546         if ( src->o_valid & OBD_MD_FLID )
547                 dst->i_ino = src->o_id;
548         if ( src->o_valid & OBD_MD_FLATIME ) 
549                 dst->i_atime = src->o_atime;
550         if ( src->o_valid & OBD_MD_FLMTIME ) 
551                 dst->i_mtime = src->o_mtime;
552         if ( src->o_valid & OBD_MD_FLCTIME ) 
553                 dst->i_ctime = src->o_ctime;
554         if ( src->o_valid & OBD_MD_FLSIZE ) 
555                 dst->i_size = src->o_size;
556         if ( src->o_valid & OBD_MD_FLBLOCKS ) /* allocation of space */
557                 dst->i_blocks = src->o_blocks;
558         if ( src->o_valid & OBD_MD_FLBLKSZ )
559                 dst->i_blksize = src->o_blksize;
560         if ( src->o_valid & OBD_MD_FLMODE ) 
561                 dst->i_mode = src->o_mode;
562         if ( src->o_valid & OBD_MD_FLUID ) 
563                 dst->i_uid = src->o_uid;
564         if ( src->o_valid & OBD_MD_FLGID ) 
565                 dst->i_gid = src->o_gid;
566         if ( src->o_valid & OBD_MD_FLFLAGS ) 
567                 dst->i_flags = src->o_flags;
568         if ( src->o_valid & OBD_MD_FLNLINK )
569                 dst->i_nlink = src->o_nlink;
570         if ( src->o_valid & OBD_MD_FLGENER )
571                 dst->i_generation = src->o_generation;
572 }
573
574 #endif 
575
576 static __inline__ void obdo_cpy_md(struct obdo *dst, struct obdo *src)
577 {
578 #ifdef __KERNEL__
579         CDEBUG(D_INODE, "src obdo %Ld valid 0x%x, dst obdo %Ld\n",
580                src->o_id, src->o_valid, dst->o_id);
581 #endif
582         if ( src->o_valid & OBD_MD_FLATIME ) 
583                 dst->o_atime = src->o_atime;
584         if ( src->o_valid & OBD_MD_FLMTIME ) 
585                 dst->o_mtime = src->o_mtime;
586         if ( src->o_valid & OBD_MD_FLCTIME ) 
587                 dst->o_ctime = src->o_ctime;
588         if ( src->o_valid & OBD_MD_FLSIZE ) 
589                 dst->o_size = src->o_size;
590         if ( src->o_valid & OBD_MD_FLBLOCKS ) /* allocation of space */
591                 dst->o_blocks = src->o_blocks;
592         if ( src->o_valid & OBD_MD_FLBLKSZ )
593                 dst->o_blksize = src->o_blksize;
594         if ( src->o_valid & OBD_MD_FLMODE ) 
595                 dst->o_mode = src->o_mode;
596         if ( src->o_valid & OBD_MD_FLUID ) 
597                 dst->o_uid = src->o_uid;
598         if ( src->o_valid & OBD_MD_FLGID ) 
599                 dst->o_gid = src->o_gid;
600         if ( src->o_valid & OBD_MD_FLFLAGS ) 
601                 dst->o_flags = src->o_flags;
602         /*
603         if ( src->o_valid & OBD_MD_FLOBDFLG ) 
604                 dst->o_obdflags = src->o_obdflags;
605         */
606         if ( src->o_valid & OBD_MD_FLNLINK ) 
607                 dst->o_nlink = src->o_nlink;
608         if ( src->o_valid & OBD_MD_FLGENER ) 
609                 dst->o_generation = src->o_generation;
610         if ( src->o_valid & OBD_MD_FLINLINE &&
611              src->o_obdflags & OBD_FL_INLINEDATA) {
612                 memcpy(dst->o_inline, src->o_inline, sizeof(src->o_inline));
613                 dst->o_obdflags |= OBD_FL_INLINEDATA;
614         }
615         if ( src->o_valid & OBD_MD_FLOBDMD &&
616              src->o_obdflags & OBD_FL_OBDMDEXISTS) {
617                 memcpy(dst->o_obdmd, src->o_obdmd, sizeof(src->o_obdmd));
618                 dst->o_obdflags |= OBD_FL_OBDMDEXISTS;
619         }
620
621         dst->o_valid |= src->o_valid;
622 }
623
624
625 /* returns FALSE if comparison (by flags) is same, TRUE if changed */
626 static __inline__ int obdo_cmp_md(struct obdo *dst, struct obdo *src,
627                                   obd_flag compare)
628 {
629         int res = 0;
630
631         if ( compare & OBD_MD_FLATIME )
632                 res = (res || (dst->o_atime != src->o_atime));
633         if ( compare & OBD_MD_FLMTIME )
634                 res = (res || (dst->o_mtime != src->o_mtime));
635         if ( compare & OBD_MD_FLCTIME )
636                 res = (res || (dst->o_ctime != src->o_ctime));
637         if ( compare & OBD_MD_FLSIZE )
638                 res = (res || (dst->o_size != src->o_size));
639         if ( compare & OBD_MD_FLBLOCKS ) /* allocation of space */
640                 res = (res || (dst->o_blocks != src->o_blocks));
641         if ( compare & OBD_MD_FLBLKSZ )
642                 res = (res || (dst->o_blksize != src->o_blksize));
643         if ( compare & OBD_MD_FLMODE )
644                 res = (res || (dst->o_mode != src->o_mode));
645         if ( compare & OBD_MD_FLUID )
646                 res = (res || (dst->o_uid != src->o_uid));
647         if ( compare & OBD_MD_FLGID )
648                 res = (res || (dst->o_gid != src->o_gid));
649         if ( compare & OBD_MD_FLFLAGS ) 
650                 res = (res || (dst->o_flags != src->o_flags));
651         if ( compare & OBD_MD_FLNLINK )
652                 res = (res || (dst->o_nlink != src->o_nlink));
653         if ( compare & OBD_MD_FLGENER )
654                 res = (res || (dst->o_generation != src->o_generation));
655         /* XXX Don't know if thses should be included here - wasn't previously
656         if ( compare & OBD_MD_FLINLINE )
657                 res = (res || memcmp(dst->o_inline, src->o_inline));
658         if ( compare & OBD_MD_FLOBDMD )
659                 res = (res || memcmp(dst->o_obdmd, src->o_obdmd));
660         */
661         return res;
662 }
663
664
665 #ifdef __KERNEL__
666 int obd_register_type(struct obd_ops *ops, char *nm);
667 int obd_unregister_type(char *nm);
668
669 struct obd_client {
670         struct list_head cli_chain;
671         struct obd_device *cli_obd;
672         unsigned int cli_id;
673         unsigned long cli_prealloc_quota;
674         struct list_head cli_prealloc_inodes;
675 };
676
677
678 struct obd_prealloc_inode {
679         struct list_head obd_prealloc_chain;
680         unsigned long inode;
681 };
682
683 /* generic operations shared by various OBD types */
684 int gen_multi_setup(struct obd_device *obddev, uint32_t len, void *data);
685 int gen_multi_cleanup(struct obd_device *obddev);
686 int gen_multi_attach(struct obd_device *obddev, uint32_t len, void *data);
687 int gen_multi_detach(struct obd_device *obddev);
688 int gen_connect (struct obd_conn *conn);
689 int gen_disconnect(struct obd_conn *conn);
690 struct obd_client *gen_client(const struct obd_conn *);
691 int gen_cleanup(struct obd_device *obddev);
692 int gen_copy_data(struct obd_conn *dst_conn, struct obdo *dst,
693                   struct obd_conn *src_conn, struct obdo *src,
694                   obd_size count, obd_off offset);
695
696 #endif
697
698 /* sysctl.c */
699 extern void obd_sysctl_init (void);
700 extern void obd_sysctl_clean (void);
701
702 /* pack_generic.c */
703 int lustre_pack_msg(int count, int *lens, char **bufs, int *len, char **buf);
704 int lustre_unpack_msg(char *buf, int len);
705 void *lustre_msg_buf(int n, struct lustre_msg *m);
706
707 #endif /* __LINUX_CLASS_OBD_H */