Whamcloud - gitweb
This commit contains probably 92% of the striping infrastructure
[fs/lustre-release.git] / lustre / include / linux / obd.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2001  Cluster File Systems, Inc.
5  *
6  * This code is issued under the GNU General Public License.
7  * See the file COPYING in this distribution
8  */
9
10 #ifndef __OBD_H
11 #define __OBD_H
12 #include <linux/fs.h>
13 #include <linux/list.h>
14 #include <linux/smp_lock.h>
15
16 #include <linux/lustre_idl.h>
17
18 struct obd_type {
19         struct list_head typ_chain;
20         struct obd_ops *typ_ops;
21         char *typ_name;
22         int  typ_refcnt;
23 };
24
25
26 /* Individual type definitions */
27
28 struct ext2_obd {
29         struct super_block *e2_sb;
30         struct vfsmount *e2_vfsmnt;
31 };
32
33 #define OBD_RUN_CTXT_MAGIC      0xC0FFEEAA
34 #define OBD_CTXT_DEBUG          /* development-only debugging */
35 struct obd_run_ctxt {
36         struct vfsmount *pwdmnt;
37         struct dentry   *pwd;
38         mm_segment_t     fs;
39 #ifdef OBD_CTXT_DEBUG
40         __u32            magic;
41 #endif
42 };
43
44 struct filter_obd {
45         char *fo_fstype;
46         struct super_block *fo_sb;
47         struct vfsmount *fo_vfsmnt;
48         struct obd_run_ctxt fo_ctxt;
49         struct dentry *fo_dentry_O;
50         struct dentry *fo_dentry_O_mode[16];
51         spinlock_t fo_lock;
52         __u64 fo_lastino;
53         struct file_operations *fo_fop;
54         struct inode_operations *fo_iop;
55         struct address_space_operations *fo_aops;
56 };
57
58 struct mds_client_info;
59 struct mds_server_data;
60
61 struct mdc_obd {
62         struct lustre_handle mdc_connh;
63         struct ptlrpc_client *mdc_client;
64         struct ptlrpc_client *mdc_ldlm_client;
65         struct ptlrpc_connection *mdc_conn;
66         int mdc_max_mdsize;
67         __u8 mdc_target_uuid[37];
68 };
69
70 struct osc_obd {
71         struct lustre_handle osc_connh;
72         struct ptlrpc_client *osc_client;
73         struct ptlrpc_client *osc_ldlm_client;
74         struct ptlrpc_connection *osc_conn;
75         __u8 osc_target_uuid[37];
76 };
77
78 struct mds_obd {
79         struct ldlm_namespace *mds_local_namespace;
80         struct ptlrpc_service *mds_service;
81         struct ptlrpc_client *mds_ldlm_client; /* to be an LDLM client */
82         struct ptlrpc_connection *mds_ldlm_conn; /* to be an LDLM client */
83         struct lustre_handle mds_connh; /* to be one's on DLM client */
84
85         char *mds_fstype;
86         struct super_block *mds_sb;
87         struct super_operations *mds_sop;
88         struct vfsmount *mds_vfsmnt;
89         struct obd_run_ctxt mds_ctxt;
90         struct file_operations *mds_fop;
91         struct inode_operations *mds_iop;
92         struct address_space_operations *mds_aops;
93         struct mds_fs_operations *mds_fsops;
94         int mds_max_mdsize;
95         struct file *mds_rcvd_filp;
96         __u64 mds_last_committed;
97         __u64 mds_last_rcvd;
98         __u64 mds_mount_count;
99         struct ll_fid mds_rootfid;
100         int mds_client_count;
101         struct list_head mds_client_info;
102         struct mds_server_data *mds_server_data;
103 };
104
105 struct ldlm_obd {
106         struct ptlrpc_service *ldlm_service;
107         struct ptlrpc_client *ldlm_client;
108         struct ptlrpc_connection *ldlm_server_conn;
109 };
110
111 struct echo_obd {
112         char *eo_fstype;
113         struct super_block *eo_sb;
114         struct vfsmount *eo_vfsmnt;
115         struct obd_run_ctxt eo_ctxt;
116         spinlock_t eo_lock;
117         __u64 eo_lastino;
118         struct file_operations *eo_fop;
119         struct inode_operations *eo_iop;
120         struct address_space_operations *eo_aops;
121 };
122
123 struct recovd_obd {
124         time_t                recovd_waketime;
125         time_t                recovd_timeout;
126         struct ptlrpc_service *recovd_service;
127         struct ptlrpc_client  *recovd_client;
128         __u32                  recovd_flags; 
129         __u32                  recovd_wakeup_flag; 
130         spinlock_t             recovd_lock;
131         struct list_head      recovd_clients_lh; /* clients managed  */
132         struct list_head      recovd_troubled_lh; /* clients in trouble */
133         wait_queue_head_t     recovd_recovery_waitq;
134         wait_queue_head_t     recovd_ctl_waitq;
135         wait_queue_head_t     recovd_waitq;
136         struct task_struct    *recovd_thread;
137 };
138
139 struct trace_obd {
140         struct obdtrace_opstats *stats;
141 };
142
143 #if 0
144 struct snap_obd {
145         unsigned int snap_index;  /* which snapshot index are we accessing */
146         int snap_tableno;
147 };
148
149 #endif
150
151 struct ost_obd {
152         struct ptlrpc_service *ost_service;
153         struct lustre_handle ost_conn;   /* the local connection to the OBD */
154 };
155
156
157 struct lov_tgt_desc { 
158         uuid_t uuid;
159         struct lustre_handle conn; 
160 };
161
162 struct lov_obd {
163         struct obd_device *mdcobd;
164         struct lov_desc desc;
165         int bufsize; 
166         struct lov_tgt_desc *tgts;
167 };
168
169 struct niobuf_local {
170         __u64 offset;
171         __u32 len;
172         __u32 xid;
173         __u32 flags;
174         void *addr;
175         struct page *page;
176         void *target_private;
177         struct dentry *dentry;
178 };
179
180 #define N_LOCAL_TEMP_PAGE 0x00000001
181
182 /* corresponds to one of the obd's */
183 struct obd_device {
184         struct obd_type *obd_type;
185
186         /* common and UUID name of this device */
187         char *obd_name;
188         __u8 obd_uuid[37];
189
190         int obd_minor;
191         int obd_flags;
192         struct proc_dir_entry *obd_proc_entry;
193         struct list_head obd_exports;
194         struct list_head obd_imports;
195         struct ldlm_namespace *obd_namespace;
196         union {
197                 struct ext2_obd ext2;
198                 struct filter_obd filter;
199                 struct mds_obd mds;
200                 struct mdc_obd mdc;
201                 struct ost_obd ost;
202                 struct osc_obd osc;
203                 struct ldlm_obd ldlm;
204                 struct echo_obd echo;
205                 struct recovd_obd recovd;
206                 struct trace_obd trace;
207                 struct lov_obd lov;
208 #if 0
209                 struct snap_obd snap;
210 #endif
211         } u;
212 };
213
214 struct obd_ops {
215         int (*o_iocontrol)(long cmd, struct lustre_handle *, int len, void *karg,
216                            void *uarg);
217         int (*o_get_info)(struct lustre_handle *, 
218                           obd_count keylen, void *key,
219                           obd_count *vallen, void **val);
220         int (*o_set_info)(struct lustre_handle *, 
221                           obd_count keylen, void *key,
222                           obd_count vallen, void *val);
223         int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
224         int (*o_detach)(struct obd_device *dev);
225         int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
226         int (*o_cleanup)(struct obd_device *dev);
227         int (*o_connect)(struct lustre_handle *conn, struct obd_device *src);
228         int (*o_disconnect)(struct lustre_handle *conn);
229
230
231         int (*o_statfs)(struct lustre_handle *conn, struct statfs *statfs);
232         int (*o_preallocate)(struct lustre_handle *, obd_count *req, obd_id *ids);
233         int (*o_create)(struct lustre_handle *conn,  struct obdo *oa, 
234                         struct lov_stripe_md **ea);
235         int (*o_destroy)(struct lustre_handle *conn, struct obdo *oa, 
236                          struct lov_stripe_md *ea);
237         int (*o_setattr)(struct lustre_handle *conn, struct obdo *oa);
238         int (*o_getattr)(struct lustre_handle *conn, struct obdo *oa);
239         int (*o_open)(struct lustre_handle *conn, struct obdo *oa,
240                       struct lov_stripe_md *);
241         int (*o_close)(struct lustre_handle *conn, struct obdo *oa,
242                        struct lov_stripe_md *);
243         int (*o_brw)(int rw, struct lustre_handle *conn, 
244                      struct lov_stripe_md *md, obd_count oa_bufs, 
245                      struct page **buf,
246                      obd_size *count, 
247                      obd_off *offset, 
248                      obd_flag *flags,
249                      void *);
250         int (*o_punch)(struct lustre_handle *conn, struct obdo *tgt, struct lov_stripe_md *md, obd_size count,
251                        obd_off offset);
252         int (*o_sync)(struct lustre_handle *conn, struct obdo *tgt, obd_size count,
253                       obd_off offset);
254         int (*o_migrate)(struct lustre_handle *conn, struct obdo *dst,
255                          struct obdo *src, obd_size count, obd_off offset);
256         int (*o_copy)(struct lustre_handle *dstconn, struct obdo *dst,
257                       struct lustre_handle *srconn, struct obdo *src,
258                       obd_size count, obd_off offset);
259         int (*o_iterate)(struct lustre_handle *conn, int (*)(obd_id, obd_gr, void *),
260                          obd_id *startid, obd_gr group, void *data);
261         int (*o_preprw)(int cmd, struct lustre_handle *conn,
262                         int objcount, struct obd_ioobj *obj,
263                         int niocount, struct niobuf_remote *remote,
264                         struct niobuf_local *local, void **desc_private);
265         int (*o_commitrw)(int cmd, struct lustre_handle *conn,
266                           int objcount, struct obd_ioobj *obj,
267                           int niocount, struct niobuf_local *local,
268                           void *desc_private);
269         int (*o_enqueue)(struct lustre_handle *conn,
270                          struct lustre_handle *parent_lock, __u64 *res_id,
271                          __u32 type, void *cookie, int cookielen, __u32 mode,
272                          int *flags, void *cb, void *data, int datalen,
273                          struct lustre_handle *lockh);
274         int (*o_cancel)(struct lustre_handle *, __u32 mode, struct lustre_handle *);
275 };
276
277 #endif