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