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) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2012, Whamcloud, Inc.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/fld/fld_internal.h
38 * Author: Yury Umanets <umka@clusterfs.com>
39 * Author: Tom WangDi <wangdi@clusterfs.com>
41 #ifndef __FLD_INTERNAL_H
42 #define __FLD_INTERNAL_H
44 #include <lustre/lustre_idl.h>
45 #include <dt_object.h>
47 #include <libcfs/libcfs.h>
48 #include <lustre_req_layout.h>
49 #include <lustre_fld.h>
52 LUSTRE_FLD_INIT = 1 << 0,
53 LUSTRE_FLD_RUN = 1 << 1
62 typedef int (*fld_hash_func_t) (struct lu_client_fld *, __u64);
64 typedef struct lu_fld_target *
65 (*fld_scan_func_t) (struct lu_client_fld *, __u64);
69 fld_hash_func_t fh_hash_func;
70 fld_scan_func_t fh_scan_func;
73 struct fld_cache_entry {
77 * fld cache entries are sorted on range->lsr_start field. */
78 struct lu_seq_range fce_range;
83 * Cache guard, protects fci_hash mostly because others immutable after
86 cfs_spinlock_t fci_lock;
89 * Cache shrink threshold */
93 * Prefered number of cached entries */
97 * Current number of cached entries. Protected by \a fci_lock */
101 * LRU list fld entries. */
105 * sorted fld entries. */
106 cfs_list_t fci_entries_head;
109 * Cache statistics. */
110 struct fld_stats fci_stat;
113 * Cache name used for debug and messages. */
124 /* 4M of FLD cache will not hurt client a lot. */
125 FLD_SERVER_CACHE_SIZE = (4 * 0x100000),
127 /* 1M of FLD cache will not hurt client a lot. */
128 FLD_CLIENT_CACHE_SIZE = (1 * 0x100000)
132 /* Cache threshold is 10 percent of size. */
133 FLD_SERVER_CACHE_THRESHOLD = 10,
135 /* Cache threshold is 10 percent of size. */
136 FLD_CLIENT_CACHE_THRESHOLD = 10
139 extern struct lu_fld_hash fld_hash[];
143 struct fld_thread_info {
144 struct req_capsule *fti_pill;
146 struct lu_seq_range fti_rec;
147 struct lu_seq_range fti_lrange;
148 struct lu_seq_range fti_irange;
152 struct thandle *fld_trans_create(struct lu_server_fld *fld,
153 const struct lu_env *env);
154 int fld_trans_start(struct lu_server_fld *fld,
155 const struct lu_env *env, struct thandle *th);
157 void fld_trans_stop(struct lu_server_fld *fld,
158 const struct lu_env *env, struct thandle* th);
160 int fld_index_init(struct lu_server_fld *fld,
161 const struct lu_env *env,
162 struct dt_device *dt);
164 void fld_index_fini(struct lu_server_fld *fld,
165 const struct lu_env *env);
167 int fld_index_create(struct lu_server_fld *fld,
168 const struct lu_env *env,
169 const struct lu_seq_range *range,
172 int fld_index_delete(struct lu_server_fld *fld,
173 const struct lu_env *env,
174 struct lu_seq_range *range,
177 int fld_index_lookup(struct lu_server_fld *fld,
178 const struct lu_env *env,
179 seqno_t seq, struct lu_seq_range *range);
181 int fld_client_rpc(struct obd_export *exp,
182 struct lu_seq_range *range, __u32 fld_op);
185 extern struct lprocfs_vars fld_server_proc_list[];
186 extern struct lprocfs_vars fld_client_proc_list[];
191 struct fld_cache *fld_cache_init(const char *name,
192 int cache_size, int cache_threshold);
194 void fld_cache_fini(struct fld_cache *cache);
196 void fld_cache_flush(struct fld_cache *cache);
198 void fld_cache_insert(struct fld_cache *cache,
199 const struct lu_seq_range *range);
201 void fld_cache_delete(struct fld_cache *cache,
202 const struct lu_seq_range *range);
204 int fld_cache_lookup(struct fld_cache *cache,
205 const seqno_t seq, struct lu_seq_range *range);
207 static inline const char *
208 fld_target_name(struct lu_fld_target *tar)
210 if (tar->ft_srv != NULL)
211 return tar->ft_srv->lsf_name;
213 return (const char *)tar->ft_exp->exp_obd->obd_name;
216 extern cfs_proc_dir_entry_t *fld_type_proc_dir;
218 #endif /* __FLD_INTERNAL_H */