Whamcloud - gitweb
Land b_head_libcfs onto HEAD (20080805_1611)
[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 <lustre_req_layout.h>
50 #include <lustre_fld.h>
51
52 enum fld_op {
53         FLD_CREATE = 0,
54         FLD_DELETE = 1,
55         FLD_LOOKUP = 2
56 };
57
58 enum {
59         /* 4M of FLD cache will not hurt client a lot. */
60         FLD_SERVER_CACHE_SIZE      = (4 * 0x100000),
61
62         /* 1M of FLD cache will not hurt client a lot. */
63         FLD_CLIENT_CACHE_SIZE      = (1 * 0x100000)
64 };
65
66 enum {
67         /* Cache threshold is 10 percent of size. */
68         FLD_SERVER_CACHE_THRESHOLD = 10,
69
70         /* Cache threshold is 10 percent of size. */
71         FLD_CLIENT_CACHE_THRESHOLD = 10
72 };
73
74 enum {
75         /*
76          * One page is used for hashtable. That is sizeof(struct hlist_head) *
77          * 1024.
78          */
79         FLD_CLIENT_HTABLE_SIZE     = (1024 * 1),
80
81         /* 
82          * Here 4 pages are used for hashtable of server cache. This is is
83          * because cache it self is 4 times bugger.
84          */
85         FLD_SERVER_HTABLE_SIZE     = (1024 * 4)
86 };
87
88 extern struct lu_fld_hash fld_hash[];
89
90 #ifdef __KERNEL__
91 struct fld_thread_info {
92         struct req_capsule *fti_pill;
93         __u64               fti_key;
94         __u64               fti_rec;
95         __u32               fti_flags;
96 };
97
98 int fld_index_init(struct lu_server_fld *fld,
99                    const struct lu_env *env,
100                    struct dt_device *dt);
101
102 void fld_index_fini(struct lu_server_fld *fld,
103                     const struct lu_env *env);
104
105 int fld_index_create(struct lu_server_fld *fld,
106                      const struct lu_env *env,
107                      seqno_t seq, mdsno_t mds);
108
109 int fld_index_delete(struct lu_server_fld *fld,
110                      const struct lu_env *env,
111                      seqno_t seq);
112
113 int fld_index_lookup(struct lu_server_fld *fld,
114                      const struct lu_env *env,
115                      seqno_t seq, mdsno_t *mds);
116
117 #ifdef LPROCFS
118 extern struct lprocfs_vars fld_server_proc_list[];
119 extern struct lprocfs_vars fld_client_proc_list[];
120 #endif
121
122 #endif
123
124 static inline const char *
125 fld_target_name(struct lu_fld_target *tar)
126 {
127         if (tar->ft_srv != NULL)
128                 return tar->ft_srv->lsf_name;
129
130         return (const char *)tar->ft_exp->exp_obd->obd_name;
131 }
132
133 extern cfs_proc_dir_entry_t *fld_type_proc_dir;
134
135 #endif /* __FLD_INTERNAL_H */