Whamcloud - gitweb
b=21571 stacksize and locking fixes for loadgen patch from umka
[fs/lustre-release.git] / lustre / include / lustre_fld.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
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.
11  *
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).
17  *
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
21  *
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
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #ifndef __LINUX_FLD_H
38 #define __LINUX_FLD_H
39
40 #include <lustre/lustre_idl.h>
41 #include <lustre_mdt.h>
42 #include <dt_object.h>
43
44 #include <libcfs/libcfs.h>
45
46 struct lu_client_fld;
47 struct lu_server_fld;
48 struct lu_fld_hash;
49 struct fld_cache;
50
51 extern const struct dt_index_features fld_index_features;
52 extern const char fld_index_name[];
53
54 /*
55  * FLD (Fid Location Database) interface.
56  */
57 enum {
58         LUSTRE_CLI_FLD_HASH_DHT = 0,
59         LUSTRE_CLI_FLD_HASH_RRB
60 };
61
62
63 struct lu_fld_target {
64         struct list_head         ft_chain;
65         struct obd_export       *ft_exp;
66         struct lu_server_fld    *ft_srv;
67         __u64                    ft_idx;
68 };
69
70 struct lu_server_fld {
71         /**
72          * Fld dir proc entry. */
73         cfs_proc_dir_entry_t    *lsf_proc_dir;
74
75         /**
76          * /fld file object device */
77         struct dt_object        *lsf_obj;
78
79         /**
80          * super sequence controller export, needed to forward fld
81          * lookup  request. */
82         struct obd_export       *lsf_control_exp;
83
84         /**
85          * Client FLD cache. */
86         struct fld_cache        *lsf_cache;
87
88         /**
89          * Protect index modifications */
90         struct mutex            lsf_lock;
91
92         /**
93          * Fld service name in form "fld-srv-lustre-MDTXXX" */
94         char                     lsf_name[80];
95 };
96
97 struct lu_client_fld {
98         /**
99          * Client side proc entry. */
100         cfs_proc_dir_entry_t    *lcf_proc_dir;
101
102         /**
103          * List of exports client FLD knows about. */
104         struct list_head         lcf_targets;
105
106         /**
107          * Current hash to be used to chose an export. */
108         struct lu_fld_hash      *lcf_hash;
109
110         /**
111          * Exports count. */
112         int                      lcf_count;
113
114         /**
115          * Lock protecting exports list and fld_hash. */
116         spinlock_t               lcf_lock;
117
118         /**
119          * Client FLD cache. */
120         struct fld_cache        *lcf_cache;
121
122         /**
123          * Client fld proc entry name. */
124         char                     lcf_name[80];
125
126         const struct lu_context *lcf_ctx;
127
128         int                      lcf_flags;
129 };
130
131 /**
132  * number of blocks to reserve for particular operations. Should be function of
133  * ... something. Stub for now.
134  */
135 enum {
136         /* one insert operation can involve two delete and one insert */
137         FLD_TXN_INDEX_INSERT_CREDITS  = 60,
138         FLD_TXN_INDEX_DELETE_CREDITS  = 20,
139 };
140
141 int fld_query(struct com_thread_info *info);
142
143 /* Server methods */
144 int fld_server_init(struct lu_server_fld *fld,
145                     struct dt_device *dt,
146                     const char *prefix,
147                     const struct lu_env *env,
148                     int mds_node_id);
149
150 void fld_server_fini(struct lu_server_fld *fld,
151                      const struct lu_env *env);
152
153 int fld_server_create(struct lu_server_fld *fld,
154                       const struct lu_env *env,
155                       struct lu_seq_range *add_range,
156                       struct thandle *th);
157
158 int fld_server_delete(struct lu_server_fld *fld,
159                       const struct lu_env *env,
160                       struct lu_seq_range *range);
161
162 int fld_server_lookup(struct lu_server_fld *fld,
163                       const struct lu_env *env,
164                       seqno_t seq, struct lu_seq_range *range);
165
166 /* Client methods */
167 int fld_client_init(struct lu_client_fld *fld,
168                     const char *prefix, int hash);
169
170 void fld_client_fini(struct lu_client_fld *fld);
171
172 void fld_client_flush(struct lu_client_fld *fld);
173
174 int fld_client_lookup(struct lu_client_fld *fld,
175                       seqno_t seq, mdsno_t *mds,
176                       const struct lu_env *env);
177
178 int fld_client_create(struct lu_client_fld *fld,
179                       struct lu_seq_range *range,
180                       const struct lu_env *env);
181
182 int fld_client_delete(struct lu_client_fld *fld,
183                       seqno_t seq,
184                       const struct lu_env *env);
185
186 int fld_client_add_target(struct lu_client_fld *fld,
187                           struct lu_fld_target *tar);
188
189 int fld_client_del_target(struct lu_client_fld *fld,
190                           __u64 idx);
191
192 #endif