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>
56 * FLD (Fid Location Database) interface.
59 LUSTRE_CLI_FLD_HASH_DHT = 0,
60 LUSTRE_CLI_FLD_HASH_RRB
65 struct lu_fld_target {
66 struct list_head ft_chain;
67 struct obd_export *ft_exp;
68 struct lu_server_fld *ft_srv;
73 (*fld_hash_func_t) (struct lu_client_fld *, __u64);
75 typedef struct lu_fld_target *
76 (*fld_scan_func_t) (struct lu_client_fld *, __u64);
80 fld_hash_func_t fh_hash_func;
81 fld_scan_func_t fh_scan_func;
84 struct fld_cache_entry {
85 struct hlist_node fce_list;
86 struct list_head fce_lru;
89 cfs_waitq_t fce_waitq;
96 * Cache guard, protects fci_hash mostly because others immutable after
101 /* Cache shrink threshold */
104 /* Prefered number of cached entries */
107 /* Current number of cached entries. Protected by @fci_lock */
110 /* Hash table size (number of collision lists) */
113 /* Hash table mask */
116 /* Hash table for all collision lists */
117 struct hlist_head *fci_hash_table;
120 struct list_head fci_lru;
122 /* Cache statistics. */
123 struct fld_stats fci_stat;
125 /* Cache name used for debug and messages. */
129 struct lu_server_fld {
130 /* Fld dir proc entry. */
131 cfs_proc_dir_entry_t *lsf_proc_dir;
133 /* /fld file object device */
134 struct dt_object *lsf_obj;
136 /* Client FLD cache. */
137 struct fld_cache *lsf_cache;
139 /* Protect index modifications */
140 struct semaphore lsf_sem;
142 /* Fld service name in form "fld-srv-lustre-MDTXXX" */
147 LUSTRE_FLD_INIT = 1 << 0,
148 LUSTRE_FLD_RUN = 1 << 1
151 struct lu_client_fld {
152 /* Client side proc entry. */
153 cfs_proc_dir_entry_t *lcf_proc_dir;
155 /* List of exports client FLD knows about. */
156 struct list_head lcf_targets;
158 /* Current hash to be used to chose an export. */
159 struct lu_fld_hash *lcf_hash;
164 /* Lock protecting exports list and fld_hash. */
167 /* Client FLD cache. */
168 struct fld_cache *lcf_cache;
170 /* Client fld proc entry name. */
173 const struct lu_context *lcf_ctx;
178 int fld_query(struct com_thread_info *info);
181 int fld_server_init(struct lu_server_fld *fld,
182 struct dt_device *dt,
184 const struct lu_env *env);
186 void fld_server_fini(struct lu_server_fld *fld,
187 const struct lu_env *env);
189 int fld_server_create(struct lu_server_fld *fld,
190 const struct lu_env *env,
191 seqno_t seq, mdsno_t mds);
193 int fld_server_delete(struct lu_server_fld *fld,
194 const struct lu_env *env,
197 int fld_server_lookup(struct lu_server_fld *fld,
198 const struct lu_env *env,
199 seqno_t seq, mdsno_t *mds);
202 int fld_client_init(struct lu_client_fld *fld,
203 const char *prefix, int hash);
205 void fld_client_fini(struct lu_client_fld *fld);
207 void fld_client_flush(struct lu_client_fld *fld);
209 int fld_client_lookup(struct lu_client_fld *fld,
210 seqno_t seq, mdsno_t *mds,
211 const struct lu_env *env);
213 int fld_client_create(struct lu_client_fld *fld,
214 seqno_t seq, mdsno_t mds,
215 const struct lu_env *env);
217 int fld_client_delete(struct lu_client_fld *fld,
219 const struct lu_env *env);
221 int fld_client_add_target(struct lu_client_fld *fld,
222 struct lu_fld_target *tar);
224 int fld_client_del_target(struct lu_client_fld *fld,
228 struct fld_cache *fld_cache_init(const char *name,
231 int cache_threshold);
233 void fld_cache_fini(struct fld_cache *cache);
235 void fld_cache_flush(struct fld_cache *cache);
237 int fld_cache_insert(struct fld_cache *cache,
238 seqno_t seq, mdsno_t mds);
240 int fld_cache_insert_inflight(struct fld_cache *cache,
243 void fld_cache_delete(struct fld_cache *cache,
247 fld_cache_lookup(struct fld_cache *cache,
248 seqno_t seq, mdsno_t *mds);