1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * lustre/cmm/cmm_internal.h
5 * Lustre Cluster Metadata Manager (cmm)
7 * Copyright (C) 2006 Cluster File Systems, Inc.
8 * Author: Mike Pershin <tappro@clusterfs.com>
10 * This file is part of the Lustre file system, http://www.lustre.org
11 * Lustre is a trademark of Cluster File Systems, Inc.
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.
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.
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.
29 #ifndef _CMM_INTERNAL_H
30 #define _CMM_INTERNAL_H
32 #if defined(__KERNEL__)
35 #include <lustre_fld.h>
36 #include <md_object.h>
39 struct md_device cmm_md_dev;
40 /* device flags, taken from enum 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;
47 struct list_head cmm_targets;
48 spinlock_t cmm_tgt_guard;
50 /* client FLD interface */
51 struct lu_client_fld cmm_fld;
56 * Device initialization complete.
58 CMM_INITIALIZED = 1 << 0
61 static inline struct md_device_operations *cmm_child_ops(struct cmm_device *d)
63 return (d->cmm_child->md_ops);
66 static inline struct cmm_device *md2cmm_dev(struct md_device *m)
68 return container_of0(m, struct cmm_device, cmm_md_dev);
71 static inline struct cmm_device *lu2cmm_dev(struct lu_device *d)
73 return container_of0(d, struct cmm_device, cmm_md_dev.md_lu_dev);
76 static inline struct lu_device *cmm2lu_dev(struct cmm_device *d)
78 return (&d->cmm_md_dev.md_lu_dev);
82 struct md_object cmo_obj;
85 /* local CMM object */
87 struct cmm_object cmm_obj;
90 /* remote CMM object */
92 struct cmm_object cmm_obj;
93 /* mds number where object is placed */
97 static inline struct cmm_device *cmm_obj2dev(struct cmm_object *c)
99 return (md2cmm_dev(md_obj2dev(&c->cmo_obj)));
102 static inline struct cmm_object *lu2cmm_obj(struct lu_object *o)
104 //LASSERT(lu_device_is_cmm(o->lo_dev));
105 return container_of0(o, struct cmm_object, cmo_obj.mo_lu);
108 /* get cmm object from md_object */
109 static inline struct cmm_object *md2cmm_obj(struct md_object *o)
111 return container_of0(o, struct cmm_object, cmo_obj);
113 /* get lower-layer object */
114 static inline struct md_object *cmm2child_obj(struct cmm_object *o)
116 return (o ? lu2md(lu_object_next(&o->cmo_obj.mo_lu)) : NULL);
120 struct lu_object *cmm_object_alloc(const struct lu_context *ctx,
121 const struct lu_object_header *hdr,
124 #endif /* __KERNEL__ */
125 #endif /* _CMM_INTERNAL_H */