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.
40 #include <lustre/lustre_idl.h>
41 #include <lustre_mdt.h>
42 #include <dt_object.h>
44 #include <libcfs/libcfs.h>
49 extern const struct dt_index_features fld_index_features;
50 extern const char fld_index_name[];
60 * FLD (Fid Location Database) interface.
63 LUSTRE_CLI_FLD_HASH_DHT = 0,
64 LUSTRE_CLI_FLD_HASH_RRB
69 struct lu_fld_target {
70 struct list_head ft_chain;
71 struct obd_export *ft_exp;
72 struct lu_server_fld *ft_srv;
77 (*fld_hash_func_t) (struct lu_client_fld *, __u64);
79 typedef struct lu_fld_target *
80 (*fld_scan_func_t) (struct lu_client_fld *, __u64);
84 fld_hash_func_t fh_hash_func;
85 fld_scan_func_t fh_scan_func;
88 struct fld_cache_entry {
89 struct hlist_node fce_list;
90 struct list_head fce_lru;
93 cfs_waitq_t fce_waitq;
100 * Cache guard, protects fci_hash mostly because others immutable after
105 /* Cache shrink threshold */
108 /* Prefered number of cached entries */
111 /* Current number of cached entries. Protected by @fci_lock */
114 /* Hash table size (number of collision lists) */
117 /* Hash table mask */
120 /* Hash table for all collision lists */
121 struct hlist_head *fci_hash_table;
124 struct list_head fci_lru;
126 /* Cache statistics. */
127 struct fld_stats fci_stat;
129 /* Cache name used for debug and messages. */
133 struct lu_server_fld {
134 /* Fld dir proc entry. */
135 cfs_proc_dir_entry_t *lsf_proc_dir;
137 /* /fld file object device */
138 struct dt_object *lsf_obj;
140 /* Client FLD cache. */
141 struct fld_cache *lsf_cache;
143 /* Protect index modifications */
144 struct semaphore lsf_sem;
146 /* Fld service name in form "fld-srv-lustre-MDTXXX" */
151 LUSTRE_FLD_INIT = 1 << 0,
152 LUSTRE_FLD_RUN = 1 << 1
155 struct lu_client_fld {
156 /* Client side proc entry. */
157 cfs_proc_dir_entry_t *lcf_proc_dir;
159 /* List of exports client FLD knows about. */
160 struct list_head lcf_targets;
162 /* Current hash to be used to chose an export. */
163 struct lu_fld_hash *lcf_hash;
168 /* Lock protecting exports list and fld_hash. */
171 /* Client FLD cache. */
172 struct fld_cache *lcf_cache;
174 /* Client fld proc entry name. */
177 const struct lu_context *lcf_ctx;
182 int fld_query(struct com_thread_info *info);
185 int fld_server_init(struct lu_server_fld *fld,
186 struct dt_device *dt,
188 const struct lu_env *env);
190 void fld_server_fini(struct lu_server_fld *fld,
191 const struct lu_env *env);
193 int fld_server_create(struct lu_server_fld *fld,
194 const struct lu_env *env,
195 seqno_t seq, mdsno_t mds);
197 int fld_server_delete(struct lu_server_fld *fld,
198 const struct lu_env *env,
201 int fld_server_lookup(struct lu_server_fld *fld,
202 const struct lu_env *env,
203 seqno_t seq, mdsno_t *mds);
206 int fld_client_init(struct lu_client_fld *fld,
207 const char *prefix, int hash);
209 void fld_client_fini(struct lu_client_fld *fld);
211 void fld_client_flush(struct lu_client_fld *fld);
213 int fld_client_lookup(struct lu_client_fld *fld,
214 seqno_t seq, mdsno_t *mds,
215 const struct lu_env *env);
217 int fld_client_create(struct lu_client_fld *fld,
218 seqno_t seq, mdsno_t mds,
219 const struct lu_env *env);
221 int fld_client_delete(struct lu_client_fld *fld,
223 const struct lu_env *env);
225 int fld_client_add_target(struct lu_client_fld *fld,
226 struct lu_fld_target *tar);
228 int fld_client_del_target(struct lu_client_fld *fld,
232 struct fld_cache *fld_cache_init(const char *name,
235 int cache_threshold);
237 void fld_cache_fini(struct fld_cache *cache);
239 void fld_cache_flush(struct fld_cache *cache);
241 int fld_cache_insert(struct fld_cache *cache,
242 seqno_t seq, mdsno_t mds);
244 int fld_cache_insert_inflight(struct fld_cache *cache,
247 void fld_cache_delete(struct fld_cache *cache,
251 fld_cache_lookup(struct fld_cache *cache,
252 seqno_t seq, mdsno_t *mds);