Whamcloud - gitweb
14640fdc8c855184192b307ac6348c59b06ca4e3
[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 struct obd_run_ctxt {
30         struct vfsmount *pwdmnt;
31         struct dentry   *pwd;
32         mm_segment_t     fs;
33 };
34
35 struct obd_conn {
36         struct obd_device *oc_dev;
37         uint32_t oc_id;
38 };
39
40 struct obd_devicename {
41         uint32_t len;
42         char *name;
43         struct dentry *dentry;   /* file system obd device names */
44         __u8 _uuid[16];          /* uuid obd device names */
45 };
46
47
48 /* Individual type definitions */
49
50 struct ext2_obd {
51         struct super_block *e2_sb;
52         struct vfsmount *e2_vfsmnt;
53 };
54
55 struct filter_obd {
56         char *fo_fstype;
57         struct super_block *fo_sb;
58         struct vfsmount *fo_vfsmnt;
59         struct obd_run_ctxt fo_ctxt;
60         spinlock_t fo_lock;
61         __u64 fo_lastino;
62         struct file_operations *fo_fop;
63         struct inode_operations *fo_iop;
64         struct address_space_operations *fo_aops;
65 };
66
67 struct mds_client_info;
68 struct mds_server_data;
69
70 struct mds_obd {
71         struct ptlrpc_service *mds_service;
72
73         char *mds_fstype;
74         struct super_block *mds_sb;
75         struct vfsmount *mds_vfsmnt;
76         struct obd_run_ctxt mds_ctxt;
77         struct file_operations *mds_fop;
78         struct inode_operations *mds_iop;
79         struct address_space_operations *mds_aops;
80         struct mds_fs_operations *mds_fsops;
81         struct file *mds_rcvd_filp;
82         __u64 mds_last_rcvd;
83         __u64 mds_mount_count;
84         struct ll_fid mds_rootfid;
85         int mds_client_count;
86         struct mds_client_info *mds_client_info;
87         struct mds_server_data *mds_server_data;
88 };
89
90 struct ldlm_obd {
91         struct ptlrpc_service *ldlm_service;
92         struct ptlrpc_client *ldlm_client;
93         struct ptlrpc_connection *ldlm_server_conn;
94 };
95
96 struct echo_obd {
97         char *eo_fstype;
98         struct super_block *eo_sb;
99         struct vfsmount *eo_vfsmnt;
100         struct obd_run_ctxt eo_ctxt;
101         spinlock_t eo_lock;
102         __u64 eo_lastino;
103         struct file_operations *eo_fop;
104         struct inode_operations *eo_iop;
105         struct address_space_operations *eo_aops;
106 };
107
108 struct recovd_obd {
109         time_t                recovd_waketime;
110         time_t                recovd_timeout;
111         struct ptlrpc_service *recovd_service;
112         struct ptlrpc_client  *recovd_client;
113         __u32                  recovd_flags; 
114         spinlock_t             recovd_lock;
115         struct list_head      recovd_connections_lh; /* connections managed by the mgr */
116         struct list_head      recovd_troubled_lh; /* connections in trouble */
117         wait_queue_head_t     recovd_recovery_waitq;
118         wait_queue_head_t     recovd_ctl_waitq;
119         wait_queue_head_t     recovd_waitq;
120         struct task_struct    *recovd_thread;
121 };
122
123 struct trace_obd {
124         struct obdtrace_opstats *stats;
125 };
126
127 #if 0
128 struct snap_obd {
129         unsigned int snap_index;  /* which snapshot index are we accessing */
130         int snap_tableno;
131 };
132
133 struct raid1_obd {
134         unsigned int raid1_count; /* how many replicas */
135         /* devices to replicate on */
136         struct obd_device *raid1_devlist[MAX_RAID1];
137         /* connections we make */
138         struct obd_conn_info raid1_connections[MAX_RAID1];
139         struct list_head raid1_clients;  /* clients we have */
140 };
141 #endif
142
143 struct ost_obd {
144         struct ptlrpc_service *ost_service;
145
146         struct obd_device *ost_tgt;
147         struct obd_conn ost_conn;
148 };
149
150 struct osc_obd {
151         struct obd_device *osc_tgt;
152         struct ptlrpc_client *osc_client;
153         struct ptlrpc_client *osc_ldlm_client;
154         struct ptlrpc_connection *osc_conn;
155 };
156
157 /* corresponds to one of the obd's */
158 #define MAX_MULTI       16
159 struct obd_device {
160         struct obd_type *obd_type;
161         char *obd_name;
162         __u8 obd_uuid[37];
163
164         int obd_minor;
165         int obd_flags;
166         int obd_refcnt;
167         struct obd_devicename obd_fsname;
168         struct proc_dir_entry *obd_proc_entry;
169         int obd_multi_count;
170         struct obd_conn obd_multi_conn[MAX_MULTI];
171         unsigned int obd_gen_last_id;
172         unsigned long obd_gen_prealloc_quota;
173         struct list_head obd_gen_clients;
174         struct list_head obd_req_list;
175         wait_queue_head_t obd_req_waitq;
176         union {
177                 struct ext2_obd ext2;
178                 struct filter_obd filter;
179                 struct mds_obd mds;
180                 struct ost_obd ost;
181                 struct osc_obd osc;
182                 struct ldlm_obd ldlm;
183                 struct echo_obd echo;
184                 struct recovd_obd recovd;
185                 struct trace_obd trace;
186 #if 0
187                 struct raid1_obd raid1;
188                 struct snap_obd snap;
189 #endif
190         } u;
191 };
192
193 struct obd_ops {
194         int (*o_iocontrol)(int cmd, struct obd_conn *, int len, void *karg,
195                            void *uarg);
196         int (*o_get_info)(struct obd_conn *, obd_count keylen, void *key,
197                           obd_count *vallen, void **val);
198         int (*o_set_info)(struct obd_conn *, obd_count keylen, void *key,
199                           obd_count vallen, void *val);
200         int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
201         int (*o_detach)(struct obd_device *dev);
202         int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
203         int (*o_cleanup)(struct obd_device *dev);
204         int (*o_connect)(struct obd_conn *conn);
205         int (*o_disconnect)(struct obd_conn *conn);
206
207
208         int (*o_statfs)(struct obd_conn *conn, struct statfs *statfs);
209         int (*o_preallocate)(struct obd_conn *, obd_count *req, obd_id *ids);
210         int (*o_create)(struct obd_conn *conn,  struct obdo *oa);
211         int (*o_destroy)(struct obd_conn *conn, struct obdo *oa);
212         int (*o_setattr)(struct obd_conn *conn, struct obdo *oa);
213         int (*o_getattr)(struct obd_conn *conn, struct obdo *oa);
214         int (*o_open)(struct obd_conn *conn, struct obdo *oa);
215         int (*o_close)(struct obd_conn *conn, struct obdo *oa);
216         int (*o_read)(struct obd_conn *conn, struct obdo *oa, char *buf,
217                       obd_size *count, obd_off offset);
218         int (*o_write)(struct obd_conn *conn, struct obdo *oa, char *buf,
219                        obd_size *count, obd_off offset);
220         int (*o_brw)(int rw, struct obd_conn *conn, obd_count num_oa,
221                      struct obdo **oa, obd_count *oa_bufs, struct page **buf,
222                      obd_size *count, obd_off *offset, obd_flag *flags);
223         int (*o_punch)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
224                        obd_off offset);
225         int (*o_sync)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
226                       obd_off offset);
227         int (*o_migrate)(struct obd_conn *conn, struct obdo *dst,
228                          struct obdo *src, obd_size count, obd_off offset);
229         int (*o_copy)(struct obd_conn *dstconn, struct obdo *dst,
230                       struct obd_conn *srconn, struct obdo *src,
231                       obd_size count, obd_off offset);
232         int (*o_iterate)(struct obd_conn *conn, int (*)(obd_id, obd_gr, void *),
233                          obd_id *startid, obd_gr group, void *data);
234         int (*o_preprw)(int cmd, struct obd_conn *conn,
235                         int objcount, struct obd_ioobj *obj,
236                         int niocount, struct niobuf *nb,
237                         struct niobuf *res);
238         int (*o_commitrw)(int cmd, struct obd_conn *conn,
239                           int objcount, struct obd_ioobj *obj,
240                           int niocount, struct niobuf *res);
241 };
242
243 #endif