Whamcloud - gitweb
Merge from posix_stable.
[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_conn_info {
19         unsigned int conn_id;     /* handle */
20 };
21
22 struct obd_type {
23         struct list_head typ_chain;
24         struct obd_ops *typ_ops;
25         char *typ_name;
26         int  typ_refcnt;
27 };
28
29 #define OBD_RUN_CTXT_MAGIC      0xC0FFEEAA
30 #define OBD_CTXT_DEBUG          /* development-only debugging */
31
32 struct obd_run_ctxt {
33         struct vfsmount *pwdmnt;
34         struct dentry   *pwd;
35         mm_segment_t     fs;
36 #ifdef OBD_CTXT_DEBUG
37         __u32            magic;
38 #endif
39 };
40
41 struct obd_conn {
42         struct obd_device *oc_dev;
43         uint32_t oc_id;
44 };
45
46 struct obd_devicename {
47         uint32_t len;
48         char *name;
49         struct dentry *dentry;   /* file system obd device names */
50         __u8 _uuid[16];          /* uuid obd device names */
51 };
52
53
54 /* Individual type definitions */
55
56 struct ext2_obd {
57         struct super_block *e2_sb;
58         struct vfsmount *e2_vfsmnt;
59 };
60
61 struct filter_obd {
62         char *fo_fstype;
63         struct super_block *fo_sb;
64         struct vfsmount *fo_vfsmnt;
65         struct obd_run_ctxt fo_ctxt;
66         struct dentry *fo_dentry_O;
67         struct dentry *fo_dentry_O_mode[16];
68         spinlock_t fo_lock;
69         __u64 fo_lastino;
70         struct file_operations *fo_fop;
71         struct inode_operations *fo_iop;
72         struct address_space_operations *fo_aops;
73 };
74
75 struct mds_client_info;
76 struct mds_server_data;
77
78 struct mdc_obd {
79         struct ptlrpc_client *mdc_client;
80         struct ptlrpc_client *mdc_ldlm_client;
81         struct ptlrpc_connection *mdc_conn;
82         __u8 mdc_target_uuid[37];
83 };
84
85 struct mds_obd {
86         struct ldlm_namespace *mds_local_namespace;
87         struct ptlrpc_service *mds_service;
88         struct ptlrpc_client *mds_ldlm_client; /* to be an LDLM client */
89         struct ptlrpc_connection *mds_ldlm_conn; /* to be an LDLM client */
90
91         char *mds_fstype;
92         struct super_block *mds_sb;
93         struct super_operations *mds_sop;
94         struct vfsmount *mds_vfsmnt;
95         struct obd_run_ctxt mds_ctxt;
96         struct file_operations *mds_fop;
97         struct inode_operations *mds_iop;
98         struct address_space_operations *mds_aops;
99         struct mds_fs_operations *mds_fsops;
100         struct file *mds_rcvd_filp;
101         __u64 mds_last_committed;
102         __u64 mds_last_rcvd;
103         __u64 mds_mount_count;
104         struct ll_fid mds_rootfid;
105         int mds_client_count;
106         struct list_head mds_client_info;
107         struct mds_server_data *mds_server_data;
108 };
109
110 struct ldlm_obd {
111         struct ptlrpc_service *ldlm_service;
112         struct ptlrpc_client *ldlm_client;
113         struct ptlrpc_connection *ldlm_server_conn;
114 };
115
116 struct echo_obd {
117         char *eo_fstype;
118         struct super_block *eo_sb;
119         struct vfsmount *eo_vfsmnt;
120         struct obd_run_ctxt eo_ctxt;
121         spinlock_t eo_lock;
122         __u64 eo_lastino;
123         struct file_operations *eo_fop;
124         struct inode_operations *eo_iop;
125         struct address_space_operations *eo_aops;
126 };
127
128 struct recovd_obd {
129         time_t                recovd_waketime;
130         time_t                recovd_timeout;
131         struct ptlrpc_service *recovd_service;
132         struct ptlrpc_client  *recovd_client;
133         __u32                  recovd_flags; 
134         __u32                  recovd_wakeup_flag; 
135         spinlock_t             recovd_lock;
136         struct list_head      recovd_clients_lh; /* clients managed  */
137         struct list_head      recovd_troubled_lh; /* clients in trouble */
138         wait_queue_head_t     recovd_recovery_waitq;
139         wait_queue_head_t     recovd_ctl_waitq;
140         wait_queue_head_t     recovd_waitq;
141         struct task_struct    *recovd_thread;
142 };
143
144 struct trace_obd {
145         struct obdtrace_opstats *stats;
146 };
147
148 #if 0
149 struct snap_obd {
150         unsigned int snap_index;  /* which snapshot index are we accessing */
151         int snap_tableno;
152 };
153
154 struct raid1_obd {
155         unsigned int raid1_count; /* how many replicas */
156         /* devices to replicate on */
157         struct obd_device *raid1_devlist[MAX_RAID1];
158         /* connections we make */
159         struct obd_conn_info raid1_connections[MAX_RAID1];
160         struct list_head raid1_clients;  /* clients we have */
161 };
162 #endif
163
164 struct ost_obd {
165         struct ptlrpc_service *ost_service;
166         struct obd_device *ost_tgt; /* the exported OBD */ 
167         struct obd_conn ost_conn;   /* the local connection to the OBD */
168 };
169
170 struct osc_obd {
171         struct obd_device *osc_tgt;
172         struct ptlrpc_client *osc_client;
173         struct ptlrpc_client *osc_ldlm_client;
174         struct ptlrpc_connection *osc_conn;
175         __u8 osc_target_uuid[37];
176 };
177
178 typedef __u8 uuid_t[37];
179
180 #define MAX_MULTI       16
181 struct lov_obd {
182         __u32 lov_default_count;
183         __u32 lov_default_pattern;
184         __u32 lov_default_size;
185         uuid_t lov_service_uuids[MAX_MULTI];
186
187 #if 0
188         int lov_count;
189         struct obd_conn *lov_targets;
190 #endif
191 };
192
193 /* corresponds to one of the obd's */
194 struct obd_device {
195         struct obd_type *obd_type;
196         char *obd_name;
197         __u8 obd_uuid[37];
198
199         int obd_minor;
200         int obd_flags;
201         int obd_refcnt;
202         struct obd_devicename obd_fsname;
203         struct proc_dir_entry *obd_proc_entry;
204         int obd_multi_count;
205         struct obd_conn obd_multi_conn[MAX_MULTI];
206         unsigned int obd_gen_last_id;
207         unsigned long obd_gen_prealloc_quota;
208         struct list_head obd_gen_clients;
209         struct list_head obd_req_list;
210         wait_queue_head_t obd_req_waitq;
211         struct ldlm_namespace *obd_namespace;
212         union {
213                 struct ext2_obd ext2;
214                 struct filter_obd filter;
215                 struct mds_obd mds;
216                 struct mdc_obd mdc;
217                 struct ost_obd ost;
218                 struct osc_obd osc;
219                 struct ldlm_obd ldlm;
220                 struct echo_obd echo;
221                 struct recovd_obd recovd;
222                 struct trace_obd trace;
223                 struct lov_obd lov;
224 #if 0
225                 struct raid1_obd raid1;
226                 struct snap_obd snap;
227 #endif
228         } u;
229 };
230
231 struct obd_ops {
232         int (*o_iocontrol)(long cmd, struct obd_conn *, int len, void *karg,
233                            void *uarg);
234         int (*o_get_info)(struct obd_conn *, obd_count keylen, void *key,
235                           obd_count *vallen, void **val);
236         int (*o_set_info)(struct obd_conn *, obd_count keylen, void *key,
237                           obd_count vallen, void *val);
238         int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
239         int (*o_detach)(struct obd_device *dev);
240         int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
241         int (*o_cleanup)(struct obd_device *dev);
242         int (*o_connect)(struct obd_conn *conn);
243         int (*o_disconnect)(struct obd_conn *conn);
244
245
246         int (*o_statfs)(struct obd_conn *conn, struct statfs *statfs);
247         int (*o_preallocate)(struct obd_conn *, obd_count *req, obd_id *ids);
248         int (*o_create)(struct obd_conn *conn,  struct obdo *oa);
249         int (*o_destroy)(struct obd_conn *conn, struct obdo *oa);
250         int (*o_setattr)(struct obd_conn *conn, struct obdo *oa);
251         int (*o_getattr)(struct obd_conn *conn, struct obdo *oa);
252         int (*o_open)(struct obd_conn *conn, struct obdo *oa);
253         int (*o_close)(struct obd_conn *conn, struct obdo *oa);
254         int (*o_read)(struct obd_conn *conn, struct obdo *oa, char *buf,
255                       obd_size *count, obd_off offset);
256         int (*o_write)(struct obd_conn *conn, struct obdo *oa, char *buf,
257                        obd_size *count, obd_off offset);
258         int (*o_brw)(int rw, struct obd_conn *conn, obd_count num_oa,
259                      struct obdo **oa, obd_count *oa_bufs, struct page **buf,
260                      obd_size *count, obd_off *offset, obd_flag *flags,
261                      void *);
262         int (*o_punch)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
263                        obd_off offset);
264         int (*o_sync)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
265                       obd_off offset);
266         int (*o_migrate)(struct obd_conn *conn, struct obdo *dst,
267                          struct obdo *src, obd_size count, obd_off offset);
268         int (*o_copy)(struct obd_conn *dstconn, struct obdo *dst,
269                       struct obd_conn *srconn, struct obdo *src,
270                       obd_size count, obd_off offset);
271         int (*o_iterate)(struct obd_conn *conn, int (*)(obd_id, obd_gr, void *),
272                          obd_id *startid, obd_gr group, void *data);
273         int (*o_preprw)(int cmd, struct obd_conn *conn,
274                         int objcount, struct obd_ioobj *obj,
275                         int niocount, struct niobuf_remote *remote,
276                         struct niobuf_local *local, void **desc_private);
277         int (*o_commitrw)(int cmd, struct obd_conn *conn,
278                           int objcount, struct obd_ioobj *obj,
279                           int niocount, struct niobuf_local *local,
280                           void *desc_private);
281         int (*o_enqueue)(struct obd_conn *conn,
282                          struct lustre_handle *parent_lock, __u64 *res_id,
283                          __u32 type, void *cookie, int cookielen, __u32 mode,
284                          int *flags, void *cb, void *data, int datalen,
285                          struct lustre_handle *lockh);
286         int (*o_cancel)(struct obd_conn *, __u32 mode, struct lustre_handle *);
287 };
288
289 #endif