Whamcloud - gitweb
make lu_context const
[fs/lustre-release.git] / lustre / cmm / mdc_internal.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2006 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 _CMM_MDC_INTERNAL_H
24 #define _CMM_MDC_INTERNAL_H
25
26 #if defined(__KERNEL__)
27
28 #include <obd.h>
29 #include <md_object.h>
30
31 struct mdc_cli_desc {
32         struct obd_connect_data  cl_conn_data;
33         struct obd_uuid          cl_srv_uuid;
34         struct obd_uuid          cl_cli_uuid;
35         struct obd_export        *cl_exp;
36 };
37
38 struct mdc_device {
39         struct md_device        mc_md_dev;
40         /* other MD servers in cluster */
41         struct list_head        mc_linkage;
42         __u32                   mc_num;
43         struct mdc_cli_desc     mc_desc;
44 };
45
46 struct mdc_object {
47         struct md_object        mco_obj;
48 };
49
50 static inline struct lu_device *mdc2lu_dev(struct mdc_device *mc)
51 {
52         return (&mc->mc_md_dev.md_lu_dev);
53 }
54
55 static inline struct mdc_device *md2mdc_dev(struct md_device *md)
56 {
57         return container_of0(md, struct mdc_device, mc_md_dev);
58 }
59
60 static inline struct mdc_device *mdc_obj2dev(struct mdc_object *mco)
61 {
62         return (md2mdc_dev(md_device_get(&mco->mco_obj)));
63 }
64
65 static inline struct mdc_object *lu2mdc_obj(struct lu_object *lo)
66 {
67         return container_of0(lo, struct mdc_object, mco_obj.mo_lu);
68 }
69
70 static inline struct mdc_object *md2mdc_obj(struct md_object *mo)
71 {
72         return container_of0(mo, struct mdc_object, mco_obj);
73 }
74
75 static inline struct mdc_device *lu2mdc_dev(struct lu_device *ld)
76 {
77         return container_of0(ld, struct mdc_device, mc_md_dev.md_lu_dev);
78 }
79
80 int mdc_object_init(const struct lu_context *, struct lu_object*);
81 struct lu_object *mdc_object_alloc(const struct lu_context *,
82                                    struct lu_device *);
83 void mdc_object_free(const struct lu_context *, struct lu_object *);
84 void mdc_object_release(const struct lu_context *, struct lu_object *);
85
86 #endif /* __KERNEL__ */
87 #endif /* _CMM_MDC_INTERNAL_H */