Whamcloud - gitweb
file lc_modprobe.sh.in was added on branch b_new_cmd on 2006-08-19 03:08:14 +0000
[fs/lustre-release.git] / lustre / cmm / cmm_internal.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  lustre/cmm/cmm_internal.h
5  *  Lustre Cluster Metadata Manager (cmm)
6  *
7  *  Copyright (C) 2006 Cluster File Systems, Inc.
8  *   Author: Mike Pershin <tappro@clusterfs.com>
9  *   
10  *   This file is part of the Lustre file system, http://www.lustre.org
11  *   Lustre is a trademark of Cluster File Systems, Inc.
12  *
13  *   You may have signed or agreed to another license before downloading
14  *   this software.  If so, you are bound by the terms and conditions
15  *   of that agreement, and the following does not apply to you.  See the
16  *   LICENSE file included with this distribution for more information.
17  *
18  *   If you did not agree to a different license, then this copy of Lustre
19  *   is open source software; you can redistribute it and/or modify it
20  *   under the terms of version 2 of the GNU General Public License as
21  *   published by the Free Software Foundation.
22  *
23  *   In either case, Lustre is distributed in the hope that it will be
24  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
25  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  *   license text for more details.
27  */
28
29 #ifndef _CMM_INTERNAL_H
30 #define _CMM_INTERNAL_H
31
32 #if defined(__KERNEL__)
33
34 #include <obd.h>
35 #include <lustre_fld.h>
36 #include <md_object.h>
37
38 struct cmm_device {
39         struct md_device      cmm_md_dev;
40         /* device flags, taken from enum cmm_flags */
41         __u32                 cmm_flags;
42         /* underlaying device in MDS stack, usually MDD */
43         struct md_device      *cmm_child;
44         /* other MD servers in cluster */
45         mdsno_t               cmm_local_num;
46         __u32                 cmm_tgt_count;
47         struct list_head      cmm_targets;
48         spinlock_t            cmm_tgt_guard;
49
50         /* client FLD interface */
51         struct lu_client_fld  cmm_fld;
52 };
53
54 enum cmm_flags {
55         /*
56          * Device initialization complete.
57          */
58         CMM_INITIALIZED = 1 << 0
59 };
60
61 static inline struct md_device_operations *cmm_child_ops(struct cmm_device *d)
62 {
63         return (d->cmm_child->md_ops);
64 }
65
66 static inline struct cmm_device *md2cmm_dev(struct md_device *m)
67 {
68         return container_of0(m, struct cmm_device, cmm_md_dev);
69 }
70
71 static inline struct cmm_device *lu2cmm_dev(struct lu_device *d)
72 {
73         return container_of0(d, struct cmm_device, cmm_md_dev.md_lu_dev);
74 }
75
76 static inline struct lu_device *cmm2lu_dev(struct cmm_device *d)
77 {
78         return (&d->cmm_md_dev.md_lu_dev);
79 }
80
81 struct cmm_object {
82         struct md_object cmo_obj;
83 };
84
85 /* local CMM object */
86 struct cml_object {
87         struct cmm_object cmm_obj;
88 };
89
90 /* remote CMM object */
91 struct cmr_object {
92         struct cmm_object cmm_obj;
93         /* mds number where object is placed */
94         mdsno_t           cmo_num;
95 };
96
97 static inline struct cmm_device *cmm_obj2dev(struct cmm_object *c)
98 {
99         return (md2cmm_dev(md_obj2dev(&c->cmo_obj)));
100 }
101
102 static inline struct cmm_object *lu2cmm_obj(struct lu_object *o)
103 {
104         //LASSERT(lu_device_is_cmm(o->lo_dev));
105         return container_of0(o, struct cmm_object, cmo_obj.mo_lu);
106 }
107
108 /* get cmm object from md_object */
109 static inline struct cmm_object *md2cmm_obj(struct md_object *o)
110 {
111         return container_of0(o, struct cmm_object, cmo_obj);
112 }
113 /* get lower-layer object */
114 static inline struct md_object *cmm2child_obj(struct cmm_object *o)
115 {
116         return (o ? lu2md(lu_object_next(&o->cmo_obj.mo_lu)) : NULL);
117 }
118
119 /* cmm_object.c */
120 struct lu_object *cmm_object_alloc(const struct lu_context *ctx,
121                                    const struct lu_object_header *hdr,
122                                    struct lu_device *);
123
124 #endif /* __KERNEL__ */
125 #endif /* _CMM_INTERNAL_H */
126