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