Whamcloud - gitweb
- make HEAD from b_post_cmd3
[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  *  fld/fld_internal.h
5  *
6  *  Copyright (C) 2006 Cluster File Systems, Inc.
7  *   Author: Yury Umanets <umka@clusterfs.com>
8  *           Tom WangDi <wangdi@clusterfs.com>
9  *
10  *   This file is part of the Lustre file system, http://www.lustre.org
11  *   Lustre is a trademark of Cluster File Systems, Inc.
12  *
13  *   You may have signed or agreed to another license before downloading
14  *   this software.  If so, you are bound by the terms and conditions
15  *   of that agreement, and the following does not apply to you.  See the
16  *   LICENSE file included with this distribution for more information.
17  *
18  *   If you did not agree to a different license, then this copy of Lustre
19  *   is open source software; you can redistribute it and/or modify it
20  *   under the terms of version 2 of the GNU General Public License as
21  *   published by the Free Software Foundation.
22  *
23  *   In either case, Lustre is distributed in the hope that it will be
24  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
25  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  *   license text for more details.
27  */
28 #ifndef __FLD_INTERNAL_H
29 #define __FLD_INTERNAL_H
30
31 #include <lustre/lustre_idl.h>
32 #include <dt_object.h>
33
34 #include <libcfs/list.h>
35 #include <libcfs/kp30.h>
36
37 #include <linux/types.h>
38 #include <lustre_req_layout.h>
39 #include <lustre_fld.h>
40
41 enum fld_op {
42         FLD_CREATE = 0,
43         FLD_DELETE = 1,
44         FLD_LOOKUP = 2
45 };
46
47 enum {
48         /* 4M of FLD cache will not hurt client a lot. */
49         FLD_SERVER_CACHE_SIZE      = (4 * 0x100000),
50
51         /* 1M of FLD cache will not hurt client a lot. */
52         FLD_CLIENT_CACHE_SIZE      = (1 * 0x100000)
53 };
54
55 enum {
56         /* Cache threshold is 10 percent of size. */
57         FLD_SERVER_CACHE_THRESHOLD = 10,
58
59         /* Cache threshold is 10 percent of size. */
60         FLD_CLIENT_CACHE_THRESHOLD = 10
61 };
62
63 enum {
64         /*
65          * One page is used for hashtable. That is sizeof(struct hlist_head) *
66          * 1024.
67          */
68         FLD_CLIENT_HTABLE_SIZE     = (1024 * 1),
69
70         /* 
71          * Here 4 pages are used for hashtable of server cache. This is is
72          * because cache it self is 4 times bugger.
73          */
74         FLD_SERVER_HTABLE_SIZE     = (1024 * 4)
75 };
76
77 extern struct lu_fld_hash fld_hash[];
78
79 #ifdef __KERNEL__
80 struct fld_thread_info {
81         struct req_capsule fti_pill;
82         int                fti_rep_buf_size[REQ_MAX_FIELD_NR];
83         __u64              fti_key;
84         __u64              fti_rec;
85         __u32              fti_flags;
86 };
87
88 int fld_index_init(struct lu_server_fld *fld,
89                    const struct lu_env *env,
90                    struct dt_device *dt);
91
92 void fld_index_fini(struct lu_server_fld *fld,
93                     const struct lu_env *env);
94
95 int fld_index_create(struct lu_server_fld *fld,
96                      const struct lu_env *env,
97                      seqno_t seq, mdsno_t mds);
98
99 int fld_index_delete(struct lu_server_fld *fld,
100                      const struct lu_env *env,
101                      seqno_t seq);
102
103 int fld_index_lookup(struct lu_server_fld *fld,
104                      const struct lu_env *env,
105                      seqno_t seq, mdsno_t *mds);
106
107 #ifdef LPROCFS
108 extern struct lprocfs_vars fld_server_proc_list[];
109 extern struct lprocfs_vars fld_client_proc_list[];
110 #endif
111
112 #endif
113
114 static inline const char *
115 fld_target_name(struct lu_fld_target *tar)
116 {
117         if (tar->ft_srv != NULL)
118                 return tar->ft_srv->lsf_name;
119
120         return (const char *)tar->ft_exp->exp_obd->obd_name;
121 }
122
123 extern cfs_proc_dir_entry_t *fld_type_proc_dir;
124
125 #endif /* __FLD_INTERNAL_H */