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