1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2006 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
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.
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.
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.
29 #include <lustre/lustre_idl.h>
31 #include <libcfs/list.h>
32 #include <libcfs/kp30.h>
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;
42 /* this is how may FIDs may be allocated in one sequence. 16384 for now */
43 LUSTRE_SEQ_MAX_WIDTH = 0x0000000000004000ULL,
45 /* how many sequences may be allocate for meta-sequence (this is 128
47 LUSTRE_SEQ_META_WIDTH = 0x0000000000000080ULL,
49 /* this is how many sequences (128 * 128) may be in one
50 * super-sequence allocated to MDTs. */
51 LUSTRE_SEQ_SUPER_WIDTH = (LUSTRE_SEQ_META_WIDTH * LUSTRE_SEQ_META_WIDTH)
64 /* client sequence manager interface */
65 struct lu_client_seq {
66 /* sequence-controller export. */
67 struct obd_export *lcs_exp;
68 struct semaphore lcs_sem;
70 /* range of allowed for allocation sequeces. When using lu_client_seq on
71 * clients, this contains meta-sequence range. And for servers this
72 * contains super-sequence range. */
73 struct lu_range lcs_range;
75 /* seq related proc */
76 cfs_proc_dir_entry_t *lcs_proc_dir;
78 /* this holds last allocated fid in last obtained seq */
79 struct lu_fid lcs_fid;
81 /* LUSTRE_SEQ_METADATA or LUSTRE_SEQ_DATA */
82 enum lu_cli_type lcs_type;
84 /* service uuid, passed from MDT + seq name to form unique seq name to
85 * use it with procfs. */
88 /* sequence width, that is how many objects may be allocated in one
89 * sequence. Default value for it is LUSTRE_SEQ_MAX_WIDTH. */
94 /* server sequence manager interface */
95 struct lu_server_seq {
96 /* available sequence space */
97 struct lu_range lss_space;
99 /* super-sequence range, all super-sequences for other servers are
100 * allocated from it. */
101 struct lu_range lss_super;
103 /* device for server side seq manager needs (saving sequences to backing
105 struct dt_device *lss_dev;
107 /* /seq file object device */
108 struct dt_object *lss_obj;
110 /* seq related proc */
111 cfs_proc_dir_entry_t *lss_proc_entry;
112 cfs_proc_dir_entry_t *lss_proc_dir;
114 /* LUSTRE_SEQ_SERVER or LUSTRE_SEQ_CONTROLLER */
115 enum lu_mgr_type lss_type;
117 /* server side seq service for metadata stack */
118 struct ptlrpc_service *lss_md_service;
120 /* server side seq service for data stack */
121 struct ptlrpc_service *lss_dt_service;
123 /* client interafce to request controller */
124 struct lu_client_seq *lss_cli;
126 /* semaphore for protecting allocation */
127 struct semaphore lss_sem;
129 /* service uuid, passed from MDT + seq name to form unique seq name to
130 * use it with procfs. */
133 /* allocation chunks for super and meta sequences. Default values are
134 * LUSTRE_SEQ_SUPER_WIDTH and LUSTRE_SEQ_META_WIDTH. */
135 __u64 lss_super_width;
136 __u64 lss_meta_width;
142 int seq_server_init(struct lu_server_seq *seq,
143 struct dt_device *dev,
145 enum lu_mgr_type type,
146 const struct lu_context *ctx);
148 void seq_server_fini(struct lu_server_seq *seq,
149 const struct lu_context *ctx);
151 int seq_server_set_cli(struct lu_server_seq *seq,
152 struct lu_client_seq *cli,
153 const struct lu_context *ctx);
156 int seq_client_init(struct lu_client_seq *seq,
158 struct obd_export *exp,
159 enum lu_cli_type type);
161 void seq_client_fini(struct lu_client_seq *seq);
163 int seq_client_alloc_super(struct lu_client_seq *seq);
164 int seq_client_alloc_meta(struct lu_client_seq *seq);
166 int seq_client_alloc_seq(struct lu_client_seq *seq,
168 int seq_client_alloc_fid(struct lu_client_seq *seq,
171 /* Fids common stuff */
172 int fid_is_local(struct lu_site *site, const struct lu_fid *fid);
173 void fid_to_le(struct lu_fid *dst, const struct lu_fid *src);
174 void fid_to_be(struct lu_fid *dst, const struct lu_fid *src);
176 /* Range common stuff */
177 void range_to_le(struct lu_range *dst, const struct lu_range *src);
178 void range_to_be(struct lu_range *dst, const struct lu_range *src);
180 #endif /* __LINUX_OBD_CLASS_H */