Whamcloud - gitweb
791ded4df919cc6fce372573279330aa5869fc77
[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  *  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_INTERNAL_H
24 #define _CMM_INTERNAL_H
25
26 #if defined(__KERNEL__)
27
28 #include <linux/obd.h>
29 #include <linux/md_object.h>
30
31 struct cmm_mdc_device {
32         struct md_device mdc_md_dev;
33         /* other MD servers in cluster */
34         __u32            cmm_tgt_count;
35         struct list_head cmm_tgt_linkage;
36 };
37
38 struct cmm_device {
39         struct md_device cmm_md_dev;
40         /* underlaying device in MDS stack, usually MDD */
41         struct md_device *cmm_child;
42         /* other MD servers in cluster */
43         __u32            local_num;
44         __u32            cmm_tgt_count;
45         struct list_head cmm_targets;
46 };
47
48 static inline struct md_device_operations *cmm_child_ops(struct cmm_device *d)
49 {
50         return (d->cmm_child->md_ops);
51 }
52
53 static inline struct cmm_device *md2cmm_dev(struct md_device *m)
54 {
55         return container_of0(m, struct cmm_device, cmm_md_dev);
56 }
57
58 static inline struct cmm_device *lu2cmm_dev(struct lu_device *d)
59 {
60         //LASSERT(lu_device_is_cmm(d));
61         return container_of0(d, struct cmm_device, cmm_md_dev.md_lu_dev);
62 }
63
64 static inline struct lu_device *cmm2lu_dev(struct cmm_device *d)
65 {
66         return (&d->cmm_md_dev.md_lu_dev);
67 }
68
69 struct cmm_object {
70         struct md_object        cmo_obj;
71 };
72
73 static inline struct cmm_device *cmm_obj2dev(struct cmm_object *c)
74 {
75         return (md2cmm_dev(md_device_get(&c->cmo_obj)));
76 }
77
78 static inline struct cmm_object *lu2cmm_obj(struct lu_object *o)
79 {
80         //LASSERT(lu_device_is_cmm(o->lo_dev));
81         return container_of0(o, struct cmm_object, cmo_obj.mo_lu);
82 }
83
84 /* get cmm object from md_object */
85 static inline struct cmm_object *md2cmm_obj(struct md_object *o)
86 {
87         return container_of0(o, struct cmm_object, cmo_obj);
88 }
89 /* get lower-layer object */
90 static inline struct md_object *cmm2child_obj(struct cmm_object *o)
91 {
92         return lu2md(lu_object_next(&o->cmo_obj.mo_lu));
93 }
94
95 /* cmm device */
96 int cmm_add_mdc(struct cmm_device *, struct lustre_cfg *);
97
98 /* cmm_object.c */
99 struct lu_object *cmm_object_alloc(struct lu_context *ctx, struct lu_device *);
100 void cmm_object_free(struct lu_context *ctx, struct lu_object *o);
101 //int cmm_getattr(struct lu_object *o, struct lu_attr *a);
102 //int cmm_setattr(struct lu_object *o, struct lu_attr *a);
103
104 /* cmm md operations */
105 int cmm_config(struct lu_context *ctx, struct md_device *md, const char *name,
106                void *buf, int size, int mode);
107 int cmm_root_get(struct lu_context *ctx, struct md_device *m, struct lu_fid *f);
108 int cmm_statfs(struct lu_context *ctx,
109                struct md_device *m, struct kstatfs *sfs);
110 int cmm_mkdir(struct lu_context *ctxt, struct md_object *o, const char *name,
111               struct md_object *child);
112 int cmm_xattr_get(struct lu_context *ctxt,
113                   struct md_object *obj, void *buf, int size,
114                   const char *name);
115
116 #endif /* __KERNEL__ */
117 #endif /* _CMM_INTERNAL_H */