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