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