Whamcloud - gitweb
LU-819 utils: Fix lfs getstripe -M
[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  * Copyright (c) 2011 Whamcloud, Inc.
32  */
33 /*
34  * This file is part of Lustre, http://www.lustre.org/
35  * Lustre is a trademark of Sun Microsystems, Inc.
36  */
37
38 #ifndef __LINUX_FLD_H
39 #define __LINUX_FLD_H
40
41 /** \defgroup fld fld
42  *
43  * @{
44  */
45
46 #include <lustre/lustre_idl.h>
47 #include <lustre_mdt.h>
48 #include <dt_object.h>
49
50 #include <libcfs/libcfs.h>
51
52 struct lu_client_fld;
53 struct lu_server_fld;
54 struct lu_fld_hash;
55 struct fld_cache;
56
57 extern const struct dt_index_features fld_index_features;
58 extern const char fld_index_name[];
59
60 /*
61  * FLD (Fid Location Database) interface.
62  */
63 enum {
64         LUSTRE_CLI_FLD_HASH_DHT = 0,
65         LUSTRE_CLI_FLD_HASH_RRB
66 };
67
68
69 struct lu_fld_target {
70         cfs_list_t               ft_chain;
71         struct obd_export       *ft_exp;
72         struct lu_server_fld    *ft_srv;
73         __u64                    ft_idx;
74 };
75
76 struct lu_server_fld {
77         /**
78          * Fld dir proc entry. */
79         cfs_proc_dir_entry_t    *lsf_proc_dir;
80
81         /**
82          * /fld file object device */
83         struct dt_object        *lsf_obj;
84
85         /**
86          * super sequence controller export, needed to forward fld
87          * lookup  request. */
88         struct obd_export       *lsf_control_exp;
89
90         /**
91          * Client FLD cache. */
92         struct fld_cache        *lsf_cache;
93
94         /**
95          * Protect index modifications */
96         cfs_mutex_t              lsf_lock;
97
98         /**
99          * Fld service name in form "fld-srv-lustre-MDTXXX" */
100         char                     lsf_name[80];
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         cfs_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(struct lu_server_fld *fld,
151                     struct dt_device *dt,
152                     const char *prefix,
153                     const struct lu_env *env,
154                     int mds_node_id);
155
156 void fld_server_fini(struct lu_server_fld *fld,
157                      const struct lu_env *env);
158
159 int fld_declare_server_create(struct lu_server_fld *fld,
160                               const struct lu_env *env,
161                               struct thandle *th);
162
163 int fld_server_create(struct lu_server_fld *fld,
164                       const struct lu_env *env,
165                       struct lu_seq_range *add_range,
166                       struct thandle *th);
167
168 int fld_server_delete(struct lu_server_fld *fld,
169                       const struct lu_env *env,
170                       struct lu_seq_range *range);
171
172 int fld_server_lookup(struct lu_server_fld *fld,
173                       const struct lu_env *env,
174                       seqno_t seq, struct lu_seq_range *range);
175
176 /* Client methods */
177 int fld_client_init(struct lu_client_fld *fld,
178                     const char *prefix, int hash);
179
180 void fld_client_fini(struct lu_client_fld *fld);
181
182 void fld_client_flush(struct lu_client_fld *fld);
183
184 int fld_client_lookup(struct lu_client_fld *fld, seqno_t seq, mdsno_t *mds,
185                       __u32 flags, const struct lu_env *env);
186
187 int fld_client_create(struct lu_client_fld *fld,
188                       struct lu_seq_range *range,
189                       const struct lu_env *env);
190
191 int fld_client_delete(struct lu_client_fld *fld,
192                       seqno_t seq,
193                       const struct lu_env *env);
194
195 int fld_client_add_target(struct lu_client_fld *fld,
196                           struct lu_fld_target *tar);
197
198 int fld_client_del_target(struct lu_client_fld *fld,
199                           __u64 idx);
200
201 void fld_client_proc_fini(struct lu_client_fld *fld);
202
203 /** @} fld */
204
205 #endif