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