Whamcloud - gitweb
4e7efb06b549f0046ddc5b1c415ba9820b757e31
[fs/lustre-release.git] / lustre / fld / fld_internal.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 [sun.com URL with a
20  * copy of GPLv2].
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  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/fld/fld_internal.h
37  *
38  * Author: Yury Umanets <umka@clusterfs.com>
39  * Author: Tom WangDi <wangdi@clusterfs.com>
40  */
41 #ifndef __FLD_INTERNAL_H
42 #define __FLD_INTERNAL_H
43
44 #include <lustre/lustre_idl.h>
45 #include <dt_object.h>
46
47 #include <libcfs/libcfs.h>
48
49 #include <linux/types.h>
50 #include <lustre_req_layout.h>
51 #include <lustre_fld.h>
52
53 enum fld_op {
54         FLD_CREATE = 0,
55         FLD_DELETE = 1,
56         FLD_LOOKUP = 2
57 };
58
59 enum {
60         /* 4M of FLD cache will not hurt client a lot. */
61         FLD_SERVER_CACHE_SIZE      = (4 * 0x100000),
62
63         /* 1M of FLD cache will not hurt client a lot. */
64         FLD_CLIENT_CACHE_SIZE      = (1 * 0x100000)
65 };
66
67 enum {
68         /* Cache threshold is 10 percent of size. */
69         FLD_SERVER_CACHE_THRESHOLD = 10,
70
71         /* Cache threshold is 10 percent of size. */
72         FLD_CLIENT_CACHE_THRESHOLD = 10
73 };
74
75 enum {
76         /*
77          * One page is used for hashtable. That is sizeof(struct hlist_head) *
78          * 1024.
79          */
80         FLD_CLIENT_HTABLE_SIZE     = (1024 * 1),
81
82         /* 
83          * Here 4 pages are used for hashtable of server cache. This is is
84          * because cache it self is 4 times bugger.
85          */
86         FLD_SERVER_HTABLE_SIZE     = (1024 * 4)
87 };
88
89 extern struct lu_fld_hash fld_hash[];
90
91 #ifdef __KERNEL__
92 struct fld_thread_info {
93         struct req_capsule *fti_pill;
94         __u64               fti_key;
95         __u64               fti_rec;
96         __u32               fti_flags;
97 };
98
99 int fld_index_init(struct lu_server_fld *fld,
100                    const struct lu_env *env,
101                    struct dt_device *dt);
102
103 void fld_index_fini(struct lu_server_fld *fld,
104                     const struct lu_env *env);
105
106 int fld_index_create(struct lu_server_fld *fld,
107                      const struct lu_env *env,
108                      seqno_t seq, mdsno_t mds);
109
110 int fld_index_delete(struct lu_server_fld *fld,
111                      const struct lu_env *env,
112                      seqno_t seq);
113
114 int fld_index_lookup(struct lu_server_fld *fld,
115                      const struct lu_env *env,
116                      seqno_t seq, mdsno_t *mds);
117
118 #ifdef LPROCFS
119 extern struct lprocfs_vars fld_server_proc_list[];
120 extern struct lprocfs_vars fld_client_proc_list[];
121 #endif
122
123 #endif
124
125 static inline const char *
126 fld_target_name(struct lu_fld_target *tar)
127 {
128         if (tar->ft_srv != NULL)
129                 return tar->ft_srv->lsf_name;
130
131         return (const char *)tar->ft_exp->exp_obd->obd_name;
132 }
133
134 extern cfs_proc_dir_entry_t *fld_type_proc_dir;
135
136 #endif /* __FLD_INTERNAL_H */