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