Whamcloud - gitweb
571ec4560c5bd6274dd656849e69297eff1f9bcd
[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 (c) 2007, 2010, Oracle and/or its affiliates. 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 /** \defgroup fld fld
41  *
42  * @{
43  */
44
45 #include <lustre/lustre_idl.h>
46 #include <lustre_mdt.h>
47 #include <dt_object.h>
48
49 #include <libcfs/libcfs.h>
50
51 struct lu_client_fld;
52 struct lu_server_fld;
53 struct lu_fld_hash;
54 struct fld_cache;
55
56 extern const struct dt_index_features fld_index_features;
57 extern const char fld_index_name[];
58
59 /*
60  * FLD (Fid Location Database) interface.
61  */
62 enum {
63         LUSTRE_CLI_FLD_HASH_DHT = 0,
64         LUSTRE_CLI_FLD_HASH_RRB
65 };
66
67
68 struct lu_fld_target {
69         cfs_list_t               ft_chain;
70         struct obd_export       *ft_exp;
71         struct lu_server_fld    *ft_srv;
72         __u64                    ft_idx;
73 };
74
75 struct lu_server_fld {
76         /**
77          * Fld dir proc entry. */
78         cfs_proc_dir_entry_t    *lsf_proc_dir;
79
80         /**
81          * /fld file object device */
82         struct dt_object        *lsf_obj;
83
84         /**
85          * super sequence controller export, needed to forward fld
86          * lookup  request. */
87         struct obd_export       *lsf_control_exp;
88
89         /**
90          * Client FLD cache. */
91         struct fld_cache        *lsf_cache;
92
93         /**
94          * Protect index modifications */
95         cfs_mutex_t              lsf_lock;
96
97         /**
98          * Fld service name in form "fld-srv-lustre-MDTXXX" */
99         char                     lsf_name[80];
100 };
101
102 struct lu_client_fld {
103         /**
104          * Client side proc entry. */
105         cfs_proc_dir_entry_t    *lcf_proc_dir;
106
107         /**
108          * List of exports client FLD knows about. */
109         cfs_list_t               lcf_targets;
110
111         /**
112          * Current hash to be used to chose an export. */
113         struct lu_fld_hash      *lcf_hash;
114
115         /**
116          * Exports count. */
117         int                      lcf_count;
118
119         /**
120          * Lock protecting exports list and fld_hash. */
121         cfs_spinlock_t           lcf_lock;
122
123         /**
124          * Client FLD cache. */
125         struct fld_cache        *lcf_cache;
126
127         /**
128          * Client fld proc entry name. */
129         char                     lcf_name[80];
130
131         const struct lu_context *lcf_ctx;
132
133         int                      lcf_flags;
134 };
135
136 /**
137  * number of blocks to reserve for particular operations. Should be function of
138  * ... something. Stub for now.
139  */
140 enum {
141         /* one insert operation can involve two delete and one insert */
142         FLD_TXN_INDEX_INSERT_CREDITS  = 60,
143         FLD_TXN_INDEX_DELETE_CREDITS  = 20,
144 };
145
146 int fld_query(struct com_thread_info *info);
147
148 /* Server methods */
149 int fld_server_init(struct lu_server_fld *fld,
150                     struct dt_device *dt,
151                     const char *prefix,
152                     const struct lu_env *env,
153                     int mds_node_id);
154
155 void fld_server_fini(struct lu_server_fld *fld,
156                      const struct lu_env *env);
157
158 int fld_server_create(struct lu_server_fld *fld,
159                       const struct lu_env *env,
160                       struct lu_seq_range *add_range,
161                       struct thandle *th);
162
163 int fld_server_delete(struct lu_server_fld *fld,
164                       const struct lu_env *env,
165                       struct lu_seq_range *range);
166
167 int fld_server_lookup(struct lu_server_fld *fld,
168                       const struct lu_env *env,
169                       seqno_t seq, struct lu_seq_range *range);
170
171 /* Client methods */
172 int fld_client_init(struct lu_client_fld *fld,
173                     const char *prefix, int hash);
174
175 void fld_client_fini(struct lu_client_fld *fld);
176
177 void fld_client_flush(struct lu_client_fld *fld);
178
179 int fld_client_lookup(struct lu_client_fld *fld,
180                       seqno_t seq, mdsno_t *mds,
181                       const struct lu_env *env);
182
183 int fld_client_create(struct lu_client_fld *fld,
184                       struct lu_seq_range *range,
185                       const struct lu_env *env);
186
187 int fld_client_delete(struct lu_client_fld *fld,
188                       seqno_t seq,
189                       const struct lu_env *env);
190
191 int fld_client_add_target(struct lu_client_fld *fld,
192                           struct lu_fld_target *tar);
193
194 int fld_client_del_target(struct lu_client_fld *fld,
195                           __u64 idx);
196
197 /** @} fld */
198
199 #endif