1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001-2003 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>
47 /* OBD Device Declarations */
48 #define MAX_OBD_DEVICES 128
49 extern struct obd_device obd_dev[MAX_OBD_DEVICES];
51 #define OBD_ATTACHED 0x01
52 #define OBD_SET_UP 0x02
53 #define OBD_RECOVERING 0x04
54 #define OBD_ABORT_RECOVERY 0x08
55 #define OBD_REPLAYABLE 0x10
56 #define OBD_NO_TRANSNO 0x20 /* XXX needs better name */
58 /* OBD Operations Declarations */
61 static inline int obd_check_conn(struct lustre_handle *conn)
63 struct obd_device *obd;
65 CERROR("NULL conn\n");
68 obd = class_conn2obd(conn);
74 if (!obd->obd_flags & OBD_ATTACHED ) {
75 CERROR("obd %d not attached\n", obd->obd_minor);
79 if (!obd->obd_flags & OBD_SET_UP) {
80 CERROR("obd %d not setup\n", obd->obd_minor);
85 CERROR("obd %d not typed\n", obd->obd_minor);
89 if (!obd->obd_type->typ_ops) {
90 CERROR("obd_check_conn: obd %d no operations\n",
98 #define OBT(dev) (dev)->obd_type
99 #define OBP(dev, op) (dev)->obd_type->typ_ops->o_ ## op
101 #define OBD_CHECK_SETUP(conn, exp) \
104 CERROR("NULL connection\n"); \
108 exp = class_conn2export(conn); \
110 CERROR("No export for conn "LPX64":"LPX64"\n", \
111 conn->addr, conn->cookie); \
115 if (!((exp)->exp_obd->obd_flags & OBD_SET_UP)) { \
116 CERROR("Device %d not setup\n", \
117 (exp)->exp_obd->obd_minor); \
122 #define OBD_CHECK_DEVSETUP(obd) \
125 CERROR("NULL device\n"); \
129 if (!((obd)->obd_flags & OBD_SET_UP)) { \
130 CERROR("Device %d not setup\n", \
136 #define OBD_CHECK_OP(obd, op) \
138 if (!OBP((obd), op)) { \
139 CERROR("obd_" #op ": dev %d no operation\n", \
141 RETURN(-EOPNOTSUPP); \
145 static inline int obd_get_info(struct lustre_handle *conn, obd_count keylen,
146 void *key, obd_count *vallen, void **val)
148 struct obd_export *exp;
152 OBD_CHECK_SETUP(conn, exp);
153 OBD_CHECK_OP(exp->exp_obd, get_info);
155 rc = OBP(exp->exp_obd, get_info)(conn, keylen, key, vallen, val);
159 static inline int obd_set_info(struct lustre_handle *conn, obd_count keylen,
160 void *key, obd_count vallen, void *val)
162 struct obd_export *exp;
166 OBD_CHECK_SETUP(conn, exp);
167 OBD_CHECK_OP(exp->exp_obd, set_info);
169 rc = OBP(exp->exp_obd, set_info)(conn, keylen, key, vallen, val);
173 static inline int obd_setup(struct obd_device *obd, int datalen, void *data)
178 OBD_CHECK_OP(obd, setup);
180 rc = OBP(obd, setup)(obd, datalen, data);
184 static inline int obd_cleanup(struct obd_device *obd)
189 OBD_CHECK_DEVSETUP(obd);
190 OBD_CHECK_OP(obd, cleanup);
192 rc = OBP(obd, cleanup)(obd);
196 /* Pack an in-memory MD struct for sending to the MDS and/or disk.
197 * Returns +ve size of packed MD (0 for free), or -ve error.
199 * If @wire_tgt == NULL, MD size is returned (max size if @mem_src == NULL).
200 * If @*wire_tgt != NULL and @mem_src == NULL, @*wire_tgt will be freed.
201 * If @*wire_tgt == NULL, it will be allocated
203 static inline int obd_packmd(struct lustre_handle *conn,
204 struct lov_mds_md **wire_tgt,
205 struct lov_stripe_md *mem_src)
207 struct obd_export *exp;
210 OBD_CHECK_SETUP(conn, exp);
211 OBD_CHECK_OP(exp->exp_obd, packmd);
213 RETURN(OBP(exp->exp_obd, packmd)(conn, wire_tgt, mem_src));
216 static inline int obd_size_wiremd(struct lustre_handle *conn,
217 struct lov_stripe_md *mem_src)
219 return obd_packmd(conn, NULL, mem_src);
222 /* helper functions */
223 static inline int obd_alloc_wiremd(struct lustre_handle *conn,
224 struct lov_mds_md **wire_tgt)
227 LASSERT(*wire_tgt == NULL);
228 return obd_packmd(conn, wire_tgt, NULL);
231 static inline int obd_free_wiremd(struct lustre_handle *conn,
232 struct lov_mds_md **wire_tgt)
236 return obd_packmd(conn, wire_tgt, NULL);
239 /* Unpack an MD struct from the MDS and/or disk to in-memory format.
240 * Returns +ve size of unpacked MD (0 for free), or -ve error.
242 * If @mem_tgt == NULL, MD size is returned (max size if @wire_src == NULL).
243 * If @*mem_tgt != NULL and @wire_src == NULL, @*mem_tgt will be freed.
244 * If @*mem_tgt == NULL, it will be allocated
246 static inline int obd_unpackmd(struct lustre_handle *conn,
247 struct lov_stripe_md **mem_tgt,
248 struct lov_mds_md *wire_src)
250 struct obd_export *exp;
253 OBD_CHECK_SETUP(conn, exp);
254 OBD_CHECK_OP(exp->exp_obd, unpackmd);
256 RETURN(OBP(exp->exp_obd, unpackmd)(conn, mem_tgt, wire_src));
259 static inline int obd_size_memmd(struct lustre_handle *conn,
260 struct lov_mds_md *wire_src)
262 return obd_unpackmd(conn, NULL, wire_src);
265 /* helper functions */
266 static inline int obd_alloc_memmd(struct lustre_handle *conn,
267 struct lov_stripe_md **mem_tgt)
270 LASSERT(*mem_tgt == NULL);
271 return obd_unpackmd(conn, mem_tgt, NULL);
274 static inline int obd_free_memmd(struct lustre_handle *conn,
275 struct lov_stripe_md **mem_tgt)
279 return obd_unpackmd(conn, mem_tgt, NULL);
282 static inline int obd_create(struct lustre_handle *conn, struct obdo *obdo,
283 struct lov_stripe_md **ea,
284 struct obd_trans_info *oti)
286 struct obd_export *exp;
290 OBD_CHECK_SETUP(conn, exp);
291 OBD_CHECK_OP(exp->exp_obd, create);
293 rc = OBP(exp->exp_obd, create)(conn, obdo, ea, oti);
297 static inline int obd_destroy(struct lustre_handle *conn, struct obdo *obdo,
298 struct lov_stripe_md *ea,
299 struct obd_trans_info *oti)
301 struct obd_export *exp;
305 OBD_CHECK_SETUP(conn, exp);
306 OBD_CHECK_OP(exp->exp_obd, destroy);
308 rc = OBP(exp->exp_obd, destroy)(conn, obdo, ea, oti);
312 static inline int obd_getattr(struct lustre_handle *conn, struct obdo *obdo,
313 struct lov_stripe_md *ea)
315 struct obd_export *exp;
319 OBD_CHECK_SETUP(conn, exp);
320 OBD_CHECK_OP(exp->exp_obd, getattr);
322 rc = OBP(exp->exp_obd, getattr)(conn, obdo, ea);
326 static inline int obd_close(struct lustre_handle *conn, struct obdo *obdo,
327 struct lov_stripe_md *ea,
328 struct obd_trans_info *oti)
330 struct obd_export *exp;
334 OBD_CHECK_SETUP(conn, exp);
335 OBD_CHECK_OP(exp->exp_obd, close);
337 rc = OBP(exp->exp_obd, close)(conn, obdo, ea, oti);
341 static inline int obd_open(struct lustre_handle *conn, struct obdo *obdo,
342 struct lov_stripe_md *ea, struct obd_trans_info *oti)
344 struct obd_export *exp;
348 OBD_CHECK_SETUP(conn, exp);
349 OBD_CHECK_OP(exp->exp_obd, open);
351 rc = OBP(exp->exp_obd, open)(conn, obdo, ea, oti);
355 static inline int obd_setattr(struct lustre_handle *conn, struct obdo *obdo,
356 struct lov_stripe_md *ea,
357 struct obd_trans_info *oti)
359 struct obd_export *exp;
363 OBD_CHECK_SETUP(conn, exp);
364 OBD_CHECK_OP(exp->exp_obd, setattr);
366 rc = OBP(exp->exp_obd, setattr)(conn, obdo, ea, oti);
370 static inline int obd_connect(struct lustre_handle *conn,
371 struct obd_device *obd, struct obd_uuid *cluuid,
372 struct recovd_obd *recovd,
373 ptlrpc_recovery_cb_t recover)
378 OBD_CHECK_DEVSETUP(obd);
379 OBD_CHECK_OP(obd, connect);
381 rc = OBP(obd, connect)(conn, obd, cluuid, recovd, recover);
385 static inline int obd_disconnect(struct lustre_handle *conn)
387 struct obd_export *exp;
391 OBD_CHECK_SETUP(conn, exp);
392 OBD_CHECK_OP(exp->exp_obd, disconnect);
394 rc = OBP(exp->exp_obd, disconnect)(conn);
398 static inline int obd_statfs(struct lustre_handle *conn,struct obd_statfs *osfs)
400 struct obd_export *exp;
404 OBD_CHECK_SETUP(conn, exp);
405 OBD_CHECK_OP(exp->exp_obd, statfs);
407 rc = OBP(exp->exp_obd, statfs)(conn, osfs);
411 static inline int obd_punch(struct lustre_handle *conn, struct obdo *oa,
412 struct lov_stripe_md *ea, obd_size start,
413 obd_size end, struct obd_trans_info *oti)
415 struct obd_export *exp;
419 OBD_CHECK_SETUP(conn, exp);
420 OBD_CHECK_OP(exp->exp_obd, punch);
422 rc = OBP(exp->exp_obd, punch)(conn, oa, ea, start, end, oti);
426 static inline int obd_brw(int cmd, struct lustre_handle *conn,
427 struct lov_stripe_md *ea, obd_count oa_bufs,
428 struct brw_page *pg, struct obd_brw_set *set,
429 struct obd_trans_info *oti)
431 struct obd_export *exp;
435 OBD_CHECK_SETUP(conn, exp);
436 OBD_CHECK_OP(exp->exp_obd, brw);
438 if (!(cmd & OBD_BRW_RWMASK)) {
439 CERROR("obd_brw: cmd must be OBD_BRW_READ or OBD_BRW_WRITE\n");
443 rc = OBP(exp->exp_obd, brw)(cmd, conn, ea, oa_bufs, pg, set, oti);
447 static inline int obd_preprw(int cmd, struct lustre_handle *conn,
448 int objcount, struct obd_ioobj *obj,
449 int niocount, struct niobuf_remote *remote,
450 struct niobuf_local *local, void **desc_private,
451 struct obd_trans_info *oti)
453 struct obd_export *exp;
457 OBD_CHECK_SETUP(conn, exp);
458 OBD_CHECK_OP(exp->exp_obd, preprw);
460 rc = OBP(exp->exp_obd, preprw)(cmd, conn, objcount, obj, niocount,
461 remote, local, desc_private, oti);
465 static inline int obd_commitrw(int cmd, struct lustre_handle *conn,
466 int objcount, struct obd_ioobj *obj,
467 int niocount, struct niobuf_local *local,
468 void *desc_private, struct obd_trans_info *oti)
470 struct obd_export *exp;
474 OBD_CHECK_SETUP(conn, exp);
475 OBD_CHECK_OP(exp->exp_obd, commitrw);
477 rc = OBP(exp->exp_obd, commitrw)(cmd, conn, objcount, obj, niocount,
478 local, desc_private, oti);
482 static inline int obd_iocontrol(unsigned int cmd, struct lustre_handle *conn,
483 int len, void *karg, void *uarg)
485 struct obd_export *exp;
489 OBD_CHECK_SETUP(conn, exp);
490 OBD_CHECK_OP(exp->exp_obd, iocontrol);
492 rc = OBP(exp->exp_obd, iocontrol)(cmd, conn, len, karg, uarg);
496 static inline int obd_enqueue(struct lustre_handle *conn,
497 struct lov_stripe_md *ea,
498 struct lustre_handle *parent_lock,
499 __u32 type, void *cookie, int cookielen,
500 __u32 mode, int *flags, void *cb, void *data,
501 int datalen, struct lustre_handle *lockh)
503 struct obd_export *exp;
507 OBD_CHECK_SETUP(conn, exp);
508 OBD_CHECK_OP(exp->exp_obd, enqueue);
510 rc = OBP(exp->exp_obd, enqueue)(conn, ea, parent_lock, type,
511 cookie, cookielen, mode, flags, cb,
512 data, datalen, lockh);
516 static inline int obd_cancel(struct lustre_handle *conn,
517 struct lov_stripe_md *ea, __u32 mode,
518 struct lustre_handle *lockh)
520 struct obd_export *exp;
524 OBD_CHECK_SETUP(conn, exp);
525 OBD_CHECK_OP(exp->exp_obd, cancel);
527 rc = OBP(exp->exp_obd, cancel)(conn, ea, mode, lockh);
531 static inline int obd_cancel_unused(struct lustre_handle *conn,
532 struct lov_stripe_md *ea, int local)
534 struct obd_export *exp;
538 OBD_CHECK_SETUP(conn, exp);
539 OBD_CHECK_OP(exp->exp_obd, cancel_unused);
541 rc = OBP(exp->exp_obd, cancel_unused)(conn, ea, local);
547 /* OBD Metadata Support */
549 extern int obd_init_caches(void);
550 extern void obd_cleanup_caches(void);
552 static inline struct lustre_handle *obdo_handle(struct obdo *oa)
554 return (struct lustre_handle *)&oa->o_inline;
557 static inline void obd_oa2handle(struct lustre_handle *handle, struct obdo *oa)
559 if (oa->o_valid |= OBD_MD_FLHANDLE) {
560 struct lustre_handle *oa_handle = obdo_handle(oa);
561 memcpy(handle, oa_handle, sizeof(*handle));
565 static inline void obd_handle2oa(struct obdo *oa, struct lustre_handle *handle)
567 if (handle && handle->addr) {
568 struct lustre_handle *oa_handle = obdo_handle(oa);
569 memcpy(oa_handle, handle, sizeof(*handle));
570 oa->o_valid |= OBD_MD_FLHANDLE;
575 /* support routines */
576 extern kmem_cache_t *obdo_cachep;
577 static inline struct obdo *obdo_alloc(void)
581 oa = kmem_cache_alloc(obdo_cachep, SLAB_KERNEL);
584 memset(oa, 0, sizeof (*oa));
589 static inline void obdo_free(struct obdo *oa)
593 kmem_cache_free(obdo_cachep, oa);
596 static inline void obdo_from_iattr(struct obdo *oa, struct iattr *attr)
598 unsigned int ia_valid = attr->ia_valid;
600 if (ia_valid & ATTR_ATIME) {
601 oa->o_atime = attr->ia_atime;
602 oa->o_valid |= OBD_MD_FLATIME;
604 if (ia_valid & ATTR_MTIME) {
605 oa->o_mtime = attr->ia_mtime;
606 oa->o_valid |= OBD_MD_FLMTIME;
608 if (ia_valid & ATTR_CTIME) {
609 oa->o_ctime = attr->ia_ctime;
610 oa->o_valid |= OBD_MD_FLCTIME;
612 if (ia_valid & ATTR_SIZE) {
613 oa->o_size = attr->ia_size;
614 oa->o_valid |= OBD_MD_FLSIZE;
616 if (ia_valid & ATTR_MODE) {
617 oa->o_mode = attr->ia_mode;
618 oa->o_valid |= OBD_MD_FLTYPE | OBD_MD_FLMODE;
619 if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID))
620 oa->o_mode &= ~S_ISGID;
622 if (ia_valid & ATTR_UID) {
623 oa->o_uid = attr->ia_uid;
624 oa->o_valid |= OBD_MD_FLUID;
626 if (ia_valid & ATTR_GID) {
627 oa->o_gid = attr->ia_gid;
628 oa->o_valid |= OBD_MD_FLGID;
633 static inline void iattr_from_obdo(struct iattr *attr, struct obdo *oa,
636 memset(attr, 0, sizeof(*attr));
637 if (valid & OBD_MD_FLATIME) {
638 attr->ia_atime = oa->o_atime;
639 attr->ia_valid |= ATTR_ATIME;
641 if (valid & OBD_MD_FLMTIME) {
642 attr->ia_mtime = oa->o_mtime;
643 attr->ia_valid |= ATTR_MTIME;
645 if (valid & OBD_MD_FLCTIME) {
646 attr->ia_ctime = oa->o_ctime;
647 attr->ia_valid |= ATTR_CTIME;
649 if (valid & OBD_MD_FLSIZE) {
650 attr->ia_size = oa->o_size;
651 attr->ia_valid |= ATTR_SIZE;
653 if (valid & OBD_MD_FLTYPE) {
654 attr->ia_mode = (attr->ia_mode & ~S_IFMT)|(oa->o_mode & S_IFMT);
655 attr->ia_valid |= ATTR_MODE;
657 if (valid & OBD_MD_FLMODE) {
658 attr->ia_mode = (attr->ia_mode & S_IFMT)|(oa->o_mode & ~S_IFMT);
659 attr->ia_valid |= ATTR_MODE;
660 if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID))
661 attr->ia_mode &= ~S_ISGID;
663 if (valid & OBD_MD_FLUID)
665 attr->ia_uid = oa->o_uid;
666 attr->ia_valid |= ATTR_UID;
668 if (valid & OBD_MD_FLGID) {
669 attr->ia_gid = oa->o_gid;
670 attr->ia_valid |= ATTR_GID;
675 /* WARNING: the file systems must take care not to tinker with
676 attributes they don't manage (such as blocks). */
678 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
679 #define to_kdev_t(dev) dev
680 #define kdev_t_to_nr(dev) dev
683 static inline void obdo_from_inode(struct obdo *dst, struct inode *src,
686 if (valid & OBD_MD_FLATIME)
687 dst->o_atime = src->i_atime;
688 if (valid & OBD_MD_FLMTIME)
689 dst->o_mtime = src->i_mtime;
690 if (valid & OBD_MD_FLCTIME)
691 dst->o_ctime = src->i_ctime;
692 if (valid & OBD_MD_FLSIZE)
693 dst->o_size = src->i_size;
694 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
695 dst->o_blocks = src->i_blocks;
696 if (valid & OBD_MD_FLBLKSZ)
697 dst->o_blksize = src->i_blksize;
698 if (valid & OBD_MD_FLTYPE)
699 dst->o_mode = (dst->o_mode & ~S_IFMT) | (src->i_mode & S_IFMT);
700 if (valid & OBD_MD_FLMODE)
701 dst->o_mode = (dst->o_mode & S_IFMT) | (src->i_mode & ~S_IFMT);
702 if (valid & OBD_MD_FLUID)
703 dst->o_uid = src->i_uid;
704 if (valid & OBD_MD_FLGID)
705 dst->o_gid = src->i_gid;
706 if (valid & OBD_MD_FLFLAGS)
707 dst->o_flags = src->i_flags;
708 if (valid & OBD_MD_FLNLINK)
709 dst->o_nlink = src->i_nlink;
710 if (valid & OBD_MD_FLGENER)
711 dst->o_generation = src->i_generation;
712 if (valid & OBD_MD_FLRDEV)
713 dst->o_rdev = (__u32)kdev_t_to_nr(src->i_rdev);
715 dst->o_valid |= (valid & ~OBD_MD_FLID);
718 static inline void obdo_to_inode(struct inode *dst, struct obdo *src,
721 valid &= src->o_valid;
723 if (valid & OBD_MD_FLATIME)
724 dst->i_atime = src->o_atime;
725 if (valid & OBD_MD_FLMTIME)
726 dst->i_mtime = src->o_mtime;
727 if (valid & OBD_MD_FLCTIME && src->o_ctime > dst->i_ctime)
728 dst->i_ctime = src->o_ctime;
729 if (valid & OBD_MD_FLSIZE)
730 dst->i_size = src->o_size;
731 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
732 dst->i_blocks = src->o_blocks;
733 if (valid & OBD_MD_FLBLKSZ)
734 dst->i_blksize = src->o_blksize;
735 if (valid & OBD_MD_FLTYPE)
736 dst->i_mode = (dst->i_mode & ~S_IFMT) | (src->o_mode & S_IFMT);
737 if (valid & OBD_MD_FLMODE)
738 dst->i_mode = (dst->i_mode & S_IFMT) | (src->o_mode & ~S_IFMT);
739 if (valid & OBD_MD_FLUID)
740 dst->i_uid = src->o_uid;
741 if (valid & OBD_MD_FLGID)
742 dst->i_gid = src->o_gid;
743 if (valid & OBD_MD_FLFLAGS)
744 dst->i_flags = src->o_flags;
745 if (valid & OBD_MD_FLNLINK)
746 dst->i_nlink = src->o_nlink;
747 if (valid & OBD_MD_FLGENER)
748 dst->i_generation = src->o_generation;
749 if (valid & OBD_MD_FLRDEV)
750 dst->i_rdev = to_kdev_t(src->o_rdev);
754 static inline void obdo_cpy_md(struct obdo *dst, struct obdo *src,
758 CDEBUG(D_INODE, "src obdo %Ld valid 0x%x, dst obdo %Ld\n",
759 (unsigned long long)src->o_id, src->o_valid,
760 (unsigned long long)dst->o_id);
762 if (valid & OBD_MD_FLATIME)
763 dst->o_atime = src->o_atime;
764 if (valid & OBD_MD_FLMTIME)
765 dst->o_mtime = src->o_mtime;
766 if (valid & OBD_MD_FLCTIME)
767 dst->o_ctime = src->o_ctime;
768 if (valid & OBD_MD_FLSIZE)
769 dst->o_size = src->o_size;
770 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
771 dst->o_blocks = src->o_blocks;
772 if (valid & OBD_MD_FLBLKSZ)
773 dst->o_blksize = src->o_blksize;
774 if (valid & OBD_MD_FLTYPE)
775 dst->o_mode = (dst->o_mode & ~S_IFMT) | (src->o_mode & S_IFMT);
776 if (valid & OBD_MD_FLMODE)
777 dst->o_mode = (dst->o_mode & S_IFMT) | (src->o_mode & ~S_IFMT);
778 if (valid & OBD_MD_FLUID)
779 dst->o_uid = src->o_uid;
780 if (valid & OBD_MD_FLGID)
781 dst->o_gid = src->o_gid;
782 if (valid & OBD_MD_FLFLAGS)
783 dst->o_flags = src->o_flags;
785 if (valid & OBD_MD_FLOBDFLG)
786 dst->o_obdflags = src->o_obdflags;
788 if (valid & OBD_MD_FLNLINK)
789 dst->o_nlink = src->o_nlink;
790 if (valid & OBD_MD_FLGENER)
791 dst->o_generation = src->o_generation;
792 if (valid & OBD_MD_FLRDEV)
793 dst->o_rdev = src->o_rdev;
794 if (valid & OBD_MD_FLINLINE &&
795 src->o_obdflags & OBD_FL_INLINEDATA) {
796 memcpy(dst->o_inline, src->o_inline, sizeof(src->o_inline));
797 dst->o_obdflags |= OBD_FL_INLINEDATA;
800 dst->o_valid |= valid;
804 /* returns FALSE if comparison (by flags) is same, TRUE if changed */
805 static inline int obdo_cmp_md(struct obdo *dst, struct obdo *src,
810 if ( compare & OBD_MD_FLATIME )
811 res = (res || (dst->o_atime != src->o_atime));
812 if ( compare & OBD_MD_FLMTIME )
813 res = (res || (dst->o_mtime != src->o_mtime));
814 if ( compare & OBD_MD_FLCTIME )
815 res = (res || (dst->o_ctime != src->o_ctime));
816 if ( compare & OBD_MD_FLSIZE )
817 res = (res || (dst->o_size != src->o_size));
818 if ( compare & OBD_MD_FLBLOCKS ) /* allocation of space */
819 res = (res || (dst->o_blocks != src->o_blocks));
820 if ( compare & OBD_MD_FLBLKSZ )
821 res = (res || (dst->o_blksize != src->o_blksize));
822 if ( compare & OBD_MD_FLTYPE )
823 res = (res || (((dst->o_mode ^ src->o_mode) & S_IFMT) != 0));
824 if ( compare & OBD_MD_FLMODE )
825 res = (res || (((dst->o_mode ^ src->o_mode) & ~S_IFMT) != 0));
826 if ( compare & OBD_MD_FLUID )
827 res = (res || (dst->o_uid != src->o_uid));
828 if ( compare & OBD_MD_FLGID )
829 res = (res || (dst->o_gid != src->o_gid));
830 if ( compare & OBD_MD_FLFLAGS )
831 res = (res || (dst->o_flags != src->o_flags));
832 if ( compare & OBD_MD_FLNLINK )
833 res = (res || (dst->o_nlink != src->o_nlink));
834 if ( compare & OBD_MD_FLGENER )
835 res = (res || (dst->o_generation != src->o_generation));
836 /* XXX Don't know if thses should be included here - wasn't previously
837 if ( compare & OBD_MD_FLINLINE )
838 res = (res || memcmp(dst->o_inline, src->o_inline));
845 /* I'm as embarrassed about this as you are.
847 * <shaver> // XXX do not look into _superhack with remaining eye
848 * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */
849 extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
850 extern void (*ptlrpc_abort_inflight_superhack)(struct obd_import *imp,
853 int class_register_type(struct obd_ops *ops, struct lprocfs_vars* vars,
855 int class_unregister_type(char *nm);
856 int class_name2dev(char *name);
857 int class_uuid2dev(struct obd_uuid *uuid);
858 struct obd_device *class_uuid2obd(struct obd_uuid *uuid);
859 struct obd_export *class_new_export(struct obd_device *obddev);
860 struct obd_type *class_get_type(char *name);
861 void class_put_type(struct obd_type *type);
862 void class_destroy_export(struct obd_export *exp);
863 int class_connect(struct lustre_handle *conn, struct obd_device *obd,
864 struct obd_uuid *cluuid);
865 int class_disconnect(struct lustre_handle *conn);
866 void class_disconnect_all(struct obd_device *obddev);
868 /* generic operations shared by various OBD types */
869 int class_multi_setup(struct obd_device *obddev, uint32_t len, void *data);
870 int class_multi_cleanup(struct obd_device *obddev);
872 extern void (*class_signal_connection_failure)(struct ptlrpc_connection *);
874 static inline struct ptlrpc_connection *class_rd2conn(struct recovd_data *rd)
876 /* reuse list_entry's member-pointer offset stuff */
877 return list_entry(rd, struct ptlrpc_connection, c_recovd_data);
882 void statfs_pack(struct obd_statfs *osfs, struct statfs *sfs);
883 void statfs_unpack(struct statfs *sfs, struct obd_statfs *osfs);
884 void obd_statfs_pack(struct obd_statfs *tgt, struct obd_statfs *src);
885 void obd_statfs_unpack(struct obd_statfs *tgt, struct obd_statfs *src);
888 struct obd_class_user_state {
889 struct obd_device *ocus_current_obd;
890 struct list_head ocus_conns;
893 struct obd_class_user_conn {
894 struct list_head ocuc_chain;
895 struct lustre_handle ocuc_conn;
901 extern void obd_sysctl_init (void);
902 extern void obd_sysctl_clean (void);
905 typedef __u8 class_uuid_t[16];
906 //int class_uuid_parse(struct obd_uuid in, class_uuid_t out);
907 void class_uuid_unparse(class_uuid_t in, struct obd_uuid *out);
908 #endif /* __LINUX_OBD_CLASS_H */