Whamcloud - gitweb
- cleanups and small fixes accordingly to Nikita's DLDINSP.
[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  *  Copyright (C) 2006 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  */
22
23 #ifndef __LINUX_FLD_H
24 #define __LINUX_FLD_H
25
26 struct lu_client_fld;
27 struct lu_server_fld;
28
29 /*
30  * FLD (Fid Location Database) interface.
31  */
32 enum {
33         LUSTRE_CLI_FLD_HASH_DHT = 0,
34         LUSTRE_CLI_FLD_HASH_RRB
35 };
36
37 typedef int (*fld_hash_func_t) (struct lu_client_fld *, __u64);
38
39 struct lu_fld_hash {
40         const char              *fh_name;
41         fld_hash_func_t          fh_func;
42 };
43
44 struct lu_server_fld {
45         /* service proc entry */
46         cfs_proc_dir_entry_t    *fld_proc_entry;
47
48         /* fld dir proc entry */
49         cfs_proc_dir_entry_t    *fld_proc_dir;
50
51         /* pointer to started server service */
52         struct ptlrpc_service   *fld_service;
53
54         /* device for access object index methods */
55         struct dt_device        *fld_dt;
56
57         /* /fld file object device */
58         struct dt_object        *fld_obj;
59
60         /* /fld file fid */
61         struct lu_fid            fld_fid;
62
63         /* fld service name in form "fld-MDTXXX" */
64         char                     fld_name[80];
65 };
66
67 struct fld_cache_entry {
68         struct hlist_node        fce_list;
69         mdsno_t                  fce_mds;
70         seqno_t                  fce_seq;
71 };
72
73 struct fld_cache_info {
74         struct hlist_head       *fci_hash;
75         spinlock_t               fci_lock;
76         int                      fci_size;
77         int                      fci_hash_mask;
78 };
79
80 struct lu_client_fld {
81         /* client side proc entry */
82         cfs_proc_dir_entry_t    *fld_proc_dir;
83
84         /* list of exports client FLD knows about */
85         struct list_head         fld_targets;
86
87         /* current hash to be used to chose an export */
88         struct lu_fld_hash      *fld_hash;
89
90         /* exports count */
91         int                      fld_count;
92
93         /* lock protecting exports list and fld_hash */
94         spinlock_t               fld_lock;
95
96         /* client FLD cache */
97         struct fld_cache_info   *fld_cache;
98
99         /* client fld proc entry name */
100         char                     fld_name[80];
101 };
102
103 /* server methods */
104 int fld_server_init(struct lu_server_fld *fld,
105                     const struct lu_context *ctx,
106                     struct dt_device *dt,
107                     const char *uuid);
108
109 void fld_server_fini(struct lu_server_fld *fld,
110                      const struct lu_context *ctx);
111
112 int fld_server_lookup(struct lu_server_fld *fld,
113                       const struct lu_context *ctx,
114                       seqno_t seq, mdsno_t *mds);
115         
116 int fld_server_create(struct lu_server_fld *fld,
117                       const struct lu_context *ctx,
118                       seqno_t seq, mdsno_t mds);
119
120 int fld_server_delete(struct lu_server_fld *fld,
121                       const struct lu_context *ctx,
122                       seqno_t seq);
123
124 /* client methods */
125 int fld_client_init(struct lu_client_fld *fld,
126                     const char *uuid,
127                     int hash);
128
129 void fld_client_fini(struct lu_client_fld *fld);
130
131 int fld_client_lookup(struct lu_client_fld *fld,
132                       seqno_t seq, mdsno_t *mds);
133
134 int fld_client_create(struct lu_client_fld *fld,
135                       seqno_t seq, mdsno_t mds);
136
137 int fld_client_delete(struct lu_client_fld *fld,
138                       seqno_t seq);
139
140 int fld_client_add_target(struct lu_client_fld *fld,
141                           struct obd_export *exp);
142
143 int fld_client_del_target(struct lu_client_fld *fld,
144                           struct obd_export *exp);
145
146 /* cache methods */
147 struct fld_cache_info *fld_cache_init(int size);
148
149 void fld_cache_fini(struct fld_cache_info *cache);
150
151 int fld_cache_insert(struct fld_cache_info *cache,
152                      seqno_t seq, mdsno_t mds);
153
154 void fld_cache_delete(struct fld_cache_info *cache,
155                       seqno_t seq);
156
157 int
158 fld_cache_lookup(struct fld_cache_info *cache,
159                  seqno_t seq, mdsno_t *mds);
160
161 #endif