Whamcloud - gitweb
Commit prototype changes in headers.
[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 #include <linux/proc_fs.h>
16
17 #include <linux/lustre_idl.h>
18
19 struct obd_type {
20         struct list_head typ_chain;
21         struct obd_ops *typ_ops;
22         char *typ_name;
23         int  typ_refcnt;
24 };
25
26
27 /* Individual type definitions */
28
29 struct ext2_obd {
30         struct super_block *e2_sb;
31         struct vfsmount *e2_vfsmnt;
32 };
33
34 #define OBD_RUN_CTXT_MAGIC      0xC0FFEEAA
35 #define OBD_CTXT_DEBUG          /* development-only debugging */
36 struct obd_run_ctxt {
37         struct vfsmount *pwdmnt;
38         struct dentry   *pwd;
39         mm_segment_t     fs;
40 #ifdef OBD_CTXT_DEBUG
41         __u32            magic;
42 #endif
43 };
44
45 struct filter_obd {
46         char *fo_fstype;
47         struct super_block *fo_sb;
48         struct vfsmount *fo_vfsmnt;
49         struct obd_run_ctxt fo_ctxt;
50         struct dentry *fo_dentry_O;
51         struct dentry *fo_dentry_O_mode[16];
52         spinlock_t fo_lock;
53         __u64 fo_lastino;
54         struct file_operations *fo_fop;
55         struct inode_operations *fo_iop;
56         struct address_space_operations *fo_aops;
57 };
58
59 struct mds_server_data;
60
61 struct client_obd {
62         struct ptlrpc_client *cl_client;
63         struct ptlrpc_client *cl_ldlm_client;
64         struct ptlrpc_connection *cl_conn;
65         struct lustre_handle cl_exporth;
66         struct semaphore cl_sem;
67         int cl_conn_count;
68         __u8 cl_target_uuid[37];
69         int cl_max_mdsize;
70 };
71
72 #if 0
73 struct osc_obd {
74         struct ptlrpc_client *osc_client;
75         struct ptlrpc_client *osc_ldlm_client;
76         struct ptlrpc_connection *osc_conn;
77         __u8 osc_target_uuid[37];
78 };
79 #endif
80
81 struct mds_obd {
82         struct ptlrpc_service *mds_service;
83
84         char *mds_fstype;
85         struct super_block *mds_sb;
86         struct super_operations *mds_sop;
87         struct vfsmount *mds_vfsmnt;
88         struct obd_run_ctxt mds_ctxt;
89         struct file_operations *mds_fop;
90         struct inode_operations *mds_iop;
91         struct address_space_operations *mds_aops;
92         struct mds_fs_operations *mds_fsops;
93         int mds_max_mdsize;
94         struct file *mds_rcvd_filp;
95         __u64 mds_last_committed;
96         __u64 mds_last_rcvd;
97         __u64 mds_mount_count;
98         struct ll_fid mds_rootfid;
99         struct mds_server_data *mds_server_data;
100 };
101
102 struct ldlm_obd {
103         struct ptlrpc_service *ldlm_service;
104         struct ptlrpc_client *ldlm_client;
105         struct ptlrpc_connection *ldlm_server_conn;
106 };
107
108 struct echo_obd {
109         char *eo_fstype;
110         struct super_block *eo_sb;
111         struct vfsmount *eo_vfsmnt;
112         struct obd_run_ctxt eo_ctxt;
113         spinlock_t eo_lock;
114         __u64 eo_lastino;
115         struct file_operations *eo_fop;
116         struct inode_operations *eo_iop;
117         struct address_space_operations *eo_aops;
118 };
119
120 struct recovd_obd {
121         time_t                recovd_waketime;
122         time_t                recovd_timeout;
123         struct ptlrpc_service *recovd_service;
124         struct ptlrpc_client  *recovd_client;
125         __u32                  recovd_flags; 
126         __u32                  recovd_wakeup_flag; 
127         spinlock_t             recovd_lock;
128         struct list_head      recovd_clients_lh; /* clients managed  */
129         struct list_head      recovd_troubled_lh; /* clients in trouble */
130         wait_queue_head_t     recovd_recovery_waitq;
131         wait_queue_head_t     recovd_ctl_waitq;
132         wait_queue_head_t     recovd_waitq;
133         struct task_struct    *recovd_thread;
134 };
135
136 struct trace_obd {
137         struct obdtrace_opstats *stats;
138 };
139
140 #if 0
141 struct snap_obd {
142         unsigned int snap_index;  /* which snapshot index are we accessing */
143         int snap_tableno;
144 };
145
146 #endif
147
148 struct ost_obd {
149         struct ptlrpc_service *ost_service;
150         struct lustre_handle ost_conn;   /* the local connection to the OBD */
151 };
152
153
154 struct lov_tgt_desc { 
155         uuid_t uuid;
156         struct lustre_handle conn; 
157 };
158
159 struct lov_obd {
160         struct obd_device *mdcobd;
161         struct lov_desc desc;
162         int bufsize; 
163         struct lov_tgt_desc *tgts;
164 };
165
166 struct niobuf_local {
167         __u64 offset;
168         __u32 len;
169         __u32 xid;
170         __u32 flags;
171         void *addr;
172         struct page *page;
173         void *target_private;
174         struct dentry *dentry;
175 };
176
177 #define N_LOCAL_TEMP_PAGE 0x00000001
178
179 /* corresponds to one of the obd's */
180 struct obd_device {
181         struct obd_type *obd_type;
182
183         /* common and UUID name of this device */
184         char *obd_name;
185         __u8 obd_uuid[37];
186
187         int obd_minor;
188         int obd_flags;
189         struct proc_dir_entry *obd_proc_entry;
190         struct list_head obd_exports;
191         struct list_head obd_imports;
192         struct ldlm_namespace *obd_namespace;
193         union {
194                 struct ext2_obd ext2;
195                 struct filter_obd filter;
196                 struct mds_obd mds;
197                 struct client_obd cli;
198                 struct ost_obd ost;
199                 //                struct osc_obd osc;
200                 struct ldlm_obd ldlm;
201                 struct echo_obd echo;
202                 struct recovd_obd recovd;
203                 struct trace_obd trace;
204                 struct lov_obd lov;
205 #if 0
206                 struct snap_obd snap;
207 #endif
208         } u;
209 };
210
211 typedef void (*brw_callback_t)(void *);
212
213 struct obd_ops {
214         int (*o_iocontrol)(long cmd, struct lustre_handle *, int len,
215                            void *karg, void *uarg);
216         int (*o_get_info)(struct lustre_handle *, obd_count keylen, void *key,
217                           obd_count *vallen, void **val);
218         int (*o_set_info)(struct lustre_handle *, obd_count keylen, void *key,
219                           obd_count vallen, void *val);
220         int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
221         int (*o_detach)(struct obd_device *dev);
222         int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
223         int (*o_cleanup)(struct obd_device *dev);
224         int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
225                          char *cluuid);
226         int (*o_disconnect)(struct lustre_handle *conn);
227
228
229         int (*o_statfs)(struct lustre_handle *conn, struct statfs *statfs);
230         int (*o_preallocate)(struct lustre_handle *, obd_count *req,
231                              obd_id *ids);
232         int (*o_create)(struct lustre_handle *conn,  struct obdo *oa,
233                         struct lov_stripe_md **ea);
234         int (*o_destroy)(struct lustre_handle *conn, struct obdo *oa,
235                          struct lov_stripe_md *ea);
236         int (*o_setattr)(struct lustre_handle *conn, struct obdo *oa,
237                          struct lov_stripe_md *ea);
238         int (*o_getattr)(struct lustre_handle *conn, struct obdo *oa,
239                          struct lov_stripe_md *ea);
240         int (*o_open)(struct lustre_handle *conn, struct obdo *oa,
241                       struct lov_stripe_md *);
242         int (*o_close)(struct lustre_handle *conn, struct obdo *oa,
243                        struct lov_stripe_md *);
244         int (*o_brw)(int rw, struct lustre_handle *conn,
245                      struct lov_stripe_md *md, obd_count oa_bufs,
246                      struct page **buf, obd_size *count, obd_off *offset,
247                      obd_flag *flags, brw_callback_t callback, void * data);
248         int (*o_punch)(struct lustre_handle *conn, struct obdo *tgt,
249                        struct lov_stripe_md *md, obd_size count,
250                        obd_off offset);
251         int (*o_sync)(struct lustre_handle *conn, struct obdo *tgt,
252                       obd_size count, obd_off offset);
253         int (*o_migrate)(struct lustre_handle *conn, struct obdo *dst,
254                          struct obdo *src, obd_size count, obd_off offset);
255         int (*o_copy)(struct lustre_handle *dstconn, struct obdo *dst,
256                       struct lustre_handle *srconn, struct obdo *src,
257                       obd_size count, obd_off offset);
258         int (*o_iterate)(struct lustre_handle *conn,
259                          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,
275                         struct lustre_handle *);
276 };
277
278 #endif