Whamcloud - gitweb
- Fixed some 64bit warnings
[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                 CERROR("obd_check_conn: NULL conn\n");
81                 RETURN(-ENOTCONN);
82         }
83         obd = conn->oc_dev;
84         if (!obd) {
85                 CERROR("obd_check_conn: NULL obd\n");
86                 RETURN(-ENODEV);
87         }
88
89         if (!obd->obd_flags & OBD_ATTACHED ) {
90                 CERROR("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                 CERROR("obd_check_conn: obd %d not setup\n", obd->obd_minor); 
96                 RETURN(-ENODEV);
97         }
98
99         if (!obd->obd_type) {
100                 CERROR("obd_check_conn: obd %d not typed\n", obd->obd_minor);
101                 RETURN(-ENODEV);
102         }
103
104         if (!obd->obd_type->typ_ops) {
105                 CERROR("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                 CERROR("obd: error in operation: " #op "\n");   \
139                 RETURN(rc);                                     \
140         }                                                       \
141         if (!OBP(conn->oc_dev,op)) {                            \
142                 CERROR("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         RETURN(rc);
157 }
158
159 static inline int obd_set_info(struct obd_conn *conn, obd_count keylen,
160                                void *key, obd_count vallen, void *val)
161 {
162         int rc;
163         OBD_CHECK_SETUP(conn);
164         OBD_CHECK_OP(conn,set_info);
165
166         rc = OBP(conn->oc_dev, set_info)(conn, keylen, key, vallen, val);
167         RETURN(rc);
168 }
169
170 static inline int obd_setup(struct obd_device *obd, int datalen, void *data)
171 {
172         struct obd_conn conn;
173         int rc;
174         conn.oc_dev = obd;
175
176         OBD_CHECK_OP((&conn),setup);
177
178         rc = OBP(conn.oc_dev, setup)(obd, datalen, data);
179         RETURN(rc);
180 }
181
182 static inline int obd_cleanup(struct obd_device *obd)
183 {
184         struct obd_conn conn;
185         int rc;
186         conn.oc_dev = obd;
187
188         OBD_CHECK_SETUP(&conn);
189         OBD_CHECK_OP((&conn),cleanup);
190
191         rc = OBP(conn.oc_dev, cleanup)(obd);
192         RETURN(rc);
193 }
194
195 static inline int obd_create(struct obd_conn *conn, struct obdo *obdo)
196 {
197         int rc;
198         OBD_CHECK_SETUP(conn);
199         OBD_CHECK_OP(conn,create);
200
201         rc = OBP(conn->oc_dev, create)(conn, obdo);
202         RETURN(rc);
203 }
204
205 static inline int obd_destroy(struct obd_conn *conn, struct obdo *obdo)
206 {
207         int rc;
208         OBD_CHECK_SETUP(conn);
209         OBD_CHECK_OP(conn,destroy);
210
211         rc = OBP(conn->oc_dev, destroy)(conn, obdo);
212         RETURN(rc);
213 }
214
215 static inline int obd_getattr(struct obd_conn *conn, struct obdo *obdo)
216 {
217         int rc;
218         OBD_CHECK_SETUP(conn);
219         OBD_CHECK_OP(conn,getattr);
220
221         rc = OBP(conn->oc_dev, getattr)(conn, obdo);
222         RETURN(rc);
223 }
224
225 static inline int obd_close(struct obd_conn *conn, struct obdo *obdo)
226 {
227         int rc;
228         OBD_CHECK_SETUP(conn);
229         OBD_CHECK_OP(conn,close);
230
231         rc = OBP(conn->oc_dev, close)(conn, obdo);
232         RETURN(rc);
233 }
234 static inline int obd_open(struct obd_conn *conn, struct obdo *obdo)
235 {
236         int rc;
237         OBD_CHECK_SETUP(conn);
238         OBD_CHECK_OP(conn,open);
239
240         rc = OBP(conn->oc_dev, open) (conn, obdo);
241         RETURN(rc);
242 }
243
244 static inline int obd_setattr(struct obd_conn *conn, struct obdo *obdo)
245 {
246         int rc;
247         OBD_CHECK_SETUP(conn);
248         OBD_CHECK_OP(conn,setattr);
249
250         rc = OBP(conn->oc_dev, setattr)(conn, obdo);
251         RETURN(rc);
252 }
253
254 static inline int obd_connect(struct obd_conn *conn)
255 {
256         int rc;
257         OBD_CHECK_SETUP(conn);
258         OBD_CHECK_OP(conn,connect);
259
260         rc = OBP(conn->oc_dev, connect)(conn);
261         RETURN(rc);
262 }
263
264 static inline int obd_disconnect(struct obd_conn *conn)
265 {
266         int rc;
267         OBD_CHECK_SETUP(conn);
268         OBD_CHECK_OP(conn,disconnect);
269
270         rc = OBP(conn->oc_dev, disconnect)(conn);
271         RETURN(rc);
272 }
273
274 static inline int obd_statfs(struct obd_conn *conn, struct statfs *buf)
275 {
276         int rc;
277         OBD_CHECK_SETUP(conn);
278         OBD_CHECK_OP(conn,statfs);
279
280         rc = OBP(conn->oc_dev, statfs)(conn, buf);
281         RETURN(rc);
282 }
283
284 static inline int obd_punch(struct obd_conn *conn, struct obdo *tgt,
285                             obd_size count, obd_off offset)
286 {
287         int rc;
288         OBD_CHECK_SETUP(conn);
289         OBD_CHECK_OP(conn,punch);
290
291         rc = OBP(conn->oc_dev, punch)(conn, tgt, count, offset);
292         RETURN(rc);
293 }
294
295 static inline int obd_brw(int rw, struct obd_conn *conn, obd_count num_oa,
296                           struct obdo **oa, obd_count *oa_bufs,
297                           struct page **buf, obd_size *count, obd_off *offset,
298                           obd_flag *flags)
299 {
300         int rc;
301         OBD_CHECK_SETUP(conn);
302         OBD_CHECK_OP(conn,brw);
303
304         rc = OBP(conn->oc_dev, brw)(rw, conn, num_oa, oa, oa_bufs, buf,
305                                     count, offset, flags);
306         RETURN(rc);
307 }
308
309 static inline int obd_preprw(int cmd, struct obd_conn *conn,
310                              int objcount, struct obd_ioobj *obj,
311                              int niocount, struct niobuf_remote *remote,
312                              struct niobuf_local *local)
313 {
314         int rc;
315         OBD_CHECK_SETUP(conn);
316         OBD_CHECK_OP(conn, preprw);
317
318         rc = OBP(conn->oc_dev, preprw)(cmd, conn, objcount, obj, niocount,
319                                        remote, local);
320         RETURN(rc);
321 }
322
323 static inline int obd_commitrw(int cmd, struct obd_conn *conn,
324                                int objcount, struct obd_ioobj *obj,
325                                int niocount, struct niobuf_local *local)
326 {
327         int rc;
328         OBD_CHECK_SETUP(conn);
329         OBD_CHECK_OP(conn, commitrw);
330
331         rc = OBP(conn->oc_dev, commitrw)(cmd, conn, objcount, obj, niocount,
332                                          local);
333         RETURN(rc);
334 }
335
336 static inline int obd_iocontrol(int cmd, struct obd_conn *conn,
337                                 int len, void *karg, void *uarg)
338 {
339         int rc;
340         OBD_CHECK_SETUP(conn);
341         OBD_CHECK_OP(conn, iocontrol);
342
343         rc = OBP(conn->oc_dev, iocontrol)(cmd, conn, len, karg, uarg);
344         RETURN(rc);
345 }
346
347 static inline int obd_enqueue(struct obd_conn *conn, struct ldlm_namespace *ns,
348                               struct ldlm_handle *parent_lock, __u64 *res_id,
349                               __u32 type, struct ldlm_extent *extent,
350                               __u32 mode, int *flags, void *data, int datalen,
351                               struct ldlm_handle *lockh)
352 {
353         int rc;
354         OBD_CHECK_SETUP(conn);
355         OBD_CHECK_OP(conn, enqueue);
356         
357         rc = OBP(conn->oc_dev, enqueue)(conn, ns, parent_lock, res_id, type,
358                                         extent, mode, flags, data, datalen,
359                                         lockh);
360         RETURN(rc);
361 }
362
363 static inline int obd_cancel(struct obd_conn *conn, __u32 mode,
364                              struct ldlm_handle *lockh)
365 {
366         int rc;
367         OBD_CHECK_SETUP(conn);
368         OBD_CHECK_OP(conn, cancel);
369         
370         rc = OBP(conn->oc_dev, cancel)(conn, mode, lockh);
371         RETURN(rc);
372 }
373
374 #endif 
375
376 /*
377  *  ======== OBD Metadata Support  ===========
378  */
379
380 extern int obd_init_obdo_cache(void);
381 extern void obd_cleanup_obdo_cache(void);
382
383
384 static inline int obdo_has_inline(struct obdo *obdo)
385 {
386         return (obdo->o_valid & OBD_MD_FLINLINE &&
387                 obdo->o_obdflags & OBD_FL_INLINEDATA);
388 };
389
390 static inline int obdo_has_obdmd(struct obdo *obdo)
391 {
392         return (obdo->o_valid & OBD_MD_FLOBDMD &&
393                 obdo->o_obdflags & OBD_FL_OBDMDEXISTS);
394 };
395
396 #ifdef __KERNEL__
397 /* support routines */
398 extern kmem_cache_t *obdo_cachep;
399
400 static __inline__ struct obdo *obdo_alloc(void)
401 {
402         struct obdo *oa = NULL;
403
404         oa = kmem_cache_alloc(obdo_cachep, SLAB_KERNEL);
405         memset(oa, 0, sizeof (*oa));
406
407         return oa;
408 }
409
410 static __inline__ void obdo_free(struct obdo *oa)
411 {
412         if ( !oa ) 
413                 return;
414         kmem_cache_free(obdo_cachep, oa);
415 }
416
417 static __inline__ struct obdo *obdo_fromid(struct obd_conn *conn, obd_id id,
418                                            obd_mode mode, obd_flag valid)
419 {
420         struct obdo *oa;
421         int err;
422
423         ENTRY;
424         oa = obdo_alloc();
425         if ( !oa ) {
426                 RETURN(ERR_PTR(-ENOMEM));
427         }
428
429         oa->o_id = id;
430         oa->o_mode = mode;
431         oa->o_valid = valid;
432         if ((err = OBP(conn->oc_dev, getattr)(conn, oa))) {
433                 obdo_free(oa);
434                 RETURN(ERR_PTR(err));
435         }
436         RETURN(oa);
437 }
438
439 static inline void obdo_from_iattr(struct obdo *oa, struct iattr *attr)
440 {
441         unsigned int ia_valid = attr->ia_valid;
442
443         if (ia_valid & ATTR_ATIME) {
444                 oa->o_atime = attr->ia_atime;
445                 oa->o_valid |= OBD_MD_FLATIME;
446         }
447         if (ia_valid & ATTR_MTIME) {
448                 oa->o_mtime = attr->ia_mtime;
449                 oa->o_valid |= OBD_MD_FLMTIME;
450         }
451         if (ia_valid & ATTR_CTIME) {
452                 oa->o_ctime = attr->ia_ctime;
453                 oa->o_valid |= OBD_MD_FLCTIME;
454         }
455         if (ia_valid & ATTR_SIZE) {
456                 oa->o_size = attr->ia_size;
457                 oa->o_valid |= OBD_MD_FLSIZE;
458         }
459         if (ia_valid & ATTR_MODE) {
460                 oa->o_mode = attr->ia_mode;
461                 oa->o_valid |= OBD_MD_FLMODE;
462                 if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID))
463                         oa->o_mode &= ~S_ISGID;
464         }
465         if (ia_valid & ATTR_UID)
466         {
467                 oa->o_uid = attr->ia_uid;
468                 oa->o_valid |= OBD_MD_FLUID;
469         }
470         if (ia_valid & ATTR_GID) {
471                 oa->o_gid = attr->ia_gid;
472                 oa->o_valid |= OBD_MD_FLGID;
473         }
474 }
475
476
477 static inline void iattr_from_obdo(struct iattr *attr, struct obdo *oa)
478 {
479         unsigned int ia_valid = oa->o_valid;
480         
481         memset(attr, 0, sizeof(*attr));
482         if (ia_valid & OBD_MD_FLATIME) {
483                 attr->ia_atime = oa->o_atime;
484                 attr->ia_valid |= ATTR_ATIME;
485         }
486         if (ia_valid & OBD_MD_FLMTIME) {
487                 attr->ia_mtime = oa->o_mtime;
488                 attr->ia_valid |= ATTR_MTIME;
489         }
490         if (ia_valid & OBD_MD_FLCTIME) {
491                 attr->ia_ctime = oa->o_ctime;
492                 attr->ia_valid |= ATTR_CTIME;
493         }
494         if (ia_valid & OBD_MD_FLSIZE) {
495                 attr->ia_size = oa->o_size;
496                 attr->ia_valid |= ATTR_SIZE;
497         }
498         if (ia_valid & OBD_MD_FLMODE) {
499                 attr->ia_mode = oa->o_mode;
500                 attr->ia_valid |= ATTR_MODE;
501                 if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID))
502                         attr->ia_mode &= ~S_ISGID;
503         }
504         if (ia_valid & OBD_MD_FLUID)
505         {
506                 attr->ia_uid = oa->o_uid;
507                 attr->ia_valid |= ATTR_UID;
508         }
509         if (ia_valid & OBD_MD_FLGID) {
510                 attr->ia_gid = oa->o_gid;
511                 attr->ia_valid |= ATTR_GID;
512         }
513 }
514
515
516 /* WARNING: the file systems must take care not to tinker with
517    attributes they don't manage (such as blocks). */
518
519 static __inline__ void obdo_from_inode(struct obdo *dst, struct inode *src)
520 {
521         if ( dst->o_valid & OBD_MD_FLID )
522                 dst->o_id = src->i_ino;
523         if ( dst->o_valid & OBD_MD_FLATIME )
524                 dst->o_atime = src->i_atime;
525         if ( dst->o_valid & OBD_MD_FLMTIME )
526                 dst->o_mtime = src->i_mtime;
527         if ( dst->o_valid & OBD_MD_FLCTIME )
528                 dst->o_ctime = src->i_ctime;
529         if ( dst->o_valid & OBD_MD_FLSIZE )
530                 dst->o_size = src->i_size;
531         if ( dst->o_valid & OBD_MD_FLBLOCKS )   /* allocation of space */
532                 dst->o_blocks = src->i_blocks;
533         if ( dst->o_valid & OBD_MD_FLBLKSZ )
534                 dst->o_blksize = src->i_blksize;
535         if ( dst->o_valid & OBD_MD_FLMODE )
536                 dst->o_mode = src->i_mode;
537         if ( dst->o_valid & OBD_MD_FLUID )
538                 dst->o_uid = src->i_uid;
539         if ( dst->o_valid & OBD_MD_FLGID )
540                 dst->o_gid = src->i_gid;
541         if ( dst->o_valid & OBD_MD_FLFLAGS )
542                 dst->o_flags = src->i_flags;
543         if ( dst->o_valid & OBD_MD_FLNLINK )
544                 dst->o_nlink = src->i_nlink;
545         if ( dst->o_valid & OBD_MD_FLGENER ) 
546                 dst->o_generation = src->i_generation;
547 }
548
549 static __inline__ void obdo_to_inode(struct inode *dst, struct obdo *src)
550 {
551
552         if ( src->o_valid & OBD_MD_FLID )
553                 dst->i_ino = src->o_id;
554         if ( src->o_valid & OBD_MD_FLATIME ) 
555                 dst->i_atime = src->o_atime;
556         if ( src->o_valid & OBD_MD_FLMTIME ) 
557                 dst->i_mtime = src->o_mtime;
558         if ( src->o_valid & OBD_MD_FLCTIME ) 
559                 dst->i_ctime = src->o_ctime;
560         if ( src->o_valid & OBD_MD_FLSIZE ) 
561                 dst->i_size = src->o_size;
562         if ( src->o_valid & OBD_MD_FLBLOCKS ) /* allocation of space */
563                 dst->i_blocks = src->o_blocks;
564         if ( src->o_valid & OBD_MD_FLBLKSZ )
565                 dst->i_blksize = src->o_blksize;
566         if ( src->o_valid & OBD_MD_FLMODE ) 
567                 dst->i_mode = src->o_mode;
568         if ( src->o_valid & OBD_MD_FLUID ) 
569                 dst->i_uid = src->o_uid;
570         if ( src->o_valid & OBD_MD_FLGID ) 
571                 dst->i_gid = src->o_gid;
572         if ( src->o_valid & OBD_MD_FLFLAGS ) 
573                 dst->i_flags = src->o_flags;
574         if ( src->o_valid & OBD_MD_FLNLINK )
575                 dst->i_nlink = src->o_nlink;
576         if ( src->o_valid & OBD_MD_FLGENER )
577                 dst->i_generation = src->o_generation;
578 }
579
580 #endif 
581
582 static __inline__ void obdo_cpy_md(struct obdo *dst, struct obdo *src)
583 {
584 #ifdef __KERNEL__
585         CDEBUG(D_INODE, "src obdo %Ld valid 0x%x, dst obdo %Ld\n",
586                (unsigned long long)src->o_id, src->o_valid,
587                (unsigned long long)dst->o_id);
588 #endif
589         if ( src->o_valid & OBD_MD_FLATIME ) 
590                 dst->o_atime = src->o_atime;
591         if ( src->o_valid & OBD_MD_FLMTIME ) 
592                 dst->o_mtime = src->o_mtime;
593         if ( src->o_valid & OBD_MD_FLCTIME ) 
594                 dst->o_ctime = src->o_ctime;
595         if ( src->o_valid & OBD_MD_FLSIZE ) 
596                 dst->o_size = src->o_size;
597         if ( src->o_valid & OBD_MD_FLBLOCKS ) /* allocation of space */
598                 dst->o_blocks = src->o_blocks;
599         if ( src->o_valid & OBD_MD_FLBLKSZ )
600                 dst->o_blksize = src->o_blksize;
601         if ( src->o_valid & OBD_MD_FLMODE ) 
602                 dst->o_mode = src->o_mode;
603         if ( src->o_valid & OBD_MD_FLUID ) 
604                 dst->o_uid = src->o_uid;
605         if ( src->o_valid & OBD_MD_FLGID ) 
606                 dst->o_gid = src->o_gid;
607         if ( src->o_valid & OBD_MD_FLFLAGS ) 
608                 dst->o_flags = src->o_flags;
609         /*
610         if ( src->o_valid & OBD_MD_FLOBDFLG ) 
611                 dst->o_obdflags = src->o_obdflags;
612         */
613         if ( src->o_valid & OBD_MD_FLNLINK ) 
614                 dst->o_nlink = src->o_nlink;
615         if ( src->o_valid & OBD_MD_FLGENER ) 
616                 dst->o_generation = src->o_generation;
617         if ( src->o_valid & OBD_MD_FLINLINE &&
618              src->o_obdflags & OBD_FL_INLINEDATA) {
619                 memcpy(dst->o_inline, src->o_inline, sizeof(src->o_inline));
620                 dst->o_obdflags |= OBD_FL_INLINEDATA;
621         }
622         if ( src->o_valid & OBD_MD_FLOBDMD &&
623              src->o_obdflags & OBD_FL_OBDMDEXISTS) {
624                 memcpy(dst->o_obdmd, src->o_obdmd, sizeof(src->o_obdmd));
625                 dst->o_obdflags |= OBD_FL_OBDMDEXISTS;
626         }
627
628         dst->o_valid |= src->o_valid;
629 }
630
631
632 /* returns FALSE if comparison (by flags) is same, TRUE if changed */
633 static __inline__ int obdo_cmp_md(struct obdo *dst, struct obdo *src,
634                                   obd_flag compare)
635 {
636         int res = 0;
637
638         if ( compare & OBD_MD_FLATIME )
639                 res = (res || (dst->o_atime != src->o_atime));
640         if ( compare & OBD_MD_FLMTIME )
641                 res = (res || (dst->o_mtime != src->o_mtime));
642         if ( compare & OBD_MD_FLCTIME )
643                 res = (res || (dst->o_ctime != src->o_ctime));
644         if ( compare & OBD_MD_FLSIZE )
645                 res = (res || (dst->o_size != src->o_size));
646         if ( compare & OBD_MD_FLBLOCKS ) /* allocation of space */
647                 res = (res || (dst->o_blocks != src->o_blocks));
648         if ( compare & OBD_MD_FLBLKSZ )
649                 res = (res || (dst->o_blksize != src->o_blksize));
650         if ( compare & OBD_MD_FLMODE )
651                 res = (res || (dst->o_mode != src->o_mode));
652         if ( compare & OBD_MD_FLUID )
653                 res = (res || (dst->o_uid != src->o_uid));
654         if ( compare & OBD_MD_FLGID )
655                 res = (res || (dst->o_gid != src->o_gid));
656         if ( compare & OBD_MD_FLFLAGS ) 
657                 res = (res || (dst->o_flags != src->o_flags));
658         if ( compare & OBD_MD_FLNLINK )
659                 res = (res || (dst->o_nlink != src->o_nlink));
660         if ( compare & OBD_MD_FLGENER )
661                 res = (res || (dst->o_generation != src->o_generation));
662         /* XXX Don't know if thses should be included here - wasn't previously
663         if ( compare & OBD_MD_FLINLINE )
664                 res = (res || memcmp(dst->o_inline, src->o_inline));
665         if ( compare & OBD_MD_FLOBDMD )
666                 res = (res || memcmp(dst->o_obdmd, src->o_obdmd));
667         */
668         return res;
669 }
670
671
672 #ifdef __KERNEL__
673 int obd_register_type(struct obd_ops *ops, char *nm);
674 int obd_unregister_type(char *nm);
675
676 struct obd_client {
677         struct list_head cli_chain;
678         struct obd_device *cli_obd;
679         unsigned int cli_id;
680         unsigned long cli_prealloc_quota;
681         struct list_head cli_prealloc_inodes;
682 };
683
684
685 struct obd_prealloc_inode {
686         struct list_head obd_prealloc_chain;
687         unsigned long inode;
688 };
689
690 /* generic operations shared by various OBD types */
691 int gen_multi_setup(struct obd_device *obddev, uint32_t len, void *data);
692 int gen_multi_cleanup(struct obd_device *obddev);
693 int gen_multi_attach(struct obd_device *obddev, uint32_t len, void *data);
694 int gen_multi_detach(struct obd_device *obddev);
695 int gen_connect (struct obd_conn *conn);
696 int gen_disconnect(struct obd_conn *conn);
697 struct obd_client *gen_client(const struct obd_conn *);
698 int gen_cleanup(struct obd_device *obddev);
699 int gen_copy_data(struct obd_conn *dst_conn, struct obdo *dst,
700                   struct obd_conn *src_conn, struct obdo *src,
701                   obd_size count, obd_off offset);
702
703 #endif
704
705 /* sysctl.c */
706 extern void obd_sysctl_init (void);
707 extern void obd_sysctl_clean (void);
708
709 #endif /* __LINUX_CLASS_OBD_H */