Whamcloud - gitweb
ac9667f7c04b838be0d256a0cb19ffc89c0902c0
[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_obd {
68         struct ptlrpc_service *mds_service;
69
70         char *mds_fstype;
71         struct super_block *mds_sb;
72         struct vfsmount *mds_vfsmnt;
73         struct obd_run_ctxt mds_ctxt;
74         struct file_operations *mds_fop;
75         struct inode_operations *mds_iop;
76         struct address_space_operations *mds_aops;
77         struct mds_fs_operations *mds_fsops;
78 };
79
80 struct ldlm_obd {
81         struct ptlrpc_service *ldlm_service;
82         struct ptlrpc_client *ldlm_client;
83         struct ptlrpc_connection *ldlm_server_conn;
84 };
85
86 struct echo_obd {
87         char *eo_fstype;
88         struct super_block *eo_sb;
89         struct vfsmount *eo_vfsmnt;
90         struct obd_run_ctxt eo_ctxt;
91         spinlock_t eo_lock;
92         __u64 eo_lastino;
93         struct file_operations *eo_fop;
94         struct inode_operations *eo_iop;
95         struct address_space_operations *eo_aops;
96 };
97
98 struct connmgr_obd {
99         time_t                mgr_waketime;
100         time_t                mgr_timeout;
101         struct ptlrpc_service *mgr_service;
102         struct ptlrpc_client  *mgr_client;
103         __u32                  mgr_flags; 
104         spinlock_t             mgr_lock;
105         struct list_head      mgr_connections_lh; /* connections managed by the mgr */
106         struct list_head      mgr_troubled_lh; /* connections in trouble */
107         wait_queue_head_t     mgr_ctl_waitq;
108         wait_queue_head_t     mgr_waitq;
109         struct task_struct    *mgr_thread;
110 };
111
112 struct trace_obd {
113         struct obdtrace_opstats *stats;
114 };
115
116 #if 0
117 struct snap_obd {
118         unsigned int snap_index;  /* which snapshot index are we accessing */
119         int snap_tableno;
120 };
121
122 struct raid1_obd {
123         unsigned int raid1_count; /* how many replicas */
124         /* devices to replicate on */
125         struct obd_device *raid1_devlist[MAX_RAID1];
126         /* connections we make */
127         struct obd_conn_info raid1_connections[MAX_RAID1];
128         struct list_head raid1_clients;  /* clients we have */
129 };
130 #endif
131
132 struct ost_obd {
133         struct ptlrpc_service *ost_service;
134
135         struct obd_device *ost_tgt;
136         struct obd_conn ost_conn;
137 };
138
139 struct osc_obd {
140         struct obd_device *osc_tgt;
141         struct ptlrpc_client *osc_client;
142         struct ptlrpc_connection *osc_conn;
143 };
144
145 /* corresponds to one of the obd's */
146 #define MAX_MULTI       16
147 struct obd_device {
148         struct obd_type *obd_type;
149         int obd_minor;
150         int obd_flags;
151         int obd_refcnt;
152         struct obd_devicename obd_fsname;
153         struct proc_dir_entry *obd_proc_entry;
154         int obd_multi_count;
155         struct obd_conn obd_multi_conn[MAX_MULTI];
156         unsigned int obd_gen_last_id;
157         unsigned long obd_gen_prealloc_quota;
158         struct list_head obd_gen_clients;
159         struct list_head obd_req_list;
160         wait_queue_head_t obd_req_waitq;
161         union {
162                 struct ext2_obd ext2;
163                 struct filter_obd filter;
164                 struct mds_obd mds;
165                 struct ost_obd ost;
166                 struct osc_obd osc;
167                 struct ldlm_obd ldlm;
168                 struct echo_obd echo;
169                 struct connmgr_obd mgr;
170                 struct trace_obd trace;
171 #if 0
172                 struct raid1_obd raid1;
173                 struct snap_obd snap;
174 #endif
175         } u;
176 };
177
178 struct obd_ops {
179         int (*o_iocontrol)(int cmd, struct obd_conn *, int len, void *karg,
180                            void *uarg);
181         int (*o_get_info)(struct obd_conn *, obd_count keylen, void *key,
182                           obd_count *vallen, void **val);
183         int (*o_set_info)(struct obd_conn *, obd_count keylen, void *key,
184                           obd_count vallen, void *val);
185         int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
186         int (*o_detach)(struct obd_device *dev);
187         int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
188         int (*o_cleanup)(struct obd_device *dev);
189         int (*o_connect)(struct obd_conn *conn);
190         int (*o_disconnect)(struct obd_conn *conn);
191         int (*o_statfs)(struct obd_conn *conn, struct statfs *statfs);
192         int (*o_preallocate)(struct obd_conn *, obd_count *req, obd_id *ids);
193         int (*o_create)(struct obd_conn *conn,  struct obdo *oa);
194         int (*o_destroy)(struct obd_conn *conn, struct obdo *oa);
195         int (*o_setattr)(struct obd_conn *conn, struct obdo *oa);
196         int (*o_getattr)(struct obd_conn *conn, struct obdo *oa);
197         int (*o_open)(struct obd_conn *conn, struct obdo *oa);
198         int (*o_close)(struct obd_conn *conn, struct obdo *oa);
199         int (*o_read)(struct obd_conn *conn, struct obdo *oa, char *buf,
200                       obd_size *count, obd_off offset);
201         int (*o_write)(struct obd_conn *conn, struct obdo *oa, char *buf,
202                        obd_size *count, obd_off offset);
203         int (*o_brw)(int rw, struct obd_conn *conn, obd_count num_oa,
204                      struct obdo **oa, obd_count *oa_bufs, struct page **buf,
205                      obd_size *count, obd_off *offset, obd_flag *flags);
206         int (*o_punch)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
207                        obd_off offset);
208         int (*o_sync)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
209                       obd_off offset);
210         int (*o_migrate)(struct obd_conn *conn, struct obdo *dst,
211                          struct obdo *src, obd_size count, obd_off offset);
212         int (*o_copy)(struct obd_conn *dstconn, struct obdo *dst,
213                       struct obd_conn *srconn, struct obdo *src,
214                       obd_size count, obd_off offset);
215         int (*o_iterate)(struct obd_conn *conn, int (*)(obd_id, obd_gr, void *),
216                          obd_id *startid, obd_gr group, void *data);
217         int (*o_preprw)(int cmd, struct obd_conn *conn,
218                         int objcount, struct obd_ioobj *obj,
219                         int niocount, struct niobuf *nb,
220                         struct niobuf *res);
221         int (*o_commitrw)(int cmd, struct obd_conn *conn,
222                           int objcount, struct obd_ioobj *obj,
223                           int niocount, struct niobuf *res);
224 };
225
226 #endif