Whamcloud - gitweb
- More changes in the connection handle stuff. We are back to where
[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
16 #include <linux/lustre_idl.h>
17
18 struct obd_type {
19         struct list_head typ_chain;
20         struct obd_ops *typ_ops;
21         char *typ_name;
22         int  typ_refcnt;
23 };
24
25 #define OBD_RUN_CTXT_MAGIC      0xC0FFEEAA
26 #define OBD_CTXT_DEBUG          /* development-only debugging */
27 struct obd_run_ctxt {
28         struct vfsmount *pwdmnt;
29         struct dentry   *pwd;
30         mm_segment_t     fs;
31 #ifdef OBD_CTXT_DEBUG
32         __u32            magic;
33 #endif
34 };
35
36
37
38 struct obd_conn {
39         __u64 addr;
40         __u64 cookie;
41         struct obd_device *oc_dev;
42         uint32_t oc_id;
43 };
44
45 /* Individual type definitions */
46
47 struct ext2_obd {
48         struct super_block *e2_sb;
49         struct vfsmount *e2_vfsmnt;
50 };
51
52 struct filter_obd {
53         char *fo_fstype;
54         struct super_block *fo_sb;
55         struct vfsmount *fo_vfsmnt;
56         struct obd_run_ctxt fo_ctxt;
57         struct dentry *fo_dentry_O;
58         struct dentry *fo_dentry_O_mode[16];
59         spinlock_t fo_lock;
60         __u64 fo_lastino;
61         struct file_operations *fo_fop;
62         struct inode_operations *fo_iop;
63         struct address_space_operations *fo_aops;
64 };
65
66 struct mds_client_info;
67 struct mds_server_data;
68
69 struct mdc_obd {
70         struct ptlrpc_client *mdc_client;
71         struct ptlrpc_client *mdc_ldlm_client;
72         struct ptlrpc_connection *mdc_conn;
73         __u8 mdc_target_uuid[37];
74 };
75
76 struct mds_obd {
77         struct ldlm_namespace *mds_local_namespace;
78         struct ptlrpc_service *mds_service;
79         struct ptlrpc_client *mds_ldlm_client; /* to be an LDLM client */
80         struct ptlrpc_connection *mds_ldlm_conn; /* to be an LDLM client */
81
82         char *mds_fstype;
83         struct super_block *mds_sb;
84         struct super_operations *mds_sop;
85         struct vfsmount *mds_vfsmnt;
86         struct obd_run_ctxt mds_ctxt;
87         struct file_operations *mds_fop;
88         struct inode_operations *mds_iop;
89         struct address_space_operations *mds_aops;
90         struct mds_fs_operations *mds_fsops;
91         struct file *mds_rcvd_filp;
92         __u64 mds_last_committed;
93         __u64 mds_last_rcvd;
94         __u64 mds_mount_count;
95         struct ll_fid mds_rootfid;
96         int mds_client_count;
97         struct list_head mds_client_info;
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 obd_conn ost_conn;   /* the local connection to the OBD */
150 };
151
152 struct osc_obd {
153         struct lustre_handle osc_connh;
154         struct ptlrpc_client *osc_client;
155         struct ptlrpc_client *osc_ldlm_client;
156         struct ptlrpc_connection *osc_conn;
157         __u8 osc_target_uuid[37];
158 };
159
160 typedef __u8 uuid_t[37];
161
162 #define MAX_MULTI       16
163 struct lov_obd {
164         __u32 lov_default_count;
165         __u32 lov_default_pattern;
166         __u32 lov_default_size;
167         uuid_t lov_service_uuids[MAX_MULTI];
168
169 #if 0
170         int lov_count;
171         struct obd_conn *lov_targets;
172 #endif
173 };
174
175 /* corresponds to one of the obd's */
176 struct obd_device {
177         struct obd_type *obd_type;
178
179         /* common and UUID name of this device */
180         char *obd_name;
181         __u8 obd_uuid[37];
182
183         int obd_minor;
184         int obd_flags;
185         struct proc_dir_entry *obd_proc_entry;
186         int obd_multi_count;
187         struct obd_conn obd_multi_conn[MAX_MULTI];
188         unsigned int obd_gen_last_id;
189         unsigned long obd_gen_prealloc_quota;
190         //        struct obd_device *obd_target; /* for anything that simply layers */ 
191         struct list_head obd_exports;
192         struct list_head obd_imports;
193         struct ldlm_namespace *obd_namespace;
194         union {
195                 struct ext2_obd ext2;
196                 struct filter_obd filter;
197                 struct mds_obd mds;
198                 struct mdc_obd mdc;
199                 struct ost_obd ost;
200                 struct osc_obd osc;
201                 struct ldlm_obd ldlm;
202                 struct echo_obd echo;
203                 struct recovd_obd recovd;
204                 struct trace_obd trace;
205                 struct lov_obd lov;
206 #if 0
207                 struct snap_obd snap;
208 #endif
209         } u;
210 };
211
212 struct obd_ops {
213         int (*o_iocontrol)(long cmd, struct obd_conn *, int len, void *karg,
214                            void *uarg);
215         int (*o_get_info)(struct obd_conn *, obd_count keylen, void *key,
216                           obd_count *vallen, void **val);
217         int (*o_set_info)(struct obd_conn *, 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 obd_conn *conn, struct obd_device *src);
224         int (*o_disconnect)(struct obd_conn *conn);
225
226
227         int (*o_statfs)(struct obd_conn *conn, struct statfs *statfs);
228         int (*o_preallocate)(struct obd_conn *, obd_count *req, obd_id *ids);
229         int (*o_create)(struct obd_conn *conn,  struct obdo *oa);
230         int (*o_destroy)(struct obd_conn *conn, struct obdo *oa);
231         int (*o_setattr)(struct obd_conn *conn, struct obdo *oa);
232         int (*o_getattr)(struct obd_conn *conn, struct obdo *oa);
233         int (*o_open)(struct obd_conn *conn, struct obdo *oa);
234         int (*o_close)(struct obd_conn *conn, struct obdo *oa);
235         int (*o_brw)(int rw, struct obd_conn *conn, obd_count num_oa,
236                      struct obdo **oa, obd_count *oa_bufs, struct page **buf,
237                      obd_size *count, obd_off *offset, obd_flag *flags,
238                      void *);
239         int (*o_punch)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
240                        obd_off offset);
241         int (*o_sync)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
242                       obd_off offset);
243         int (*o_migrate)(struct obd_conn *conn, struct obdo *dst,
244                          struct obdo *src, obd_size count, obd_off offset);
245         int (*o_copy)(struct obd_conn *dstconn, struct obdo *dst,
246                       struct obd_conn *srconn, struct obdo *src,
247                       obd_size count, obd_off offset);
248         int (*o_iterate)(struct obd_conn *conn, int (*)(obd_id, obd_gr, void *),
249                          obd_id *startid, obd_gr group, void *data);
250         int (*o_preprw)(int cmd, struct obd_conn *conn,
251                         int objcount, struct obd_ioobj *obj,
252                         int niocount, struct niobuf_remote *remote,
253                         struct niobuf_local *local, void **desc_private);
254         int (*o_commitrw)(int cmd, struct obd_conn *conn,
255                           int objcount, struct obd_ioobj *obj,
256                           int niocount, struct niobuf_local *local,
257                           void *desc_private);
258         int (*o_enqueue)(struct obd_conn *conn,
259                          struct lustre_handle *parent_lock, __u64 *res_id,
260                          __u32 type, void *cookie, int cookielen, __u32 mode,
261                          int *flags, void *cb, void *data, int datalen,
262                          struct lustre_handle *lockh);
263         int (*o_cancel)(struct obd_conn *, __u32 mode, struct lustre_handle *);
264 };
265
266 #endif