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. */
43 LUSTRE_SEQ_MAX_WIDTH = 0x00000000000002800ULL,
45 /* how many sequences may be allocate for meta-sequence (this is 10240
47 LUSTRE_SEQ_META_WIDTH = 0x00000000000002800ULL,
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)
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;
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;
70 /* seq related proc */
71 cfs_proc_dir_entry_t *lcs_proc_dir;
73 /* this holds last allocated fid in last obtained seq */
74 struct lu_fid lcs_fid;
76 /* service uuid, passed from MDT + seq name to form unique seq name to
77 * use it with procfs. */
80 /* sequence width, that is how many objects may be allocated in one
81 * sequence. Default value for it is LUSTRE_SEQ_MAX_WIDTH. */
86 /* server sequence manager interface */
87 struct lu_server_seq {
88 /* available sequence space */
89 struct lu_range lss_space;
91 /* super-sequence range, all super-sequences for other servers are
92 * allocated from it. */
93 struct lu_range lss_super;
95 /* device for server side seq manager needs (saving sequences to backing
97 struct dt_device *lss_dev;
99 /* /seq file object device */
100 struct dt_object *lss_obj;
102 /* seq related proc */
103 cfs_proc_dir_entry_t *lss_proc_entry;
104 cfs_proc_dir_entry_t *lss_proc_dir;
106 /* LUSTRE_SEQ_SERVER or LUSTRE_SEQ_CONTROLLER */
107 enum lu_mgr_type lss_type;
109 /* server side seq service for metadata stack */
110 struct ptlrpc_service *lss_md_service;
112 /* server side seq service for data stack */
113 struct ptlrpc_service *lss_dt_service;
115 /* client interafce to request controller */
116 struct lu_client_seq *lss_cli;
118 /* semaphore for protecting allocation */
119 struct semaphore lss_sem;
121 /* service uuid, passed from MDT + seq name to form unique seq name to
122 * use it with procfs. */
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;
134 int seq_server_init(struct lu_server_seq *seq,
135 struct dt_device *dev,
137 enum lu_mgr_type type,
138 const struct lu_context *ctx);
140 void seq_server_fini(struct lu_server_seq *seq,
141 const struct lu_context *ctx);
143 int seq_server_set_cli(struct lu_server_seq *seq,
144 struct lu_client_seq *cli,
145 const struct lu_context *ctx);
148 int seq_client_init(struct lu_client_seq *seq,
150 struct obd_export *exp);
152 void seq_client_fini(struct lu_client_seq *seq);
154 int seq_client_alloc_super(struct lu_client_seq *seq);
155 int seq_client_alloc_meta(struct lu_client_seq *seq);
157 int seq_client_alloc_seq(struct lu_client_seq *seq,
159 int seq_client_alloc_fid(struct lu_client_seq *seq,
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);
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);
171 #endif /* __LINUX_OBD_CLASS_H */