1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 * Copyright (C) 2006 Cluster File Systems, Inc.
6 * Author: Wang Di <wangdi@clusterfs.com>
8 * This file is part of the Lustre file system, http://www.lustre.org
9 * Lustre is a trademark of Cluster File Systems, Inc.
11 * You may have signed or agreed to another license before downloading
12 * this software. If so, you are bound by the terms and conditions
13 * of that agreement, and the following does not apply to you. See the
14 * LICENSE file included with this distribution for more information.
16 * If you did not agree to a different license, then this copy of Lustre
17 * is open source software; you can redistribute it and/or modify it
18 * under the terms of version 2 of the GNU General Public License as
19 * published by the Free Software Foundation.
21 * In either case, Lustre is distributed in the hope that it will be
22 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
23 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * license text for more details.
27 #ifndef _MDD_INTERNAL_H
28 #define _MDD_INTERNAL_H
30 #include <asm/semaphore.h>
31 #include <md_object.h>
36 struct obd_device *mdd_lov_obd;
37 struct obd_uuid mdd_lov_uuid;
38 struct lov_desc mdd_lov_desc;
39 obd_id *mdd_lov_objids;
40 int mdd_lov_objids_size;
41 __u32 mdd_lov_objids_in_file;
42 int mdd_lov_nextid_set;
43 struct lu_fid mdd_lov_objid_fid;
44 struct dt_object *mdd_lov_objid_obj;
45 unsigned int mdd_lov_objids_dirty:1;
49 struct md_device mdd_md_dev;
50 struct dt_device *mdd_child;
51 struct mdd_lov_info mdd_lov_info;
52 struct dt_device mdd_lov_dev;
54 int mdd_max_cookiesize;
55 struct lu_fid mdd_root_fid;
59 struct md_object mod_obj;
62 struct mdd_thread_info {
63 struct txn_param mti_param;
64 struct lu_fid mti_fid;
65 struct lu_attr mti_attr;
66 struct lov_desc mti_ld;
67 struct lov_mds_md mti_lmm;
70 int mdd_lov_init(const struct lu_context *ctxt, struct mdd_device *mdd,
71 struct lustre_cfg *cfg);
72 int mdd_lov_fini(const struct lu_context *ctxt, struct mdd_device *mdd);
73 int mdd_notify(const struct lu_context *ctxt, struct lu_device *ld,
74 struct obd_device *watched, enum obd_notify_event ev,
77 int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj,
78 const void *buf, int buf_len, const char *name);
79 int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj,
80 struct md_object *child);
81 int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd,
82 struct mdd_object *child);
83 struct mdd_thread_info *mdd_ctx_info(const struct lu_context *ctx);
84 extern struct lu_device_operations mdd_lu_ops;
85 static inline int lu_device_is_mdd(struct lu_device *d)
88 * XXX for now. Tags in lu_device_type->ldt_something are needed.
90 return ergo(d != NULL && d->ld_ops != NULL, d->ld_ops == &mdd_lu_ops);
93 static inline struct mdd_device* lu2mdd_dev(struct lu_device *d)
95 LASSERT(lu_device_is_mdd(d));
96 return container_of0(d, struct mdd_device, mdd_md_dev.md_lu_dev);
99 static inline struct lu_device *mdd2lu_dev(struct mdd_device *d)
101 return (&d->mdd_md_dev.md_lu_dev);
104 static inline struct mdd_object *lu2mdd_obj(struct lu_object *o)
106 LASSERT(lu_device_is_mdd(o->lo_dev));
107 return container_of0(o, struct mdd_object, mod_obj.mo_lu);
110 static inline struct mdd_device* mdo2mdd(struct md_object *mdo)
112 return lu2mdd_dev(mdo->mo_lu.lo_dev);
115 static inline struct mdd_object* md2mdd_obj(struct md_object *mdo)
117 return container_of0(mdo, struct mdd_object, mod_obj);
120 static inline struct dt_device_operations *mdd_child_ops(struct mdd_device *d)
122 return d->mdd_child->dd_ops;
125 static inline struct dt_object* mdd_object_child(struct mdd_object *o)
127 return container_of0(lu_object_next(&o->mod_obj.mo_lu),
128 struct dt_object, do_lu);