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>
37 #include <linux/lustre_acl.h>
41 struct md_device cmm_md_dev;
42 /* device flags, taken from enum cmm_flags */
44 /* underlaying device in MDS stack, usually MDD */
45 struct md_device *cmm_child;
46 /* FLD client to talk to FLD */
47 struct lu_client_fld *cmm_fld;
48 /* other MD servers in cluster */
49 mdsno_t cmm_local_num;
51 struct list_head cmm_targets;
52 spinlock_t cmm_tgt_guard;
53 cfs_proc_dir_entry_t *cmm_proc_entry;
54 struct lprocfs_stats *cmm_stats;
59 * Device initialization complete.
61 CMM_INITIALIZED = 1 << 0
64 static inline struct md_device_operations *cmm_child_ops(struct cmm_device *d)
66 return (d->cmm_child->md_ops);
69 static inline struct cmm_device *md2cmm_dev(struct md_device *m)
71 return container_of0(m, struct cmm_device, cmm_md_dev);
74 static inline struct cmm_device *lu2cmm_dev(struct lu_device *d)
76 return container_of0(d, struct cmm_device, cmm_md_dev.md_lu_dev);
79 static inline struct lu_device *cmm2lu_dev(struct cmm_device *d)
81 return (&d->cmm_md_dev.md_lu_dev);
84 #ifdef HAVE_SPLIT_SUPPORT
85 enum cmm_split_state {
95 struct md_object cmo_obj;
98 /* local CMM object */
100 struct cmm_object cmm_obj;
101 #ifdef HAVE_SPLIT_SUPPORT
102 /* split state of object (for dirs only)*/
103 enum cmm_split_state clo_split;
107 /* remote CMM object */
109 struct cmm_object cmm_obj;
110 /* mds number where object is placed */
115 CMM_SPLIT_PAGE_COUNT = 1
118 struct cmm_thread_info {
119 struct md_attr cmi_ma;
120 struct lu_buf cmi_buf;
121 struct lu_fid cmi_fid; /* used for le/cpu conversions */
122 struct lu_rdpg cmi_rdpg;
123 /* pointers to pages for readpage. */
124 struct page *cmi_pages[CMM_SPLIT_PAGE_COUNT];
125 struct md_op_spec cmi_spec;
126 struct lmv_stripe_md cmi_lmv;
127 char cmi_xattr_buf[LUSTRE_POSIX_ACL_MAX_SIZE];
129 /* Ops object filename */
130 struct lu_name cti_name;
133 static inline struct cmm_device *cmm_obj2dev(struct cmm_object *c)
135 return (md2cmm_dev(md_obj2dev(&c->cmo_obj)));
138 static inline struct cmm_object *lu2cmm_obj(struct lu_object *o)
140 //LASSERT(lu_device_is_cmm(o->lo_dev));
141 return container_of0(o, struct cmm_object, cmo_obj.mo_lu);
144 /* get cmm object from md_object */
145 static inline struct cmm_object *md2cmm_obj(struct md_object *o)
147 return container_of0(o, struct cmm_object, cmo_obj);
149 /* get lower-layer object */
150 static inline struct md_object *cmm2child_obj(struct cmm_object *o)
152 return (o ? lu2md(lu_object_next(&o->cmo_obj.mo_lu)) : NULL);
155 static inline struct lu_fid* cmm2fid(struct cmm_object *obj)
157 return &(obj->cmo_obj.mo_lu.lo_header->loh_fid);
160 struct cmm_thread_info *cmm_env_info(const struct lu_env *env);
163 struct lu_object *cmm_object_alloc(const struct lu_env *env,
164 const struct lu_object_header *hdr,
168 * local CMM object operations. cml_...
170 static inline struct cml_object *lu2cml_obj(struct lu_object *o)
172 return container_of0(o, struct cml_object, cmm_obj.cmo_obj.mo_lu);
174 static inline struct cml_object *md2cml_obj(struct md_object *mo)
176 return container_of0(mo, struct cml_object, cmm_obj.cmo_obj);
178 static inline struct cml_object *cmm2cml_obj(struct cmm_object *co)
180 return container_of0(co, struct cml_object, cmm_obj);
183 int cmm_upcall(const struct lu_env *env, struct md_device *md,
184 enum md_upcall_event ev);
186 #ifdef HAVE_SPLIT_SUPPORT
188 #define CMM_MD_SIZE(stripes) (sizeof(struct lmv_stripe_md) + \
189 (stripes) * sizeof(struct lu_fid))
192 static inline struct lu_buf *cmm_buf_get(const struct lu_env *env,
193 void *area, ssize_t len)
197 buf = &cmm_env_info(env)->cmi_buf;
203 int cmm_split_check(const struct lu_env *env, struct md_object *mp,
206 int cmm_split_expect(const struct lu_env *env, struct md_object *mo,
207 struct md_attr *ma, int *split);
209 int cmm_split_dir(const struct lu_env *env, struct md_object *mo);
211 int cmm_split_access(const struct lu_env *env, struct md_object *mo,
215 int cmm_fld_lookup(struct cmm_device *cm, const struct lu_fid *fid,
216 mdsno_t *mds, const struct lu_env *env);
218 int cmm_procfs_init(struct cmm_device *cmm, const char *name);
219 int cmm_procfs_fini(struct cmm_device *cmm);
221 void cmm_lprocfs_time_start(const struct lu_env *env);
222 void cmm_lprocfs_time_end(const struct lu_env *env, struct cmm_device *cmm,
226 LPROC_CMM_SPLIT_CHECK,
233 #endif /* __KERNEL__ */
234 #endif /* _CMM_INTERNAL_H */