Whamcloud - gitweb
LU-6401 headers: move seq_range.h to correct directory
[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, 2015, 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 <libcfs/libcfs.h>
47 #include <seq_range.h>
48
49 struct lu_env;
50 struct lu_client_fld;
51 struct lu_server_fld;
52 struct lu_fld_hash;
53 struct fld_cache;
54 struct thandle;
55 struct dt_device;
56 struct dt_object;
57
58 /*
59  * FLD (Fid Location Database) interface.
60  */
61 enum {
62         LUSTRE_CLI_FLD_HASH_DHT = 0,
63         LUSTRE_CLI_FLD_HASH_RRB
64 };
65
66 struct lu_fld_target {
67         struct list_head        ft_chain;
68         struct obd_export      *ft_exp;
69         struct lu_server_fld   *ft_srv;
70         __u64                   ft_idx;
71 };
72
73 struct lu_server_fld {
74         /**
75          * Fld dir proc entry. */
76         struct proc_dir_entry   *lsf_proc_dir;
77
78         /**
79          * /fld file object device */
80         struct dt_object        *lsf_obj;
81
82         /**
83          * super sequence controller export, needed to forward fld
84          * lookup  request. */
85         struct obd_export       *lsf_control_exp;
86
87         /**
88          * Client FLD cache. */
89         struct fld_cache        *lsf_cache;
90
91         /**
92          * Protect index modifications */
93         struct mutex            lsf_lock;
94
95         /**
96          * Fld service name in form "fld-srv-lustre-MDTXXX" */
97         char                     lsf_name[80];
98
99         int (*lsf_seq_lookup)(const struct lu_env *env,
100                               struct lu_server_fld *fld, u64 seq,
101                               struct lu_seq_range *range);
102
103         /**
104          * Just reformatted or upgraded, and this flag is being
105          * used to check whether the local FLDB is needs to be
106          * synced with global FLDB(in MDT0), and it is only needed
107          * if the MDT is upgraded from < 2.6 to 2.6, i.e. when the
108          * local FLDB is being invited */
109         unsigned int             lsf_new:1;
110
111 };
112
113 struct lu_client_fld {
114         /**
115          * Client side proc entry. */
116         struct proc_dir_entry   *lcf_proc_dir;
117
118         /**
119          * List of exports client FLD knows about. */
120         struct list_head        lcf_targets;
121
122         /**
123          * Current hash to be used to chose an export. */
124         struct lu_fld_hash      *lcf_hash;
125
126         /**
127          * Exports count. */
128         int                      lcf_count;
129
130         /**
131          * Lock protecting exports list and fld_hash. */
132         spinlock_t               lcf_lock;
133
134         /**
135          * Client FLD cache. */
136         struct fld_cache        *lcf_cache;
137
138         /**
139          * Client fld proc entry name. */
140         char                     lcf_name[80];
141 };
142
143 /* Server methods */
144 int fld_server_init(const struct lu_env *env, struct lu_server_fld *fld,
145                     struct dt_device *dt, const char *prefix, int type);
146
147 void fld_server_fini(const struct lu_env *env, struct lu_server_fld *fld);
148
149 int fld_declare_server_create(const struct lu_env *env,
150                               struct lu_server_fld *fld,
151                               const struct lu_seq_range *range,
152                               struct thandle *th);
153
154 int fld_server_create(const struct lu_env *env,
155                       struct lu_server_fld *fld,
156                       const struct lu_seq_range *add_range,
157                       struct thandle *th);
158
159 int fld_insert_entry(const struct lu_env *env,
160                      struct lu_server_fld *fld,
161                      const struct lu_seq_range *range);
162
163 int fld_server_lookup(const struct lu_env *env, struct lu_server_fld *fld,
164                       u64 seq, struct lu_seq_range *range);
165
166 int fld_local_lookup(const struct lu_env *env, struct lu_server_fld *fld,
167                      u64 seq, struct lu_seq_range *range);
168
169 int fld_update_from_controller(const struct lu_env *env,
170                                struct lu_server_fld *fld);
171
172 /* Client methods */
173 int fld_client_init(struct lu_client_fld *fld,
174                     const char *prefix, int hash);
175
176 void fld_client_fini(struct lu_client_fld *fld);
177
178 void fld_client_flush(struct lu_client_fld *fld);
179
180 int fld_client_lookup(struct lu_client_fld *fld, u64 seq, u32 *mds,
181                       __u32 flags, 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, u64 seq,
188                       const struct lu_env *env);
189
190 int fld_client_add_target(struct lu_client_fld *fld,
191                           struct lu_fld_target *tar);
192
193 int fld_client_del_target(struct lu_client_fld *fld,
194                           __u64 idx);
195
196 void fld_client_proc_fini(struct lu_client_fld *fld);
197
198 /** @} fld */
199
200 #endif