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