4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2013, Intel Corporation.
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>
42 #include <lustre_lmv.h>
44 #define LMV_MAX_TGT_COUNT 128
46 #define lmv_init_lock(lmv) mutex_lock(&lmv->init_mutex);
47 #define lmv_init_unlock(lmv) mutex_unlock(&lmv->init_mutex);
49 #define LL_IT2STR(it) \
50 ((it) ? ldlm_it2str((it)->it_op) : "0")
52 int lmv_check_connect(struct obd_device *obd);
54 int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
55 void *lmm, int lmmsize, struct lookup_intent *it,
56 int flags, struct ptlrpc_request **reqp,
57 ldlm_blocking_callback cb_blocking,
58 __u64 extra_lock_flags);
60 int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data,
61 void *lmm, int lmmsize, struct lookup_intent *it,
62 int flags, struct ptlrpc_request **reqp,
63 ldlm_blocking_callback cb_blocking,
64 __u64 extra_lock_flags);
66 int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data,
67 void *lmm, int lmmsize, struct lookup_intent *it,
68 int flags, struct ptlrpc_request **reqp,
69 ldlm_blocking_callback cb_blocking,
70 __u64 extra_lock_flags);
72 int lmv_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
74 int lmv_fld_lookup(struct lmv_obd *lmv, const struct lu_fid *fid,
76 int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid,
78 int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
79 struct md_op_data *op_data);
81 int lmv_unpack_md(struct obd_export *exp, struct lmv_stripe_md **lsmp,
82 const union lmv_mds_md *lmm, int stripe_count);
84 int lmv_revalidate_slaves(struct obd_export *exp, struct mdt_body *mbody,
85 struct lmv_stripe_md *lsm,
86 ldlm_blocking_callback cb_blocking,
87 int extra_lock_flags);
89 static inline struct lmv_tgt_desc *
90 lmv_get_target(struct lmv_obd *lmv, mdsno_t mds)
92 int count = lmv->desc.ld_tgt_count;
95 for (i = 0; i < count; i++) {
96 if (lmv->tgts[i] == NULL)
99 if (lmv->tgts[i]->ltd_idx == mds)
103 return ERR_PTR(-ENODEV);
106 static inline struct lmv_tgt_desc *
107 lmv_find_target(struct lmv_obd *lmv, const struct lu_fid *fid)
112 if (lmv->desc.ld_tgt_count > 1) {
113 rc = lmv_fld_lookup(lmv, fid, &mds);
118 return lmv_get_target(lmv, mds);
121 static inline int lmv_stripe_md_size(int stripe_count)
123 struct lmv_stripe_md *lsm;
125 return sizeof(*lsm) + stripe_count * sizeof(lsm->lsm_md_oinfo[0]);
128 int lmv_name_to_stripe_index(enum lmv_hash_type hashtype,
129 unsigned int max_mdt_index,
130 const char *name, int namelen);
132 static inline const struct lmv_oinfo *
133 lsm_name_to_stripe_info(const struct lmv_stripe_md *lsm, const char *name,
138 stripe_index = lmv_name_to_stripe_index(lsm->lsm_md_hash_type,
139 lsm->lsm_md_stripe_count,
141 if (stripe_index < 0)
142 return ERR_PTR(stripe_index);
144 LASSERTF(stripe_index < lsm->lsm_md_stripe_count,
145 "stripe_index = %d, stripe_count = %d hash_type = %x"
146 "name = %.*s\n", stripe_index, lsm->lsm_md_stripe_count,
147 lsm->lsm_md_hash_type, namelen, name);
149 return &lsm->lsm_md_oinfo[stripe_index];
154 *lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
158 extern struct lprocfs_seq_vars lprocfs_lmv_obd_vars[];
160 extern struct file_operations lmv_proc_target_fops;