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 md_device mdd_md_dev;
37 struct dt_device *mdd_child;
38 struct md_lov_info mdd_lov_info;
39 struct dt_device mdd_lov_dev;
40 struct lu_fid mdd_root_fid;
41 struct dt_device_param mdd_dt_conf;
45 struct md_object mod_obj;
48 struct mdd_thread_info {
49 struct txn_param mti_param;
50 struct lu_fid mti_fid;
51 struct lu_attr mti_attr;
52 struct lov_desc mti_ld;
53 struct lov_mds_md mti_lmm;
56 int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd,
58 int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj,
59 const void *buf, int buf_len, const char *name, int fl);
60 int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj,
61 struct md_object *child, struct lov_mds_md *lmm,
62 int lmm_size, int mode);
63 int mdd_lov_create(const struct lu_context *ctxt, struct mdd_device *mdd,
64 struct mdd_object *parent, struct mdd_object *child,
65 struct lov_mds_md **lmm, int *lmm_size, const void *eadata,
66 int eadatasize, struct lu_attr *la);
67 int mdd_get_md(const struct lu_context *ctxt, struct md_object *obj,
68 void *md, int *md_size);
69 int mdd_unlink_log(const struct lu_context *ctxt, struct mdd_device *mdd,
70 struct mdd_object *mdd_cobj, struct md_attr *ma);
71 struct mdd_thread_info *mdd_ctx_info(const struct lu_context *ctx);
73 extern struct lu_device_operations mdd_lu_ops;
74 static inline int lu_device_is_mdd(struct lu_device *d)
76 return ergo(d != NULL && d->ld_ops != NULL, d->ld_ops == &mdd_lu_ops);
79 static inline struct mdd_device* lu2mdd_dev(struct lu_device *d)
81 LASSERT(lu_device_is_mdd(d));
82 return container_of0(d, struct mdd_device, mdd_md_dev.md_lu_dev);
85 static inline struct lu_device *mdd2lu_dev(struct mdd_device *d)
87 return (&d->mdd_md_dev.md_lu_dev);
90 static inline struct mdd_object *lu2mdd_obj(struct lu_object *o)
92 LASSERT(lu_device_is_mdd(o->lo_dev));
93 return container_of0(o, struct mdd_object, mod_obj.mo_lu);
96 static inline struct mdd_device* mdo2mdd(struct md_object *mdo)
98 return lu2mdd_dev(mdo->mo_lu.lo_dev);
101 static inline struct mdd_object* md2mdd_obj(struct md_object *mdo)
103 return container_of0(mdo, struct mdd_object, mod_obj);
106 static inline struct dt_device_operations *mdd_child_ops(struct mdd_device *d)
108 return d->mdd_child->dd_ops;
111 static inline struct lu_object *mdd2lu_obj(struct mdd_object *obj)
113 return &obj->mod_obj.mo_lu;
116 static inline struct dt_object* mdd_object_child(struct mdd_object *o)
118 return container_of0(lu_object_next(mdd2lu_obj(o)),
119 struct dt_object, do_lu);
121 static inline struct obd_device *mdd2_obd(struct mdd_device *mdd)
123 return mdd->mdd_md_dev.md_lu_dev.ld_obd;