1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #ifndef _LMV_INTERNAL_H_
38 #define _LMV_INTERNAL_H_
40 #include <lustre/lustre_idl.h>
43 #define LMV_MAX_TGT_COUNT 128
45 #define lmv_init_lock(lmv) down(&lmv->init_sem);
46 #define lmv_init_unlock(lmv) up(&lmv->init_sem);
48 #define LL_IT2STR(it) \
49 ((it) ? ldlm_it2str((it)->it_op) : "0")
57 * Cached home mds number for @li_fid.
63 unsigned long ls_size;
70 #define O_FREEING (1 << 0)
74 * Link to global objects list.
76 struct list_head lo_list;
78 * Sema for protecting fields.
80 struct semaphore lo_guard;
82 * Object state like O_FREEING.
94 * Object hash type to find stripe by name.
104 struct lmv_stripe *lo_stripes;
106 * Pointer to LMV obd.
108 struct obd_device *lo_obd;
111 int lmv_object_setup(struct obd_device *obd);
112 void lmv_object_cleanup(struct obd_device *obd);
115 lmv_object_lock(struct lmv_object *obj)
118 down(&obj->lo_guard);
122 lmv_object_unlock(struct lmv_object *obj)
128 void lmv_object_add(struct lmv_object *obj);
129 void lmv_object_del(struct lmv_object *obj);
131 void lmv_object_put(struct lmv_object *obj);
132 void lmv_object_put_unlock(struct lmv_object *obj);
133 void lmv_object_free(struct lmv_object *obj);
135 struct lmv_object *lmv_object_get(struct lmv_object *obj);
137 struct lmv_object *lmv_object_find(struct obd_device *obd,
138 const struct lu_fid *fid);
140 struct lmv_object *lmv_object_find_lock(struct obd_device *obd,
141 const struct lu_fid *fid);
143 struct lmv_object *lmv_object_alloc(struct obd_device *obd,
144 const struct lu_fid *fid,
145 struct lmv_stripe_md *mea);
147 struct lmv_object *lmv_object_create(struct obd_export *exp,
148 const struct lu_fid *fid,
149 struct lmv_stripe_md *mea);
151 int lmv_object_delete(struct obd_export *exp,
152 const struct lu_fid *fid);
154 int lmv_check_connect(struct obd_device *obd);
156 int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
157 void *lmm, int lmmsize, struct lookup_intent *it,
158 int flags, struct ptlrpc_request **reqp,
159 ldlm_blocking_callback cb_blocking,
160 int extra_lock_flags);
162 int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data,
163 void *lmm, int lmmsize, struct lookup_intent *it,
164 int flags, struct ptlrpc_request **reqp,
165 ldlm_blocking_callback cb_blocking,
166 int extra_lock_flags);
168 int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data,
169 void *lmm, int lmmsize, struct lookup_intent *it,
170 int flags, struct ptlrpc_request **reqp,
171 ldlm_blocking_callback cb_blocking,
172 int extra_lock_flags);
174 int lmv_allocate_slaves(struct obd_device *obd, struct lu_fid *pid,
175 struct md_op_data *op, struct lu_fid *fid);
177 int lmv_revalidate_slaves(struct obd_export *, struct ptlrpc_request **,
178 const struct lu_fid *, struct lookup_intent *, int,
179 ldlm_blocking_callback cb_blocking,
180 int extra_lock_flags);
182 int lmv_handle_split(struct obd_export *, const struct lu_fid *);
183 int lmv_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
185 int lmv_fld_lookup(struct lmv_obd *lmv, const struct lu_fid *fid,
187 int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid,
189 int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
190 struct md_op_data *op_data);
192 static inline struct lmv_stripe_md *lmv_get_mea(struct ptlrpc_request *req)
194 struct mdt_body *body;
195 struct lmv_stripe_md *mea;
197 LASSERT(req != NULL);
199 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
201 if (!body || !S_ISDIR(body->mode) || !body->eadatasize)
204 mea = req_capsule_server_sized_get(&req->rq_pill, &RMF_MDT_MD,
206 LASSERT(mea != NULL);
208 if (mea->mea_count == 0)
210 if( mea->mea_magic != MEA_MAGIC_LAST_CHAR &&
211 mea->mea_magic != MEA_MAGIC_ALL_CHARS &&
212 mea->mea_magic != MEA_MAGIC_HASH_SEGMENT)
218 static inline int lmv_get_easize(struct lmv_obd *lmv)
220 return sizeof(struct lmv_stripe_md) +
221 lmv->desc.ld_tgt_count *
222 sizeof(struct lu_fid);
225 static inline struct lmv_tgt_desc *
226 lmv_get_target(struct lmv_obd *lmv, mdsno_t mds)
228 return &lmv->tgts[mds];
231 static inline struct lmv_tgt_desc *
232 lmv_find_target(struct lmv_obd *lmv, const struct lu_fid *fid)
237 rc = lmv_fld_lookup(lmv, fid, &mds);
241 return lmv_get_target(lmv, mds);
246 void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars);
248 static inline void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars)
250 memset(lvars, 0, sizeof(*lvars));
253 extern struct file_operations lmv_proc_target_fops;