1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2006 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
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.
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.
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.
23 #ifndef _CMM_INTERNAL_H
24 #define _CMM_INTERNAL_H
26 #if defined(__KERNEL__)
28 #include <linux/obd.h>
29 #include <linux/md_object.h>
31 struct cmm_mdc_device {
32 struct md_device mdc_md_dev;
33 /* other MD servers in cluster */
35 struct list_head cmm_tgt_linkage;
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 */
45 struct list_head cmm_targets;
48 static inline struct md_device_operations *cmm_child_ops(struct cmm_device *d)
50 return (d->cmm_child->md_ops);
53 static inline struct cmm_device *md2cmm_dev(struct md_device *m)
55 return container_of0(m, struct cmm_device, cmm_md_dev);
58 static inline struct cmm_device *lu2cmm_dev(struct lu_device *d)
60 //LASSERT(lu_device_is_cmm(d));
61 return container_of0(d, struct cmm_device, cmm_md_dev.md_lu_dev);
64 static inline struct lu_device *cmm2lu_dev(struct cmm_device *d)
66 return (&d->cmm_md_dev.md_lu_dev);
70 struct md_object cmo_obj;
73 static inline struct cmm_device *cmm_obj2dev(struct cmm_object *c)
75 return (md2cmm_dev(md_device_get(&c->cmo_obj)));
78 static inline struct cmm_object *lu2cmm_obj(struct lu_object *o)
80 //LASSERT(lu_device_is_cmm(o->lo_dev));
81 return container_of0(o, struct cmm_object, cmo_obj.mo_lu);
84 /* get cmm object from md_object */
85 static inline struct cmm_object *md2cmm_obj(struct md_object *o)
87 return container_of0(o, struct cmm_object, cmo_obj);
89 /* get lower-layer object */
90 static inline struct md_object *cmm2child_obj(struct cmm_object *o)
92 return lu2md(lu_object_next(&o->cmo_obj.mo_lu));
96 int cmm_add_mdc(struct cmm_device *, struct lustre_cfg *);
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);
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,
116 #endif /* __KERNEL__ */
117 #endif /* _CMM_INTERNAL_H */