1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
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.
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.
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.
23 #ifndef __LINUX_CLASS_OBD_H
24 #define __LINUX_CLASS_OBD_H
29 # include <linux/list.h>
32 #include <asm/segment.h>
33 #include <asm/uaccess.h>
34 #include <linux/types.h>
36 #include <linux/time.h>
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 #include <linux/lprocfs_status.h>
48 /* OBD Device Declarations */
49 #define MAX_OBD_DEVICES 128
50 extern struct obd_device obd_dev[MAX_OBD_DEVICES];
52 #define OBD_ATTACHED 0x1
53 #define OBD_SET_UP 0x2
55 /* OBD Operations Declarations */
58 static inline int obd_check_conn(struct lustre_handle *conn)
60 struct obd_device *obd;
62 CERROR("NULL conn\n");
65 obd = class_conn2obd(conn);
71 if (!obd->obd_flags & OBD_ATTACHED ) {
72 CERROR("obd %d not attached\n", obd->obd_minor);
76 if (!obd->obd_flags & OBD_SET_UP) {
77 CERROR("obd %d not setup\n", obd->obd_minor);
82 CERROR("obd %d not typed\n", obd->obd_minor);
86 if (!obd->obd_type->typ_ops) {
87 CERROR("obd_check_conn: obd %d no operations\n",
95 #define OBT(dev) (dev)->obd_type
96 #define OBP(dev, op) (dev)->obd_type->typ_ops->o_ ## op
98 #define OBD_CHECK_SETUP(conn, exp) \
101 CERROR("NULL connection\n"); \
105 exp = class_conn2export(conn); \
107 CERROR("No export\n"); \
111 if (!((exp)->exp_obd->obd_flags & OBD_SET_UP)) { \
112 CERROR("Device %d not setup\n", \
113 (exp)->exp_obd->obd_minor); \
118 #define OBD_CHECK_DEVSETUP(obd) \
121 CERROR("NULL device\n"); \
125 if (!((obd)->obd_flags & OBD_SET_UP)) { \
126 CERROR("Device %d not setup\n", \
132 #define OBD_CHECK_OP(obd, op) \
134 if (!OBP((obd), op)) { \
135 CERROR("obd_" #op ": dev %d no operation\n", \
137 RETURN(-EOPNOTSUPP); \
141 static inline int obd_get_info(struct lustre_handle *conn, obd_count keylen,
142 void *key, obd_count *vallen, void **val)
144 struct obd_export *exp;
148 OBD_CHECK_SETUP(conn, exp);
149 OBD_CHECK_OP(exp->exp_obd, get_info);
151 rc = OBP(exp->exp_obd, get_info)(conn, keylen, key, vallen, val);
155 static inline int obd_set_info(struct lustre_handle *conn, obd_count keylen,
156 void *key, obd_count vallen, void *val)
158 struct obd_export *exp;
162 OBD_CHECK_SETUP(conn, exp);
163 OBD_CHECK_OP(exp->exp_obd, set_info);
165 rc = OBP(exp->exp_obd, set_info)(conn, keylen, key, vallen, val);
169 static inline int obd_setup(struct obd_device *obd, int datalen, void *data)
174 OBD_CHECK_OP(obd, setup);
176 rc = OBP(obd, setup)(obd, datalen, data);
180 static inline int obd_cleanup(struct obd_device *obd)
185 OBD_CHECK_DEVSETUP(obd);
186 OBD_CHECK_OP(obd, cleanup);
188 rc = OBP(obd, cleanup)(obd);
192 /* Pack an in-memory MD struct for sending to the MDS and/or disk.
193 * Returns +ve size of packed MD (0 for free), or -ve error.
195 * If @wire_tgt == NULL, MD size is returned (max size if @mem_src == NULL).
196 * If @*wire_tgt != NULL and @mem_src == NULL, @*wire_tgt will be freed.
197 * If @*wire_tgt == NULL, it will be allocated
199 static inline int obd_packmd(struct lustre_handle *conn,
200 struct lov_mds_md **wire_tgt,
201 struct lov_stripe_md *mem_src)
203 struct obd_export *exp;
206 OBD_CHECK_SETUP(conn, exp);
207 OBD_CHECK_OP(exp->exp_obd, packmd);
209 RETURN(OBP(exp->exp_obd, packmd)(conn, wire_tgt, mem_src));
212 static inline int obd_size_wiremd(struct lustre_handle *conn,
213 struct lov_stripe_md *mem_src)
215 return obd_packmd(conn, NULL, mem_src);
218 /* helper functions */
219 static inline int obd_alloc_wiremd(struct lustre_handle *conn,
220 struct lov_mds_md **wire_tgt)
223 LASSERT(*wire_tgt == NULL);
224 return obd_packmd(conn, wire_tgt, NULL);
227 static inline int obd_free_wiremd(struct lustre_handle *conn,
228 struct lov_mds_md **wire_tgt)
232 return obd_packmd(conn, wire_tgt, NULL);
235 /* Unpack an MD struct from the MDS and/or disk to in-memory format.
236 * Returns +ve size of unpacked MD (0 for free), or -ve error.
238 * If @mem_tgt == NULL, MD size is returned (max size if @wire_src == NULL).
239 * If @*mem_tgt != NULL and @wire_src == NULL, @*mem_tgt will be freed.
240 * If @*mem_tgt == NULL, it will be allocated
242 static inline int obd_unpackmd(struct lustre_handle *conn,
243 struct lov_stripe_md **mem_tgt,
244 struct lov_mds_md *wire_src)
246 struct obd_export *exp;
249 OBD_CHECK_SETUP(conn, exp);
250 OBD_CHECK_OP(exp->exp_obd, unpackmd);
252 RETURN(OBP(exp->exp_obd, unpackmd)(conn, mem_tgt, wire_src));
255 static inline int obd_size_memmd(struct lustre_handle *conn,
256 struct lov_mds_md *wire_src)
258 return obd_unpackmd(conn, NULL, wire_src);
261 /* helper functions */
262 static inline int obd_alloc_memmd(struct lustre_handle *conn,
263 struct lov_stripe_md **mem_tgt)
266 LASSERT(*mem_tgt == NULL);
267 return obd_unpackmd(conn, mem_tgt, NULL);
270 static inline int obd_free_memmd(struct lustre_handle *conn,
271 struct lov_stripe_md **mem_tgt)
275 return obd_unpackmd(conn, mem_tgt, NULL);
278 static inline int obd_create(struct lustre_handle *conn, struct obdo *obdo,
279 struct lov_stripe_md **ea)
281 struct obd_export *exp;
285 OBD_CHECK_SETUP(conn, exp);
286 OBD_CHECK_OP(exp->exp_obd, create);
288 rc = OBP(exp->exp_obd, create)(conn, obdo, ea);
292 static inline int obd_destroy(struct lustre_handle *conn, struct obdo *obdo,
293 struct lov_stripe_md *ea)
295 struct obd_export *exp;
299 OBD_CHECK_SETUP(conn, exp);
300 OBD_CHECK_OP(exp->exp_obd, destroy);
302 rc = OBP(exp->exp_obd, destroy)(conn, obdo, ea);
306 static inline int obd_getattr(struct lustre_handle *conn, struct obdo *obdo,
307 struct lov_stripe_md *ea)
309 struct obd_export *exp;
313 OBD_CHECK_SETUP(conn, exp);
314 OBD_CHECK_OP(exp->exp_obd, getattr);
316 rc = OBP(exp->exp_obd, getattr)(conn, obdo, ea);
320 static inline int obd_close(struct lustre_handle *conn, struct obdo *obdo,
321 struct lov_stripe_md *ea)
323 struct obd_export *exp;
327 OBD_CHECK_SETUP(conn, exp);
328 OBD_CHECK_OP(exp->exp_obd, close);
330 rc = OBP(exp->exp_obd, close)(conn, obdo, ea);
334 static inline int obd_open(struct lustre_handle *conn, struct obdo *obdo,
335 struct lov_stripe_md *ea)
337 struct obd_export *exp;
341 OBD_CHECK_SETUP(conn, exp);
342 OBD_CHECK_OP(exp->exp_obd, open);
344 rc = OBP(exp->exp_obd, open)(conn, obdo, ea);
348 static inline int obd_setattr(struct lustre_handle *conn, struct obdo *obdo,
349 struct lov_stripe_md *ea)
351 struct obd_export *exp;
355 OBD_CHECK_SETUP(conn, exp);
356 OBD_CHECK_OP(exp->exp_obd, setattr);
358 rc = OBP(exp->exp_obd, setattr)(conn, obdo, ea);
362 static inline int obd_connect(struct lustre_handle *conn,
363 struct obd_device *obd, obd_uuid_t cluuid,
364 struct recovd_obd *recovd,
365 ptlrpc_recovery_cb_t recover)
370 OBD_CHECK_DEVSETUP(obd);
371 OBD_CHECK_OP(obd, connect);
373 rc = OBP(obd, connect)(conn, obd, cluuid, recovd, recover);
377 static inline int obd_disconnect(struct lustre_handle *conn)
379 struct obd_export *exp;
383 OBD_CHECK_SETUP(conn, exp);
384 OBD_CHECK_OP(exp->exp_obd, disconnect);
386 rc = OBP(exp->exp_obd, disconnect)(conn);
390 static inline int obd_statfs(struct lustre_handle *conn,struct obd_statfs *osfs)
392 struct obd_export *exp;
396 OBD_CHECK_SETUP(conn, exp);
397 OBD_CHECK_OP(exp->exp_obd, statfs);
399 rc = OBP(exp->exp_obd, statfs)(conn, osfs);
403 static inline int obd_punch(struct lustre_handle *conn, struct obdo *oa,
404 struct lov_stripe_md *ea,
405 obd_size start, obd_size end)
407 struct obd_export *exp;
411 OBD_CHECK_SETUP(conn, exp);
412 OBD_CHECK_OP(exp->exp_obd, punch);
414 rc = OBP(exp->exp_obd, punch)(conn, oa, ea, start, end);
418 static inline int obd_brw(int cmd, struct lustre_handle *conn,
419 struct lov_stripe_md *ea, obd_count oa_bufs,
420 struct brw_page *pg, struct obd_brw_set *set)
422 struct obd_export *exp;
426 OBD_CHECK_SETUP(conn, exp);
427 OBD_CHECK_OP(exp->exp_obd, brw);
429 if (!(cmd & OBD_BRW_RWMASK)) {
430 CERROR("obd_brw: cmd must be OBD_BRW_READ or OBD_BRW_WRITE\n");
434 rc = OBP(exp->exp_obd, brw)(cmd, conn, ea, oa_bufs, pg, set);
438 static inline int obd_preprw(int cmd, struct lustre_handle *conn,
439 int objcount, struct obd_ioobj *obj,
440 int niocount, struct niobuf_remote *remote,
441 struct niobuf_local *local, void **desc_private)
443 struct obd_export *exp;
447 OBD_CHECK_SETUP(conn, exp);
448 OBD_CHECK_OP(exp->exp_obd, preprw);
450 rc = OBP(exp->exp_obd, preprw)(cmd, conn, objcount, obj, niocount,
451 remote, local, desc_private);
455 static inline int obd_commitrw(int cmd, struct lustre_handle *conn,
456 int objcount, struct obd_ioobj *obj,
457 int niocount, struct niobuf_local *local,
460 struct obd_export *exp;
464 OBD_CHECK_SETUP(conn, exp);
465 OBD_CHECK_OP(exp->exp_obd, commitrw);
467 rc = OBP(exp->exp_obd, commitrw)(cmd, conn, objcount, obj, niocount,
468 local, desc_private);
472 static inline int obd_iocontrol(unsigned int cmd, struct lustre_handle *conn,
473 int len, void *karg, void *uarg)
475 struct obd_export *exp;
479 OBD_CHECK_SETUP(conn, exp);
480 OBD_CHECK_OP(exp->exp_obd, iocontrol);
482 rc = OBP(exp->exp_obd, iocontrol)(cmd, conn, len, karg, uarg);
486 static inline int obd_enqueue(struct lustre_handle *conn,
487 struct lov_stripe_md *ea,
488 struct lustre_handle *parent_lock,
489 __u32 type, void *cookie, int cookielen,
490 __u32 mode, int *flags, void *cb, void *data,
491 int datalen, struct lustre_handle *lockh)
493 struct obd_export *exp;
497 OBD_CHECK_SETUP(conn, exp);
498 OBD_CHECK_OP(exp->exp_obd, enqueue);
500 rc = OBP(exp->exp_obd, enqueue)(conn, ea, parent_lock, type,
501 cookie, cookielen, mode, flags, cb,
502 data, datalen, lockh);
506 static inline int obd_cancel(struct lustre_handle *conn,
507 struct lov_stripe_md *ea, __u32 mode,
508 struct lustre_handle *lockh)
510 struct obd_export *exp;
514 OBD_CHECK_SETUP(conn, exp);
515 OBD_CHECK_OP(exp->exp_obd, cancel);
517 rc = OBP(exp->exp_obd, cancel)(conn, ea, mode, lockh);
521 static inline int obd_cancel_unused(struct lustre_handle *conn,
522 struct lov_stripe_md *ea, int local)
524 struct obd_export *exp;
528 OBD_CHECK_SETUP(conn, exp);
529 OBD_CHECK_OP(exp->exp_obd, cancel_unused);
531 rc = OBP(exp->exp_obd, cancel_unused)(conn, ea, local);
537 /* OBD Metadata Support */
539 extern int obd_init_caches(void);
540 extern void obd_cleanup_caches(void);
542 static inline struct lustre_handle *obdo_handle(struct obdo *oa)
544 return (struct lustre_handle *)&oa->o_inline;
547 static inline void obd_oa2handle(struct lustre_handle *handle, struct obdo *oa)
549 if (oa->o_valid |= OBD_MD_FLHANDLE) {
550 struct lustre_handle *oa_handle = obdo_handle(oa);
551 memcpy(handle, oa_handle, sizeof(*handle));
555 static inline void obd_handle2oa(struct obdo *oa, struct lustre_handle *handle)
558 struct lustre_handle *oa_handle = obdo_handle(oa);
559 memcpy(oa_handle, handle, sizeof(*handle));
560 oa->o_valid |= OBD_MD_FLHANDLE;
565 /* support routines */
566 extern kmem_cache_t *obdo_cachep;
567 static inline struct obdo *obdo_alloc(void)
571 oa = kmem_cache_alloc(obdo_cachep, SLAB_KERNEL);
574 memset(oa, 0, sizeof (*oa));
579 static inline void obdo_free(struct obdo *oa)
583 kmem_cache_free(obdo_cachep, oa);
586 static inline void obdo_from_iattr(struct obdo *oa, struct iattr *attr)
588 unsigned int ia_valid = attr->ia_valid;
590 if (ia_valid & ATTR_ATIME) {
591 oa->o_atime = attr->ia_atime;
592 oa->o_valid |= OBD_MD_FLATIME;
594 if (ia_valid & ATTR_MTIME) {
595 oa->o_mtime = attr->ia_mtime;
596 oa->o_valid |= OBD_MD_FLMTIME;
598 if (ia_valid & ATTR_CTIME) {
599 oa->o_ctime = attr->ia_ctime;
600 oa->o_valid |= OBD_MD_FLCTIME;
602 if (ia_valid & ATTR_SIZE) {
603 oa->o_size = attr->ia_size;
604 oa->o_valid |= OBD_MD_FLSIZE;
606 if (ia_valid & ATTR_MODE) {
607 oa->o_mode = attr->ia_mode;
608 oa->o_valid |= OBD_MD_FLTYPE | OBD_MD_FLMODE;
609 if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID))
610 oa->o_mode &= ~S_ISGID;
612 if (ia_valid & ATTR_UID) {
613 oa->o_uid = attr->ia_uid;
614 oa->o_valid |= OBD_MD_FLUID;
616 if (ia_valid & ATTR_GID) {
617 oa->o_gid = attr->ia_gid;
618 oa->o_valid |= OBD_MD_FLGID;
623 static inline void iattr_from_obdo(struct iattr *attr, struct obdo *oa,
626 memset(attr, 0, sizeof(*attr));
627 if (valid & OBD_MD_FLATIME) {
628 attr->ia_atime = oa->o_atime;
629 attr->ia_valid |= ATTR_ATIME;
631 if (valid & OBD_MD_FLMTIME) {
632 attr->ia_mtime = oa->o_mtime;
633 attr->ia_valid |= ATTR_MTIME;
635 if (valid & OBD_MD_FLCTIME) {
636 attr->ia_ctime = oa->o_ctime;
637 attr->ia_valid |= ATTR_CTIME;
639 if (valid & OBD_MD_FLSIZE) {
640 attr->ia_size = oa->o_size;
641 attr->ia_valid |= ATTR_SIZE;
643 if (valid & OBD_MD_FLTYPE) {
644 attr->ia_mode = (attr->ia_mode & ~S_IFMT)|(oa->o_mode & S_IFMT);
645 attr->ia_valid |= ATTR_MODE;
647 if (valid & OBD_MD_FLMODE) {
648 attr->ia_mode = (attr->ia_mode & S_IFMT)|(oa->o_mode & ~S_IFMT);
649 attr->ia_valid |= ATTR_MODE;
650 if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID))
651 attr->ia_mode &= ~S_ISGID;
653 if (valid & OBD_MD_FLUID)
655 attr->ia_uid = oa->o_uid;
656 attr->ia_valid |= ATTR_UID;
658 if (valid & OBD_MD_FLGID) {
659 attr->ia_gid = oa->o_gid;
660 attr->ia_valid |= ATTR_GID;
665 /* WARNING: the file systems must take care not to tinker with
666 attributes they don't manage (such as blocks). */
668 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
669 #define to_kdev_t(dev) dev
670 #define kdev_t_to_nr(dev) dev
673 static inline void obdo_from_inode(struct obdo *dst, struct inode *src,
676 if (valid & OBD_MD_FLATIME)
677 dst->o_atime = src->i_atime;
678 if (valid & OBD_MD_FLMTIME)
679 dst->o_mtime = src->i_mtime;
680 if (valid & OBD_MD_FLCTIME)
681 dst->o_ctime = src->i_ctime;
682 if (valid & OBD_MD_FLSIZE)
683 dst->o_size = src->i_size;
684 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
685 dst->o_blocks = src->i_blocks;
686 if (valid & OBD_MD_FLBLKSZ)
687 dst->o_blksize = src->i_blksize;
688 if (valid & OBD_MD_FLTYPE)
689 dst->o_mode = (dst->o_mode & ~S_IFMT) | (src->i_mode & S_IFMT);
690 if (valid & OBD_MD_FLMODE)
691 dst->o_mode = (dst->o_mode & S_IFMT) | (src->i_mode & ~S_IFMT);
692 if (valid & OBD_MD_FLUID)
693 dst->o_uid = src->i_uid;
694 if (valid & OBD_MD_FLGID)
695 dst->o_gid = src->i_gid;
696 if (valid & OBD_MD_FLFLAGS)
697 dst->o_flags = src->i_flags;
698 if (valid & OBD_MD_FLNLINK)
699 dst->o_nlink = src->i_nlink;
700 if (valid & OBD_MD_FLGENER)
701 dst->o_generation = src->i_generation;
702 if (valid & OBD_MD_FLRDEV)
703 dst->o_rdev = (__u32)kdev_t_to_nr(src->i_rdev);
705 dst->o_valid |= (valid & ~OBD_MD_FLID);
708 static inline void obdo_to_inode(struct inode *dst, struct obdo *src,
711 valid &= src->o_valid;
713 if (valid & OBD_MD_FLATIME)
714 dst->i_atime = src->o_atime;
715 if (valid & OBD_MD_FLMTIME)
716 dst->i_mtime = src->o_mtime;
717 if (valid & OBD_MD_FLCTIME)
718 dst->i_ctime = src->o_ctime;
719 if (valid & OBD_MD_FLSIZE)
720 dst->i_size = src->o_size;
721 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
722 dst->i_blocks = src->o_blocks;
723 if (valid & OBD_MD_FLBLKSZ)
724 dst->i_blksize = src->o_blksize;
725 if (valid & OBD_MD_FLTYPE)
726 dst->i_mode = (dst->i_mode & ~S_IFMT) | (src->o_mode & S_IFMT);
727 if (valid & OBD_MD_FLMODE)
728 dst->i_mode = (dst->i_mode & S_IFMT) | (src->o_mode & ~S_IFMT);
729 if (valid & OBD_MD_FLUID)
730 dst->i_uid = src->o_uid;
731 if (valid & OBD_MD_FLGID)
732 dst->i_gid = src->o_gid;
733 if (valid & OBD_MD_FLFLAGS)
734 dst->i_flags = src->o_flags;
735 if (valid & OBD_MD_FLNLINK)
736 dst->i_nlink = src->o_nlink;
737 if (valid & OBD_MD_FLGENER)
738 dst->i_generation = src->o_generation;
739 if (valid & OBD_MD_FLRDEV)
740 dst->i_rdev = to_kdev_t(src->o_rdev);
744 static inline void obdo_cpy_md(struct obdo *dst, struct obdo *src,
748 CDEBUG(D_INODE, "src obdo %Ld valid 0x%x, dst obdo %Ld\n",
749 (unsigned long long)src->o_id, src->o_valid,
750 (unsigned long long)dst->o_id);
752 if (valid & OBD_MD_FLATIME)
753 dst->o_atime = src->o_atime;
754 if (valid & OBD_MD_FLMTIME)
755 dst->o_mtime = src->o_mtime;
756 if (valid & OBD_MD_FLCTIME)
757 dst->o_ctime = src->o_ctime;
758 if (valid & OBD_MD_FLSIZE)
759 dst->o_size = src->o_size;
760 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
761 dst->o_blocks = src->o_blocks;
762 if (valid & OBD_MD_FLBLKSZ)
763 dst->o_blksize = src->o_blksize;
764 if (valid & OBD_MD_FLTYPE)
765 dst->o_mode = (dst->o_mode & ~S_IFMT) | (src->o_mode & S_IFMT);
766 if (valid & OBD_MD_FLMODE)
767 dst->o_mode = (dst->o_mode & S_IFMT) | (src->o_mode & ~S_IFMT);
768 if (valid & OBD_MD_FLUID)
769 dst->o_uid = src->o_uid;
770 if (valid & OBD_MD_FLGID)
771 dst->o_gid = src->o_gid;
772 if (valid & OBD_MD_FLFLAGS)
773 dst->o_flags = src->o_flags;
775 if (valid & OBD_MD_FLOBDFLG)
776 dst->o_obdflags = src->o_obdflags;
778 if (valid & OBD_MD_FLNLINK)
779 dst->o_nlink = src->o_nlink;
780 if (valid & OBD_MD_FLGENER)
781 dst->o_generation = src->o_generation;
782 if (valid & OBD_MD_FLRDEV)
783 dst->o_rdev = src->o_rdev;
784 if (valid & OBD_MD_FLINLINE &&
785 src->o_obdflags & OBD_FL_INLINEDATA) {
786 memcpy(dst->o_inline, src->o_inline, sizeof(src->o_inline));
787 dst->o_obdflags |= OBD_FL_INLINEDATA;
790 dst->o_valid |= valid;
794 /* returns FALSE if comparison (by flags) is same, TRUE if changed */
795 static inline int obdo_cmp_md(struct obdo *dst, struct obdo *src,
800 if ( compare & OBD_MD_FLATIME )
801 res = (res || (dst->o_atime != src->o_atime));
802 if ( compare & OBD_MD_FLMTIME )
803 res = (res || (dst->o_mtime != src->o_mtime));
804 if ( compare & OBD_MD_FLCTIME )
805 res = (res || (dst->o_ctime != src->o_ctime));
806 if ( compare & OBD_MD_FLSIZE )
807 res = (res || (dst->o_size != src->o_size));
808 if ( compare & OBD_MD_FLBLOCKS ) /* allocation of space */
809 res = (res || (dst->o_blocks != src->o_blocks));
810 if ( compare & OBD_MD_FLBLKSZ )
811 res = (res || (dst->o_blksize != src->o_blksize));
812 if ( compare & OBD_MD_FLTYPE )
813 res = (res || (((dst->o_mode ^ src->o_mode) & S_IFMT) != 0));
814 if ( compare & OBD_MD_FLMODE )
815 res = (res || (((dst->o_mode ^ src->o_mode) & ~S_IFMT) != 0));
816 if ( compare & OBD_MD_FLUID )
817 res = (res || (dst->o_uid != src->o_uid));
818 if ( compare & OBD_MD_FLGID )
819 res = (res || (dst->o_gid != src->o_gid));
820 if ( compare & OBD_MD_FLFLAGS )
821 res = (res || (dst->o_flags != src->o_flags));
822 if ( compare & OBD_MD_FLNLINK )
823 res = (res || (dst->o_nlink != src->o_nlink));
824 if ( compare & OBD_MD_FLGENER )
825 res = (res || (dst->o_generation != src->o_generation));
826 /* XXX Don't know if thses should be included here - wasn't previously
827 if ( compare & OBD_MD_FLINLINE )
828 res = (res || memcmp(dst->o_inline, src->o_inline));
835 /* I'm as embarrassed about this as you are.
837 * <shaver> // XXX do not look into _superhack with remaining eye
838 * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */
839 extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
841 int class_register_type(struct obd_ops *ops, struct lprocfs_vars* vars,
843 int class_unregister_type(char *nm);
844 int class_name2dev(char *name);
845 int class_uuid2dev(char *uuid);
846 struct obd_device *class_uuid2obd(char *uuid);
847 struct obd_export *class_new_export(struct obd_device *obddev);
848 struct obd_type *class_get_type(char *name);
849 void class_put_type(struct obd_type *type);
850 void class_destroy_export(struct obd_export *exp);
851 int class_connect(struct lustre_handle *conn, struct obd_device *obd,
853 int class_disconnect(struct lustre_handle *conn);
854 void class_disconnect_all(struct obd_device *obddev);
856 /* generic operations shared by various OBD types */
857 int class_multi_setup(struct obd_device *obddev, uint32_t len, void *data);
858 int class_multi_cleanup(struct obd_device *obddev);
860 extern void (*class_signal_connection_failure)(struct ptlrpc_connection *);
862 static inline struct ptlrpc_connection *class_rd2conn(struct recovd_data *rd)
864 /* reuse list_entry's member-pointer offset stuff */
865 return list_entry(rd, struct ptlrpc_connection, c_recovd_data);
870 void statfs_pack(struct obd_statfs *osfs, struct statfs *sfs);
871 void statfs_unpack(struct statfs *sfs, struct obd_statfs *osfs);
872 void obd_statfs_pack(struct obd_statfs *tgt, struct obd_statfs *src);
873 void obd_statfs_unpack(struct obd_statfs *tgt, struct obd_statfs *src);
878 extern void obd_sysctl_init (void);
879 extern void obd_sysctl_clean (void);
882 typedef __u8 class_uuid_t[16];
883 //int class_uuid_parse(obd_uuid_t in, class_uuid_t out);
884 void class_uuid_unparse(class_uuid_t in, obd_uuid_t out);
885 #endif /* __LINUX_CLASS_OBD_H */