Whamcloud - gitweb
c6784c570c75c7df82eb21c76d7eea1c74768555
[fs/lustre-release.git] / lustre / include / lustre_fld.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
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.
9  *
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).
15  *
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
19  *
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
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2011, 2013, Intel Corporation.
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         struct mutex            lsf_lock;
96
97         /**
98          * Fld service name in form "fld-srv-lustre-MDTXXX" */
99         char                     lsf_name[80];
100
101 };
102
103 struct lu_client_fld {
104         /**
105          * Client side proc entry. */
106         cfs_proc_dir_entry_t    *lcf_proc_dir;
107
108         /**
109          * List of exports client FLD knows about. */
110         cfs_list_t               lcf_targets;
111
112         /**
113          * Current hash to be used to chose an export. */
114         struct lu_fld_hash      *lcf_hash;
115
116         /**
117          * Exports count. */
118         int                      lcf_count;
119
120         /**
121          * Lock protecting exports list and fld_hash. */
122         spinlock_t               lcf_lock;
123
124         /**
125          * Client FLD cache. */
126         struct fld_cache        *lcf_cache;
127
128         /**
129          * Client fld proc entry name. */
130         char                     lcf_name[80];
131
132         const struct lu_context *lcf_ctx;
133
134         int                      lcf_flags;
135 };
136
137 /**
138  * number of blocks to reserve for particular operations. Should be function of
139  * ... something. Stub for now.
140  */
141 enum {
142         /* one insert operation can involve two delete and one insert */
143         FLD_TXN_INDEX_INSERT_CREDITS  = 60,
144         FLD_TXN_INDEX_DELETE_CREDITS  = 20,
145 };
146
147 int fld_query(struct com_thread_info *info);
148
149 /* Server methods */
150 int fld_server_init(const struct lu_env *env, struct lu_server_fld *fld,
151                     struct dt_device *dt, const char *prefix, int mds_node_id,
152                     int type);
153
154 void fld_server_fini(const struct lu_env *env, struct lu_server_fld *fld);
155
156 int fld_declare_server_create(const struct lu_env *env,
157                               struct lu_server_fld *fld,
158                               struct lu_seq_range *new,
159                               struct thandle *th);
160
161 int fld_server_create(const struct lu_env *env,
162                       struct lu_server_fld *fld,
163                       struct lu_seq_range *add_range,
164                       struct thandle *th);
165
166 int fld_insert_entry(const struct lu_env *env,
167                      struct lu_server_fld *fld,
168                      const struct lu_seq_range *range);
169
170 int fld_server_lookup(const struct lu_env *env, struct lu_server_fld *fld,
171                       seqno_t seq, struct lu_seq_range *range);
172
173 /* Client methods */
174 int fld_client_init(struct lu_client_fld *fld,
175                     const char *prefix, int hash);
176
177 void fld_client_fini(struct lu_client_fld *fld);
178
179 void fld_client_flush(struct lu_client_fld *fld);
180
181 int fld_client_lookup(struct lu_client_fld *fld, seqno_t seq, mdsno_t *mds,
182                       __u32 flags, const struct lu_env *env);
183
184 int fld_client_create(struct lu_client_fld *fld,
185                       struct lu_seq_range *range,
186                       const struct lu_env *env);
187
188 int fld_client_delete(struct lu_client_fld *fld,
189                       seqno_t seq,
190                       const struct lu_env *env);
191
192 int fld_client_add_target(struct lu_client_fld *fld,
193                           struct lu_fld_target *tar);
194
195 int fld_client_del_target(struct lu_client_fld *fld,
196                           __u64 idx);
197
198 void fld_client_proc_fini(struct lu_client_fld *fld);
199
200 /** @} fld */
201
202 #endif