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>
32 struct md_device cmm_md_dev;
33 /* underlaying device in MDS stack, usually MDD */
34 struct md_device *cmm_child;
35 /* other MD servers in cluster */
38 struct list_head cmm_targets;
41 static inline struct md_device_operations *cmm_child_ops(struct cmm_device *d)
43 return (d->cmm_child->md_ops);
46 static inline struct cmm_device *md2cmm_dev(struct md_device *m)
48 return container_of0(m, struct cmm_device, cmm_md_dev);
51 static inline struct cmm_device *lu2cmm_dev(struct lu_device *d)
53 //LASSERT(lu_device_is_cmm(d));
54 return container_of0(d, struct cmm_device, cmm_md_dev.md_lu_dev);
57 static inline struct lu_device *cmm2lu_dev(struct cmm_device *d)
59 return (&d->cmm_md_dev.md_lu_dev);
63 struct md_object cmo_obj;
64 /* mds number where object is placed */
68 static inline struct cmm_device *cmm_obj2dev(struct cmm_object *c)
70 return (md2cmm_dev(md_device_get(&c->cmo_obj)));
73 static inline struct cmm_object *lu2cmm_obj(struct lu_object *o)
75 //LASSERT(lu_device_is_cmm(o->lo_dev));
76 return container_of0(o, struct cmm_object, cmo_obj.mo_lu);
79 static inline int cmm_is_local_obj(struct cmm_object *c)
81 return (c->cmo_num == cmm_obj2dev(c)->cmm_local_num);
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 struct lu_object *cmm_object_alloc(struct lu_context *ctx, struct lu_device *);
97 void cmm_object_free(struct lu_context *ctx, struct lu_object *o);
98 //int cmm_getattr(struct lu_object *o, struct lu_attr *a);
99 //int cmm_setattr(struct lu_object *o, struct lu_attr *a);
101 /* cmm md operations */
102 int cmm_config(struct lu_context *ctx, struct md_device *md, const char *name,
103 void *buf, int size, int mode);
104 int cmm_root_get(struct lu_context *ctx, struct md_device *m, struct lu_fid *f);
105 int cmm_statfs(struct lu_context *ctx,
106 struct md_device *m, struct kstatfs *sfs);
107 int cmm_mkdir(struct lu_context *ctxt, struct lu_attr*,
108 struct md_object *o, const char *name,
109 struct md_object *child);
110 int cmm_xattr_get(struct lu_context *ctxt,
111 struct md_object *obj, void *buf, int size,
114 #endif /* __KERNEL__ */
115 #endif /* _CMM_INTERNAL_H */