Whamcloud - gitweb
We already set last_committed and last_xid for all packets, no need to do
[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         spinlock_t mds_last_lock;
127         __u64 mds_last_committed;
128         __u64 mds_last_rcvd;
129         __u64 mds_mount_count;
130         struct ll_fid mds_rootfid;
131         struct mds_server_data *mds_server_data;
132 };
133
134 struct ldlm_obd {
135         struct ptlrpc_service *ldlm_service;
136         struct ptlrpc_client *ldlm_client;
137         struct ptlrpc_connection *ldlm_server_conn;
138 };
139
140 struct echo_obd {
141         char *eo_fstype;
142         struct super_block *eo_sb;
143         struct vfsmount *eo_vfsmnt;
144         struct obd_run_ctxt eo_ctxt;
145         spinlock_t eo_lock;
146         __u64 eo_lastino;
147         struct file_operations *eo_fop;
148         struct inode_operations *eo_iop;
149         struct address_space_operations *eo_aops;
150 };
151
152 struct recovd_obd {
153         time_t                recovd_waketime;
154         time_t                recovd_timeout;
155         __u32                 recovd_flags; 
156         __u32                 recovd_wakeup_flag; 
157         spinlock_t            recovd_lock;
158         struct list_head      recovd_managed_items; /* items managed  */
159         struct list_head      recovd_troubled_items; /* items in trouble */
160         wait_queue_head_t     recovd_recovery_waitq;
161         wait_queue_head_t     recovd_ctl_waitq;
162         wait_queue_head_t     recovd_waitq;
163         struct task_struct    *recovd_thread;
164 };
165
166 struct trace_obd {
167         struct obdtrace_opstats *stats;
168 };
169
170 #if 0
171 struct snap_obd {
172         unsigned int snap_index;  /* which snapshot index are we accessing */
173         int snap_tableno;
174 };
175
176 #endif
177
178 struct ost_obd {
179         struct ptlrpc_service *ost_service;
180         struct lustre_handle ost_conn;   /* the local connection to the OBD */
181 };
182
183
184 struct lov_tgt_desc { 
185         uuid_t uuid;
186         struct lustre_handle conn; 
187 };
188
189 struct lov_obd {
190         struct obd_device *mdcobd;
191         struct lov_desc desc;
192         int bufsize; 
193         struct lov_tgt_desc *tgts;
194 };
195
196 struct niobuf_local {
197         __u64 offset;
198         __u32 len;
199         __u32 xid;
200         __u32 flags;
201         void *addr;
202         struct page *page;
203         void *target_private;
204         struct dentry *dentry;
205 };
206
207 #define N_LOCAL_TEMP_PAGE 0x00000001
208
209 /* corresponds to one of the obd's */
210 struct obd_device {
211         struct obd_type *obd_type;
212
213         /* common and UUID name of this device */
214         char *obd_name;
215         __u8 obd_uuid[37];
216
217         int obd_minor;
218         int obd_flags;
219         struct proc_dir_entry *obd_proc_entry;
220         struct list_head obd_exports;
221         struct list_head obd_imports;
222         struct ldlm_namespace *obd_namespace;
223         union {
224                 struct ext2_obd ext2;
225                 struct filter_obd filter;
226                 struct mds_obd mds;
227                 struct client_obd cli;
228                 struct ost_obd ost;
229                 //                struct osc_obd osc;
230                 struct ldlm_obd ldlm;
231                 struct echo_obd echo;
232                 struct recovd_obd recovd;
233                 struct trace_obd trace;
234                 struct lov_obd lov;
235 #if 0
236                 struct snap_obd snap;
237 #endif
238         } u;
239 };
240
241 struct io_cb_data;
242
243 struct obd_ops {
244         int (*o_iocontrol)(long cmd, struct lustre_handle *, int len,
245                            void *karg, void *uarg);
246         int (*o_get_info)(struct lustre_handle *, obd_count keylen, void *key,
247                           obd_count *vallen, void **val);
248         int (*o_set_info)(struct lustre_handle *, obd_count keylen, void *key,
249                           obd_count vallen, void *val);
250         int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
251         int (*o_detach)(struct obd_device *dev);
252         int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
253         int (*o_cleanup)(struct obd_device *dev);
254         int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
255                          char *cluuid);
256         int (*o_disconnect)(struct lustre_handle *conn);
257
258
259         int (*o_statfs)(struct lustre_handle *conn, struct statfs *statfs);
260         int (*o_preallocate)(struct lustre_handle *, obd_count *req,
261                              obd_id *ids);
262         int (*o_create)(struct lustre_handle *conn,  struct obdo *oa,
263                         struct lov_stripe_md **ea);
264         int (*o_destroy)(struct lustre_handle *conn, struct obdo *oa,
265                          struct lov_stripe_md *ea);
266         int (*o_setattr)(struct lustre_handle *conn, struct obdo *oa,
267                          struct lov_stripe_md *ea);
268         int (*o_getattr)(struct lustre_handle *conn, struct obdo *oa,
269                          struct lov_stripe_md *ea);
270         int (*o_open)(struct lustre_handle *conn, struct obdo *oa,
271                       struct lov_stripe_md *);
272         int (*o_close)(struct lustre_handle *conn, struct obdo *oa,
273                        struct lov_stripe_md *);
274         int (*o_brw)(int rw, struct lustre_handle *conn,
275                      struct lov_stripe_md *md, obd_count oa_bufs,
276                      struct brw_page *pgarr, brw_callback_t callback, 
277                      struct io_cb_data *data);
278         int (*o_punch)(struct lustre_handle *conn, struct obdo *tgt,
279                        struct lov_stripe_md *md, obd_size count,
280                        obd_off offset);
281         int (*o_sync)(struct lustre_handle *conn, struct obdo *tgt,
282                       obd_size count, obd_off offset);
283         int (*o_migrate)(struct lustre_handle *conn, struct obdo *dst,
284                          struct obdo *src, obd_size count, obd_off offset);
285         int (*o_copy)(struct lustre_handle *dstconn, struct obdo *dst,
286                       struct lustre_handle *srconn, struct obdo *src,
287                       obd_size count, obd_off offset);
288         int (*o_iterate)(struct lustre_handle *conn,
289                          int (*)(obd_id, obd_gr, void *),
290                          obd_id *startid, obd_gr group, void *data);
291         int (*o_preprw)(int cmd, struct lustre_handle *conn,
292                         int objcount, struct obd_ioobj *obj,
293                         int niocount, struct niobuf_remote *remote,
294                         struct niobuf_local *local, void **desc_private);
295         int (*o_commitrw)(int cmd, struct lustre_handle *conn,
296                           int objcount, struct obd_ioobj *obj,
297                           int niocount, struct niobuf_local *local,
298                           void *desc_private);
299         int (*o_enqueue)(struct lustre_handle *conn, struct lov_stripe_md *md,
300                          struct lustre_handle *parent_lock, 
301                          __u32 type, void *cookie, int cookielen, __u32 mode,
302                          int *flags, void *cb, void *data, int datalen,
303                          struct lustre_handle *lockh);
304         int (*o_cancel)(struct lustre_handle *, struct lov_stripe_md *md, __u32 mode, struct lustre_handle *);
305 };
306
307 /* FIXME: for 64-bit arch */
308 #define LPU64 "%Lu"
309 #define LPD64 "%Ld"
310 #define LPX64 "%Lx"
311
312 #endif