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