Whamcloud - gitweb
- start seq mgr for data stack in separate portal;
[fs/lustre-release.git] / lustre / include / lustre_fid.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_FID_H
24 #define __LINUX_FID_H
25
26 /*
27  * struct lu_fid
28  */
29 #include <lustre/lustre_idl.h>
30
31 #include <libcfs/list.h>
32 #include <libcfs/kp30.h>
33
34 struct lu_site;
35 struct lu_context;
36
37 /* whole sequences space range and zero range definitions */
38 extern const struct lu_range LUSTRE_SEQ_SPACE_RANGE;
39 extern const struct lu_range LUSTRE_SEQ_ZERO_RANGE;
40
41 enum {
42         /* this is how may FIDs may be allocated in one sequence. */
43         LUSTRE_SEQ_MAX_WIDTH = 0x00000000000002800ULL,
44
45         /* how many sequences may be allocate for meta-sequence (this is 10240
46          * sequences). */
47         LUSTRE_SEQ_META_WIDTH = 0x00000000000002800ULL,
48
49         /* this is how many sequneces (10240 * 10240) may be in one
50          * super-sequence allocated to MDTs. */
51         LUSTRE_SEQ_SUPER_WIDTH = (LUSTRE_SEQ_META_WIDTH * LUSTRE_SEQ_META_WIDTH)
52 };
53         
54 enum lu_mgr_type {
55         LUSTRE_SEQ_SERVER,
56         LUSTRE_SEQ_CONTROLLER
57 };
58
59 /* client sequence manager interface */
60 struct lu_client_seq {
61         /* sequence-controller export. */
62         struct obd_export      *lcs_exp;
63         struct semaphore        lcs_sem;
64
65         /* range of allowed for allocation sequeces. When using lu_client_seq on
66          * clients, this contains meta-sequence range. And for servers this
67          * contains super-sequence range. */
68         struct lu_range         lcs_range;
69
70         /* seq related proc */
71         cfs_proc_dir_entry_t   *lcs_proc_dir;
72
73         /* this holds last allocated fid in last obtained seq */
74         struct lu_fid           lcs_fid;
75
76         /* service uuid, passed from MDT + seq name to form unique seq name to
77          * use it with procfs. */
78         char                    lcs_name[80];
79
80         /* sequence width, that is how many objects may be allocated in one
81          * sequence. Default value for it is LUSTRE_SEQ_MAX_WIDTH. */
82         __u64                   lcs_width;
83 };
84
85 #ifdef __KERNEL__
86 /* server sequence manager interface */
87 struct lu_server_seq {
88         /* available sequence space */
89         struct lu_range         lss_space;
90
91         /* super-sequence range, all super-sequences for other servers are
92          * allocated from it. */
93         struct lu_range         lss_super;
94
95         /* device for server side seq manager needs (saving sequences to backing
96          * store). */
97         struct dt_device       *lss_dev;
98
99         /* /seq file object device */
100         struct dt_object       *lss_obj;
101
102         /* seq related proc */
103         cfs_proc_dir_entry_t   *lss_proc_entry;
104         cfs_proc_dir_entry_t   *lss_proc_dir;
105
106         /* LUSTRE_SEQ_SERVER or LUSTRE_SEQ_CONTROLLER */
107         enum lu_mgr_type       lss_type;
108
109         /* server side seq service for metadata stack */
110         struct ptlrpc_service  *lss_md_service;
111
112         /* server side seq service for data stack */
113         struct ptlrpc_service  *lss_dt_service;
114
115         /* client interafce to request controller */
116         struct lu_client_seq   *lss_cli;
117
118         /* semaphore for protecting allocation */
119         struct semaphore        lss_sem;
120
121         /* service uuid, passed from MDT + seq name to form unique seq name to
122          * use it with procfs. */
123         char                    lss_name[80];
124
125         /* allocation chunks for super and meta sequences. Default values are
126          * LUSTRE_SEQ_SUPER_WIDTH and LUSTRE_SEQ_META_WIDTH. */
127         __u64                   lss_super_width;
128         __u64                   lss_meta_width;
129 };
130 #endif
131
132 #ifdef __KERNEL__
133
134 int seq_server_init(struct lu_server_seq *seq,
135                     struct dt_device *dev,
136                     const char *uuid,
137                     enum lu_mgr_type type,
138                     const struct lu_context *ctx);
139
140 void seq_server_fini(struct lu_server_seq *seq,
141                      const struct lu_context *ctx);
142
143 int seq_server_set_cli(struct lu_server_seq *seq,
144                        struct lu_client_seq *cli,
145                        const struct lu_context *ctx);
146 #endif
147
148 int seq_client_init(struct lu_client_seq *seq,
149                     const char *uuid,
150                     struct obd_export *exp);
151
152 void seq_client_fini(struct lu_client_seq *seq);
153
154 int seq_client_alloc_super(struct lu_client_seq *seq);
155 int seq_client_alloc_meta(struct lu_client_seq *seq);
156
157 int seq_client_alloc_seq(struct lu_client_seq *seq,
158                          seqno_t *seqnr);
159 int seq_client_alloc_fid(struct lu_client_seq *seq,
160                          struct lu_fid *fid);
161
162 /* Fids common stuff */
163 int fid_is_local(struct lu_site *site, const struct lu_fid *fid);
164 void fid_to_le(struct lu_fid *dst, const struct lu_fid *src);
165 void fid_to_be(struct lu_fid *dst, const struct lu_fid *src);
166
167 /* Range common stuff */
168 void range_to_le(struct lu_range *dst, const struct lu_range *src);
169 void range_to_be(struct lu_range *dst, const struct lu_range *src);
170
171 #endif /* __LINUX_OBD_CLASS_H */