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