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